From b2a4adbe23461671b5c3d648001618aa90b1b64d Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 2 Mar 2022 10:32:55 +0900 Subject: [PATCH 01/16] do not use "+" at configure.ac fix the build break due to upgrade pkg-config 0.29.2. Change-Id: I1a32c1c8c572785fbe402097704ff60ef2bdb6eb --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index c161573..fc7ce92 100644 --- a/configure.ac +++ b/configure.ac @@ -66,8 +66,8 @@ if test "x${have_dlog}" = "xyes"; then PKG_CHECK_MODULES(DLOG, dlog) TDM_CFLAGS="$TDM_CFLAGS $DLOG_CFLAGS " - TDM_CLIENT_CFLAGS+="$TDM_CLIENT_CFLAGS $DLOG_CFLAGS " - TDM_LIBS+="$TDM_LIBS $DLOG_LIBS " + TDM_CLIENT_CFLAGS="$TDM_CLIENT_CFLAGS $DLOG_CFLAGS " + TDM_LIBS="$TDM_LIBS $DLOG_LIBS " TDM_CLIENT_LIBS="$TDM_CLIENT_LIBS $DLOG_LIBS " fi -- 2.7.4 From 8b8aa20ee03a738f23fb99c02d5feb5e1b52791a Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 2 Mar 2022 10:34:49 +0900 Subject: [PATCH 02/16] Package version up to 3.1.1 Change-Id: Ibf1ed41f1eec0aa118a3710afecdfbf4745a0b22 --- packaging/libtdm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index 8df8174..ce44a4f 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -2,7 +2,7 @@ %define HALTESTS_GCOV 0 Name: libtdm -Version: 3.1.0 +Version: 3.1.1 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From 8f618c363d696421de3f881376fba7a29129f1a4 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Fri, 24 Jun 2022 20:15:44 +0900 Subject: [PATCH 03/16] tdm_test_client: Use tbm api for dump buffer for removing duplicate code Change-Id: I83e666c2e450c7bb884e1befee9620fd5f9c6cc1 --- tools/tdm_test_client.c | 168 ++---------------------------------------------- 1 file changed, 7 insertions(+), 161 deletions(-) diff --git a/tools/tdm_test_client.c b/tools/tdm_test_client.c index 14feed9..a3f9cb2 100644 --- a/tools/tdm_test_client.c +++ b/tools/tdm_test_client.c @@ -40,7 +40,6 @@ #include #include #include -#include #include "tdm_client.h" #include "tdm_macro.h" @@ -384,179 +383,26 @@ done: tdm_client_vblank_destroy(vblank); } -#define PNG_DEPTH 8 - -void -_tdm_client_get_buffer_full_size(tbm_surface_h buffer, int *buffer_w, int *buffer_h) -{ - tbm_surface_info_s info; - int ret; - - TDM_RETURN_IF_FAIL(buffer != NULL); - - ret = tbm_surface_get_info(buffer, &info); - TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE); - - if (buffer_w) { - if (IS_RGB(info.format)) - *buffer_w = info.planes[0].stride >> 2; - else - *buffer_w = info.planes[0].stride; - } - - if (buffer_h) - *buffer_h = info.planes[0].size / info.planes[0].stride; -} - static void -_tdm_client_dump_png(const char *file, const void *data, int width, - int height) -{ - FILE *fp; - - fp = fopen(file, "wb"); - TDM_RETURN_IF_FAIL(fp != NULL); - - png_structp pPngStruct = - png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!pPngStruct) { - fclose(fp); - return; - } - - png_infop pPngInfo = png_create_info_struct(pPngStruct); - if (!pPngInfo) { - png_destroy_write_struct(&pPngStruct, NULL); - fclose(fp); - return; - } - - png_init_io(pPngStruct, fp); - png_set_IHDR(pPngStruct, - pPngInfo, - width, - height, - PNG_DEPTH, - PNG_COLOR_TYPE_RGBA, - PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); - - png_set_bgr(pPngStruct); - png_write_info(pPngStruct, pPngInfo); - - const int pixel_size = 4; // RGBA - png_bytep *row_pointers = - png_malloc(pPngStruct, height * sizeof(png_byte *)); - if (!row_pointers) { - png_destroy_write_struct(&pPngStruct, &pPngInfo); - fclose(fp); - return; - } - - unsigned int *blocks = (unsigned int *)data; - int y = 0; - int x = 0; - - for (; y < height; ++y) { - png_bytep row = - png_malloc(pPngStruct, sizeof(png_byte) * width * pixel_size); - if (!row) { - for (x = 0; x < y; x++) - png_free(pPngStruct, row_pointers[x]); - png_free(pPngStruct, row_pointers); - png_destroy_write_struct(&pPngStruct, &pPngInfo); - fclose(fp); - return; - } - - row_pointers[y] = (png_bytep)row; - for (x = 0; x < width; ++x) { - unsigned int curBlock = blocks[y * width + x]; - row[x * pixel_size] = (curBlock & 0xFF); - row[1 + x * pixel_size] = (curBlock >> 8) & 0xFF; - row[2 + x * pixel_size] = (curBlock >> 16) & 0xFF; - row[3 + x * pixel_size] = (curBlock >> 24) & 0xFF; - } - } - - png_write_image(pPngStruct, row_pointers); - png_write_end(pPngStruct, pPngInfo); - - for (y = 0; y < height; y++) - png_free(pPngStruct, row_pointers[y]); - png_free(pPngStruct, row_pointers); - - png_destroy_write_struct(&pPngStruct, &pPngInfo); - - fclose(fp); -} - -void -_tdm_client_dump_buffer(tbm_surface_h buffer, const char *file) +_dump_buffer(tbm_surface_h buffer, int count) { char temp[TDM_PATH_LEN] = {0,}; - tbm_surface_info_s info; - int len, ret; - const char *ext; - int bo_cnt; - int bw, bh; - char *dot, *p = temp; - const char *file_exts[2] = {"png", "raw"}; - - TDM_RETURN_IF_FAIL(buffer != NULL); - TDM_RETURN_IF_FAIL(file != NULL); + tbm_format tformat; + const char *ext, *file_exts[2] = {"png", "yuv"}; - ret = tbm_surface_map(buffer, TBM_OPTION_READ, &info); - TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE); + tformat = tbm_surface_get_format(buffer); - if (IS_RGB(info.format)) + if (IS_RGB(tformat)) ext = file_exts[0]; else ext = file_exts[1]; - dot = strrchr(file, '.'); - if (!dot || strlen(dot + 1) != 3 || strncmp(dot + 1, ext, 3)) { - len = strnlen(file, TDM_PATH_LEN - 5); - strncat(p, file, len); - p += len; - *(p++) = '.'; - strncat(p, ext, 4); - p += 3; - *p = '\0'; - } else { - len = strnlen(file, TDM_PATH_LEN - 1); - strncat(p, file, len); - p += len; - *p = '\0'; - } - - _tdm_client_get_buffer_full_size(buffer, &bw, &bh); - - bo_cnt = tbm_surface_internal_get_num_bos(buffer); - TDM_DBG("buffer: bo_cnt(%d) %dx%d(%dx%d) %c%c%c%c, plane: (%p+%d, %d,%d) (%p+%d, %d,%d) (%p+%d, %d,%d)", - bo_cnt, bw, bh, info.width, info.height, FOURCC_STR(info.format), - info.planes[0].ptr, info.planes[0].offset, info.planes[0].stride, info.planes[0].size, - info.planes[1].ptr, info.planes[1].offset, info.planes[1].stride, info.planes[1].size, - info.planes[2].ptr, info.planes[2].offset, info.planes[2].stride, info.planes[2].size); - - _tdm_client_dump_png(temp, info.planes[0].ptr, bw, bh); - - tbm_surface_unmap(buffer); - - printf("dump %s\n", temp); -} - -static void -_dump_buffer(tbm_surface_h buffer, int count) -{ - char temp[TDM_PATH_LEN] = {0,}; - - snprintf(temp, TDM_PATH_LEN, "/tmp/%c%c%c%c_%dx%d_%d", + snprintf(temp, TDM_PATH_LEN, "%c%c%c%c_%dx%d_%d", FOURCC_STR(tbm_surface_get_format(buffer)), tbm_surface_get_width(buffer), tbm_surface_get_height(buffer), count); - _tdm_client_dump_buffer(buffer, temp); + tbm_surface_internal_capture_buffer(buffer, "/tmp", temp, ext); } static void -- 2.7.4 From fe8bcd39bc87391503371d027f1138f42c70f876 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Mon, 27 Jun 2022 12:55:30 +0900 Subject: [PATCH 04/16] tdm_client: Remove duplicate code Change-Id: I1b61378b6a458c7196e3869aeabba1a15e119467 --- client/tdm_client.c | 190 +++++++++++++++------------------------------------- 1 file changed, 54 insertions(+), 136 deletions(-) diff --git a/client/tdm_client.c b/client/tdm_client.c index f322a49..0cf3df4 100644 --- a/client/tdm_client.c +++ b/client/tdm_client.c @@ -184,6 +184,11 @@ typedef struct _tdm_client_voutput_commit_handler_info { struct list_head call_link; } tdm_client_voutput_commit_handler_info; +typedef enum { + VBLANK_WAIT_TYPE_INTERVAL, + VBLANK_WAIT_TYPE_SEQUENCE, +} tdm_client_vblank_wait_type; + static unsigned int _tdm_client_check_wl_error(tdm_private_client *private_client, const char *func, int line) { @@ -1492,8 +1497,9 @@ tdm_client_vblank_set_enable_fake(tdm_client_vblank *vblank, unsigned int enable return TDM_ERROR_NONE; } -tdm_error -tdm_client_vblank_wait(tdm_client_vblank *vblank, unsigned int interval, tdm_client_vblank_handler func, void *user_data) +static tdm_error +_tdm_client_vblank_wait(tdm_client_vblank *vblank, tdm_client_vblank_wait_type wait_type, unsigned int wait_value, + tdm_client_vblank_handler func, void *user_data) { tdm_private_client *private_client; tdm_private_client_output *private_output; @@ -1503,14 +1509,6 @@ tdm_client_vblank_wait(tdm_client_vblank *vblank, unsigned int interval, tdm_cli unsigned int req_sec, req_usec; int ret = 0; - TDM_RETURN_VAL_IF_FAIL(vblank != NULL, TDM_ERROR_INVALID_PARAMETER); - TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER); - /* can't support "interval 0" and "getting current_msc" things because - * there is a socket communication between TDM client and server. It's impossible - * to return the current msc or sequence immediately. - */ - TDM_RETURN_VAL_IF_FAIL(interval > 0, TDM_ERROR_INVALID_PARAMETER); - private_vblank = vblank; private_output = private_vblank->private_output; private_client = private_output->private_client; @@ -1564,13 +1562,16 @@ tdm_client_vblank_wait(tdm_client_vblank *vblank, unsigned int interval, tdm_cli w->req_time = TDM_TIME(req_sec, req_usec); w->need_free = (private_vblank->sync) ? 0 : 1; - wl_tdm_vblank_wait_vblank(private_vblank->vblank, interval, w->req_id, req_sec, req_usec); + if (wait_type == VBLANK_WAIT_TYPE_INTERVAL) + wl_tdm_vblank_wait_vblank(private_vblank->vblank, wait_value, w->req_id, req_sec, req_usec); + else + wl_tdm_vblank_wait_vblank_seq(private_vblank->vblank, wait_value, w->req_id, req_sec, req_usec); if (private_vblank->enable_ttrace) TDM_TRACE_ASYNC_BEGIN((int)w->req_time, "TDM_Client_Vblank:%u", private_vblank->stamp); - TDM_DBG("vblank(%p) interval(%u) req_id(%d) req(%.6f)", - vblank, interval, w->req_id, w->req_time); + TDM_DBG("vblank(%p) wait_type(%d) wait_value(%u) req_id(%d) req(%.6f)", + vblank, wait_type, wait_value, w->req_id, w->req_time); private_vblank->req_time = w->req_time; @@ -1609,115 +1610,28 @@ tdm_client_vblank_wait(tdm_client_vblank *vblank, unsigned int interval, tdm_cli } tdm_error -tdm_client_vblank_wait_seq(tdm_client_vblank *vblank, unsigned int sequence, - tdm_client_vblank_handler func, void *user_data) +tdm_client_vblank_wait(tdm_client_vblank *vblank, unsigned int interval, tdm_client_vblank_handler func, void *user_data) { - tdm_private_client *private_client; - tdm_private_client_output *private_output; - tdm_private_client_vblank *private_vblank; - tdm_client_wait_info *w; - struct timespec tp; - unsigned int req_sec, req_usec; - int ret = 0; - TDM_RETURN_VAL_IF_FAIL(vblank != NULL, TDM_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER); - private_vblank = vblank; - private_output = private_vblank->private_output; - private_client = private_output->private_client; - - pthread_mutex_lock(&private_client->lock); - - if (CHECK_WL_PROTOCOL_ERROR(private_client)) { - pthread_mutex_unlock(&private_client->lock); - return TDM_ERROR_PROTOCOL_ERROR; - } - - if (!private_vblank->started) - private_vblank->started = 1; - - if (!private_vblank->enable_fake) { - if (private_output->connection == TDM_OUTPUT_CONN_STATUS_DISCONNECTED) { - TDM_ERR("output disconnected"); - pthread_mutex_unlock(&private_client->lock); - return TDM_ERROR_OUTPUT_DISCONNECTED; - } - if (TDM_OUTPUT_DPMS_VSYNC_IS_OFF(private_output->dpms)) { - TDM_ERR("dpms %s", tdm_dpms_str(private_output->dpms)); - pthread_mutex_unlock(&private_client->lock); - return TDM_ERROR_DPMS_OFF; - } - } - - w = calloc(1, sizeof *w); - if (!w) { - /* LCOV_EXCL_START */ - - TDM_ERR("alloc failed"); - pthread_mutex_unlock(&private_client->lock); - return TDM_ERROR_OUT_OF_MEMORY; - - /* LCOV_EXCL_STOP */ - } - - w->private_vblank = private_vblank; - w->func = func; - w->user_data = user_data; - - LIST_ADDTAIL(&w->link, &private_vblank->wait_list); - LIST_INITHEAD(&w->call_link); - - clock_gettime(CLOCK_MONOTONIC, &tp); - req_sec = (unsigned int)tp.tv_sec; - req_usec = (unsigned int)(tp.tv_nsec / 1000); - - w->req_id = ++private_output->req_id; - w->req_time = TDM_TIME(req_sec, req_usec); - w->need_free = (private_vblank->sync) ? 0 : 1; - - wl_tdm_vblank_wait_vblank_seq(private_vblank->vblank, sequence, w->req_id, req_sec, req_usec); - - if (private_vblank->enable_ttrace) - TDM_TRACE_ASYNC_BEGIN((int)w->req_time, "TDM_Client_Vblank:%u", private_vblank->stamp); - - TDM_DBG("vblank(%p) sequence(%u) req_id(%d) req(%.6f)", - vblank, sequence, w->req_id, w->req_time); - - private_vblank->req_time = w->req_time; - - if (private_vblank->last_time >= w->req_time) - TDM_ERR("'last(%.6f) < req(%.6f)' failed", private_vblank->last_time, w->req_time); - - if (!private_vblank->sync) { - wl_display_flush(private_client->display); - pthread_mutex_unlock(&private_client->lock); - return TDM_ERROR_NONE; - } - - /* LCOV_EXCL_START */ - - while (ret != -1 && !w->need_free) - ret = wl_display_dispatch(private_client->display); - - clock_gettime(CLOCK_MONOTONIC, &tp); - TDM_DBG("block during %d us", - ((unsigned int)(tp.tv_sec * 1000000) + (unsigned int)(tp.tv_nsec / 1000)) - - (req_sec * 1000000 + req_usec)); - - LIST_DEL(&w->link); - free(w); - - if (CHECK_WL_PROTOCOL_ERROR(private_client)) { - pthread_mutex_unlock(&private_client->lock); - return TDM_ERROR_PROTOCOL_ERROR; - } + /* can't support "interval 0" and "getting current_msc" things because + * there is a socket communication between TDM client and server. It's impossible + * to return the current msc or sequence immediately. + */ + TDM_RETURN_VAL_IF_FAIL(interval > 0, TDM_ERROR_INVALID_PARAMETER); - pthread_mutex_unlock(&private_client->lock); + return _tdm_client_vblank_wait(vblank, VBLANK_WAIT_TYPE_INTERVAL, interval, func, user_data); +} - return TDM_ERROR_NONE; +tdm_error +tdm_client_vblank_wait_seq(tdm_client_vblank *vblank, unsigned int sequence, + tdm_client_vblank_handler func, void *user_data) +{ + TDM_RETURN_VAL_IF_FAIL(vblank != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER); - /* LCOV_EXCL_STOP */ + return _tdm_client_vblank_wait(vblank, VBLANK_WAIT_TYPE_SEQUENCE, sequence, func, user_data); } unsigned int @@ -1808,6 +1722,27 @@ _tdm_client_voutput_create_surface_from_param(tbm_bufmgr bufmgr, return tbm_surface; } + +static tdm_private_client_buffer * +_tdm_client_voutput_create_buffer(tdm_private_client_voutput *private_voutput, + tbm_surface_h tbm_surface, + struct wl_buffer *wl_buffer) +{ + tdm_private_client_buffer *buffer = NULL; + + buffer = calloc(1, sizeof *buffer); + TDM_RETURN_VAL_IF_FAIL(buffer != NULL, NULL); + + tbm_surface_internal_ref(tbm_surface); + wl_buffer_set_user_data(wl_buffer, tbm_surface); + + buffer->wl_buffer = wl_buffer; + + LIST_ADDTAIL(&buffer->link, &private_voutput->buffer_list); + + return buffer; +} + static void tdm_client_voutput_cb_buffer_import_with_id(void *data, struct wl_tdm_voutput *wl_voutput, @@ -1834,9 +1769,6 @@ tdm_client_voutput_cb_buffer_import_with_id(void *data, TDM_RETURN_IF_FAIL(private_voutput != NULL); - buffer = calloc(1, sizeof *buffer); - TDM_RETURN_IF_FAIL(buffer != NULL); - tbm_surface = _tdm_client_voutput_create_surface_from_param(private_voutput->bufmgr, 0, width, height, format, bpp, size, num_plane, @@ -1846,19 +1778,12 @@ tdm_client_voutput_cb_buffer_import_with_id(void *data, buf0, buf1, buf2); TDM_GOTO_IF_FAIL(tbm_surface != NULL, fail); - tbm_surface_internal_ref(tbm_surface); - wl_buffer_set_user_data(wl_buffer, tbm_surface); - - buffer->wl_buffer = wl_buffer; - - LIST_ADDTAIL(&buffer->link, &private_voutput->buffer_list); + buffer = _tdm_client_voutput_create_buffer(private_voutput, tbm_surface, wl_buffer); + TDM_GOTO_IF_FAIL(buffer != NULL, fail); return; fail: - if (buffer) - free(buffer); - if (wl_buffer) wl_buffer_destroy(wl_buffer); } @@ -1901,19 +1826,12 @@ tdm_client_voutput_cb_buffer_import_with_fd(void *data, buf0, buf1, buf2); TDM_GOTO_IF_FAIL(tbm_surface != NULL, fail); - tbm_surface_internal_ref(tbm_surface); - wl_buffer_set_user_data(wl_buffer, tbm_surface); - - buffer->wl_buffer = wl_buffer; - - LIST_ADDTAIL(&buffer->link, &private_voutput->buffer_list); + buffer = _tdm_client_voutput_create_buffer(private_voutput, tbm_surface, wl_buffer); + TDM_GOTO_IF_FAIL(buffer != NULL, fail); return; fail: - if (buffer) - free(buffer); - if (wl_buffer) wl_buffer_destroy(wl_buffer); } -- 2.7.4 From 4a66c386d577cc08f4b5342b90c3806cfa494653 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Thu, 30 Jun 2022 19:22:43 +0900 Subject: [PATCH 05/16] tools/buffers: Remove duplicate code Change-Id: Id64cc0f159cb57d01f515b2708094612e7f6997e --- tools/buffers.c | 263 ++++++++++++++++++++++++-------------------------------- 1 file changed, 111 insertions(+), 152 deletions(-) diff --git a/tools/buffers.c b/tools/buffers.c index ea88179..91dcab7 100644 --- a/tools/buffers.c +++ b/tools/buffers.c @@ -195,40 +195,41 @@ struct color_yuv { #define MAKE_RGB24(rgb, r, g, b) \ { .value = MAKE_RGBA(rgb, r, g, b, 0) } +const struct color_yuv colors_yuv_top[] = { + MAKE_YUV_601(191, 192, 192), /* grey */ + MAKE_YUV_601(192, 192, 0), /* yellow */ + MAKE_YUV_601(0, 192, 192), /* cyan */ + MAKE_YUV_601(0, 192, 0), /* green */ + MAKE_YUV_601(192, 0, 192), /* magenta */ + MAKE_YUV_601(192, 0, 0), /* red */ + MAKE_YUV_601(0, 0, 192), /* blue */ +}; +const struct color_yuv colors_yuv_middle[] = { + MAKE_YUV_601(0, 0, 192), /* blue */ + MAKE_YUV_601(19, 19, 19), /* black */ + MAKE_YUV_601(192, 0, 192), /* magenta */ + MAKE_YUV_601(19, 19, 19), /* black */ + MAKE_YUV_601(0, 192, 192), /* cyan */ + MAKE_YUV_601(19, 19, 19), /* black */ + MAKE_YUV_601(192, 192, 192), /* grey */ +}; +const struct color_yuv colors_yuv_bottom[] = { + MAKE_YUV_601(0, 33, 76), /* in-phase */ + MAKE_YUV_601(255, 255, 255), /* super white */ + MAKE_YUV_601(50, 0, 106), /* quadrature */ + MAKE_YUV_601(19, 19, 19), /* black */ + MAKE_YUV_601(9, 9, 9), /* 3.5% */ + MAKE_YUV_601(19, 19, 19), /* 7.5% */ + MAKE_YUV_601(29, 29, 29), /* 11.5% */ + MAKE_YUV_601(19, 19, 19), /* black */ +}; + static void fill_smpte_yuv_planar(const struct yuv_info *yuv, unsigned char *y_mem, unsigned char *u_mem, unsigned char *v_mem, unsigned int width, unsigned int height, unsigned int stride) { - const struct color_yuv colors_top[] = { - MAKE_YUV_601(191, 192, 192), /* grey */ - MAKE_YUV_601(192, 192, 0), /* yellow */ - MAKE_YUV_601(0, 192, 192), /* cyan */ - MAKE_YUV_601(0, 192, 0), /* green */ - MAKE_YUV_601(192, 0, 192), /* magenta */ - MAKE_YUV_601(192, 0, 0), /* red */ - MAKE_YUV_601(0, 0, 192), /* blue */ - }; - const struct color_yuv colors_middle[] = { - MAKE_YUV_601(0, 0, 192), /* blue */ - MAKE_YUV_601(19, 19, 19), /* black */ - MAKE_YUV_601(192, 0, 192), /* magenta */ - MAKE_YUV_601(19, 19, 19), /* black */ - MAKE_YUV_601(0, 192, 192), /* cyan */ - MAKE_YUV_601(19, 19, 19), /* black */ - MAKE_YUV_601(192, 192, 192), /* grey */ - }; - const struct color_yuv colors_bottom[] = { - MAKE_YUV_601(0, 33, 76), /* in-phase */ - MAKE_YUV_601(255, 255, 255), /* super white */ - MAKE_YUV_601(50, 0, 106), /* quadrature */ - MAKE_YUV_601(19, 19, 19), /* black */ - MAKE_YUV_601(9, 9, 9), /* 3.5% */ - MAKE_YUV_601(19, 19, 19), /* 7.5% */ - MAKE_YUV_601(29, 29, 29), /* 11.5% */ - MAKE_YUV_601(19, 19, 19), /* black */ - }; unsigned int cs = yuv->chroma_stride; unsigned int xsub = yuv->xsub; unsigned int ysub = yuv->ysub; @@ -238,27 +239,27 @@ fill_smpte_yuv_planar(const struct yuv_info *yuv, /* Luma */ for (y = 0; y < height * 6 / 9; ++y) { for (x = 0; x < width; ++x) - y_mem[x] = colors_top[x * 7 / width].y; + y_mem[x] = colors_yuv_top[x * 7 / width].y; y_mem += stride; } for (; y < height * 7 / 9; ++y) { for (x = 0; x < width; ++x) - y_mem[x] = colors_middle[x * 7 / width].y; + y_mem[x] = colors_yuv_middle[x * 7 / width].y; y_mem += stride; } for (; y < height; ++y) { for (x = 0; x < width * 5 / 7; ++x) - y_mem[x] = colors_bottom[x * 4 / (width * 5 / 7)].y; + y_mem[x] = colors_yuv_bottom[x * 4 / (width * 5 / 7)].y; for (; x < width * 6 / 7; ++x) - y_mem[x] = colors_bottom[(x - width * 5 / 7) * 3 + y_mem[x] = colors_yuv_bottom[(x - width * 5 / 7) * 3 / (width / 7) + 4].y; for (; x < width; ++x) { if (rand_r(&rand_seed) % 2) - y_mem[x] = colors_bottom[1].y; + y_mem[x] = colors_yuv_bottom[1].y; else - y_mem[x] = colors_bottom[7].y; + y_mem[x] = colors_yuv_bottom[7].y; } y_mem += stride; } @@ -266,8 +267,8 @@ fill_smpte_yuv_planar(const struct yuv_info *yuv, /* Chroma */ for (y = 0; y < height / ysub * 6 / 9; ++y) { for (x = 0; x < width; x += xsub) { - u_mem[x * cs / xsub] = colors_top[x * 7 / width].u; - v_mem[x * cs / xsub] = colors_top[x * 7 / width].v; + u_mem[x * cs / xsub] = colors_yuv_top[x * 7 / width].u; + v_mem[x * cs / xsub] = colors_yuv_top[x * 7 / width].v; } u_mem += stride * cs / xsub; v_mem += stride * cs / xsub; @@ -275,8 +276,8 @@ fill_smpte_yuv_planar(const struct yuv_info *yuv, for (; y < height / ysub * 7 / 9; ++y) { for (x = 0; x < width; x += xsub) { - u_mem[x * cs / xsub] = colors_middle[x * 7 / width].u; - v_mem[x * cs / xsub] = colors_middle[x * 7 / width].v; + u_mem[x * cs / xsub] = colors_yuv_middle[x * 7 / width].u; + v_mem[x * cs / xsub] = colors_yuv_middle[x * 7 / width].v; } u_mem += stride * cs / xsub; v_mem += stride * cs / xsub; @@ -285,23 +286,23 @@ fill_smpte_yuv_planar(const struct yuv_info *yuv, for (; y < height / ysub; ++y) { for (x = 0; x < width * 5 / 7; x += xsub) { u_mem[x * cs / xsub] = - colors_bottom[x * 4 / (width * 5 / 7)].u; + colors_yuv_bottom[x * 4 / (width * 5 / 7)].u; v_mem[x * cs / xsub] = - colors_bottom[x * 4 / (width * 5 / 7)].v; + colors_yuv_bottom[x * 4 / (width * 5 / 7)].v; } for (; x < width * 6 / 7; x += xsub) { - u_mem[x * cs / xsub] = colors_bottom[(x - width * 5 / 7) * + u_mem[x * cs / xsub] = colors_yuv_bottom[(x - width * 5 / 7) * 3 / (width / 7) + 4].u; - v_mem[x * cs / xsub] = colors_bottom[(x - width * 5 / 7) * + v_mem[x * cs / xsub] = colors_yuv_bottom[(x - width * 5 / 7) * 3 / (width / 7) + 4].v; } for (; x < width; x += xsub) { if (rand_r(&rand_seed) % 2) { - u_mem[x * cs / xsub] = colors_bottom[1].u; - v_mem[x * cs / xsub] = colors_bottom[1].v; + u_mem[x * cs / xsub] = colors_yuv_bottom[1].u; + v_mem[x * cs / xsub] = colors_yuv_bottom[1].v; } else { - u_mem[x * cs / xsub] = colors_bottom[7].u; - v_mem[x * cs / xsub] = colors_bottom[7].v; + u_mem[x * cs / xsub] = colors_yuv_bottom[7].u; + v_mem[x * cs / xsub] = colors_yuv_bottom[7].v; } } u_mem += stride * cs / xsub; @@ -314,34 +315,6 @@ fill_smpte_yuv_packed(const struct yuv_info *yuv, unsigned char *mem, unsigned int width, unsigned int height, unsigned int stride) { - const struct color_yuv colors_top[] = { - MAKE_YUV_601(191, 192, 192), /* grey */ - MAKE_YUV_601(192, 192, 0), /* yellow */ - MAKE_YUV_601(0, 192, 192), /* cyan */ - MAKE_YUV_601(0, 192, 0), /* green */ - MAKE_YUV_601(192, 0, 192), /* magenta */ - MAKE_YUV_601(192, 0, 0), /* red */ - MAKE_YUV_601(0, 0, 192), /* blue */ - }; - const struct color_yuv colors_middle[] = { - MAKE_YUV_601(0, 0, 192), /* blue */ - MAKE_YUV_601(19, 19, 19), /* black */ - MAKE_YUV_601(192, 0, 192), /* magenta */ - MAKE_YUV_601(19, 19, 19), /* black */ - MAKE_YUV_601(0, 192, 192), /* cyan */ - MAKE_YUV_601(19, 19, 19), /* black */ - MAKE_YUV_601(192, 192, 192), /* grey */ - }; - const struct color_yuv colors_bottom[] = { - MAKE_YUV_601(0, 33, 76), /* in-phase */ - MAKE_YUV_601(255, 255, 255), /* super white */ - MAKE_YUV_601(50, 0, 106), /* quadrature */ - MAKE_YUV_601(19, 19, 19), /* black */ - MAKE_YUV_601(9, 9, 9), /* 3.5% */ - MAKE_YUV_601(19, 19, 19), /* 7.5% */ - MAKE_YUV_601(29, 29, 29), /* 11.5% */ - MAKE_YUV_601(19, 19, 19), /* black */ - }; unsigned char *y_mem = (yuv->order & YUV_YC) ? mem : mem + 1; unsigned char *c_mem = (yuv->order & YUV_CY) ? mem : mem + 1; unsigned int u = (yuv->order & YUV_YCrCb) ? 2 : 0; @@ -355,58 +328,58 @@ fill_smpte_yuv_packed(const struct yuv_info *yuv, unsigned char *mem, /* Luma */ for (y = 0; y < height * 6 / 9; ++y) { for (x = 0; x < width; ++x) - y_mem[2 * x] = colors_top[x * 7 / width].y; + y_mem[2 * x] = colors_yuv_top[x * 7 / width].y; y_mem += stride; } for (; y < height * 7 / 9; ++y) { for (x = 0; x < width; ++x) - y_mem[2 * x] = colors_middle[x * 7 / width].y; + y_mem[2 * x] = colors_yuv_middle[x * 7 / width].y; y_mem += stride; } for (; y < height; ++y) { for (x = 0; x < width * 5 / 7; ++x) - y_mem[2 * x] = colors_bottom[x * 4 / (width * 5 / 7)].y; + y_mem[2 * x] = colors_yuv_bottom[x * 4 / (width * 5 / 7)].y; for (; x < width * 6 / 7; ++x) - y_mem[2 * x] = colors_bottom[(x - width * 5 / 7) * 3 + y_mem[2 * x] = colors_yuv_bottom[(x - width * 5 / 7) * 3 / (width / 7) + 4].y; for (; x < width; ++x) - y_mem[2 * x] = colors_bottom[7].y; + y_mem[2 * x] = colors_yuv_bottom[7].y; y_mem += stride; } /* Chroma */ for (y = 0; y < height * 6 / 9; ++y) { for (x = 0; x < width; x += 2) { - c_mem[2 * x + u] = colors_top[x * 7 / width].u; - c_mem[2 * x + v] = colors_top[x * 7 / width].v; + c_mem[2 * x + u] = colors_yuv_top[x * 7 / width].u; + c_mem[2 * x + v] = colors_yuv_top[x * 7 / width].v; } c_mem += stride; } for (; y < height * 7 / 9; ++y) { for (x = 0; x < width; x += 2) { - c_mem[2 * x + u] = colors_middle[x * 7 / width].u; - c_mem[2 * x + v] = colors_middle[x * 7 / width].v; + c_mem[2 * x + u] = colors_yuv_middle[x * 7 / width].u; + c_mem[2 * x + v] = colors_yuv_middle[x * 7 / width].v; } c_mem += stride; } for (; y < height; ++y) { for (x = 0; x < width * 5 / 7; x += 2) { - c_mem[2 * x + u] = colors_bottom[x * 4 / (width * 5 / 7)].u; - c_mem[2 * x + v] = colors_bottom[x * 4 / (width * 5 / 7)].v; + c_mem[2 * x + u] = colors_yuv_bottom[x * 4 / (width * 5 / 7)].u; + c_mem[2 * x + v] = colors_yuv_bottom[x * 4 / (width * 5 / 7)].v; } for (; x < width * 6 / 7; x += 2) { - c_mem[2 * x + u] = colors_bottom[(x - width * 5 / 7) * + c_mem[2 * x + u] = colors_yuv_bottom[(x - width * 5 / 7) * 3 / (width / 7) + 4].u; - c_mem[2 * x + v] = colors_bottom[(x - width * 5 / 7) * + c_mem[2 * x + v] = colors_yuv_bottom[(x - width * 5 / 7) * 3 / (width / 7) + 4].v; } for (; x < width; x += 2) { - c_mem[2 * x + u] = colors_bottom[7].u; - c_mem[2 * x + v] = colors_bottom[7].v; + c_mem[2 * x + u] = colors_yuv_bottom[7].u; + c_mem[2 * x + v] = colors_yuv_bottom[7].v; } c_mem += stride; } @@ -416,7 +389,7 @@ static void fill_smpte_rgb16(const struct rgb_info *rgb, unsigned char *mem, unsigned int width, unsigned int height, unsigned int stride) { - const uint16_t colors_top[] = { + const uint16_t colors_rgb16_top[] = { MAKE_RGBA(rgb, 192, 192, 192, ALPHA_VALUE), /* grey */ MAKE_RGBA(rgb, 192, 192, 0, ALPHA_VALUE), /* yellow */ MAKE_RGBA(rgb, 0, 192, 192, ALPHA_VALUE), /* cyan */ @@ -425,7 +398,7 @@ fill_smpte_rgb16(const struct rgb_info *rgb, unsigned char *mem, MAKE_RGBA(rgb, 192, 0, 0, ALPHA_VALUE), /* red */ MAKE_RGBA(rgb, 0, 0, 192, ALPHA_VALUE), /* blue */ }; - const uint16_t colors_middle[] = { + const uint16_t colors_rgb16_middle[] = { MAKE_RGBA(rgb, 0, 0, 192, ALPHA_VALUE), /* blue */ MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE), /* black */ MAKE_RGBA(rgb, 192, 0, 192, ALPHA_VALUE), /* magenta */ @@ -434,7 +407,7 @@ fill_smpte_rgb16(const struct rgb_info *rgb, unsigned char *mem, MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE), /* black */ MAKE_RGBA(rgb, 192, 192, 192, ALPHA_VALUE), /* grey */ }; - const uint16_t colors_bottom[] = { + const uint16_t colors_rgb16_bottom[] = { MAKE_RGBA(rgb, 0, 33, 76, ALPHA_VALUE), /* in-phase */ MAKE_RGBA(rgb, 255, 255, 255, ALPHA_VALUE), /* super white */ MAKE_RGBA(rgb, 50, 0, 106, ALPHA_VALUE), /* quadrature */ @@ -444,6 +417,7 @@ fill_smpte_rgb16(const struct rgb_info *rgb, unsigned char *mem, MAKE_RGBA(rgb, 29, 29, 29, ALPHA_VALUE), /* 11.5% */ MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE), /* black */ }; + unsigned int x; unsigned int y; @@ -452,26 +426,26 @@ fill_smpte_rgb16(const struct rgb_info *rgb, unsigned char *mem, for (y = 0; y < height * 6 / 9; ++y) { for (x = 0; x < width; ++x) - ((uint16_t *)mem)[x] = colors_top[x * 7 / width]; + ((uint16_t *)mem)[x] = colors_rgb16_top[x * 7 / width]; mem += stride; } for (; y < height * 7 / 9; ++y) { for (x = 0; x < width; ++x) - ((uint16_t *)mem)[x] = colors_middle[x * 7 / width]; + ((uint16_t *)mem)[x] = colors_rgb16_middle[x * 7 / width]; mem += stride; } for (; y < height; ++y) { for (x = 0; x < width * 5 / 7; ++x) ((uint16_t *)mem)[x] = - colors_bottom[x * 4 / (width * 5 / 7)]; + colors_rgb16_bottom[x * 4 / (width * 5 / 7)]; for (; x < width * 6 / 7; ++x) ((uint16_t *)mem)[x] = - colors_bottom[(x - width * 5 / 7) * 3 + colors_rgb16_bottom[(x - width * 5 / 7) * 3 / (width / 7) + 4]; for (; x < width; ++x) - ((uint16_t *)mem)[x] = colors_bottom[7]; + ((uint16_t *)mem)[x] = colors_rgb16_bottom[7]; mem += stride; } } @@ -480,7 +454,7 @@ static void fill_smpte_rgb24(const struct rgb_info *rgb, void *mem, unsigned int width, unsigned int height, unsigned int stride) { - const struct color_rgb24 colors_top[] = { + const struct color_rgb24 colors_rgb24_top[] = { MAKE_RGB24(rgb, 192, 192, 192), /* grey */ MAKE_RGB24(rgb, 192, 192, 0), /* yellow */ MAKE_RGB24(rgb, 0, 192, 192), /* cyan */ @@ -489,7 +463,7 @@ fill_smpte_rgb24(const struct rgb_info *rgb, void *mem, MAKE_RGB24(rgb, 192, 0, 0), /* red */ MAKE_RGB24(rgb, 0, 0, 192), /* blue */ }; - const struct color_rgb24 colors_middle[] = { + const struct color_rgb24 colors_rgb24_middle[] = { MAKE_RGB24(rgb, 0, 0, 192), /* blue */ MAKE_RGB24(rgb, 19, 19, 19), /* black */ MAKE_RGB24(rgb, 192, 0, 192), /* magenta */ @@ -498,7 +472,7 @@ fill_smpte_rgb24(const struct rgb_info *rgb, void *mem, MAKE_RGB24(rgb, 19, 19, 19), /* black */ MAKE_RGB24(rgb, 192, 192, 192), /* grey */ }; - const struct color_rgb24 colors_bottom[] = { + const struct color_rgb24 colors_rgb24_bottom[] = { MAKE_RGB24(rgb, 0, 33, 76), /* in-phase */ MAKE_RGB24(rgb, 255, 255, 255), /* super white */ MAKE_RGB24(rgb, 50, 0, 106), /* quadrature */ @@ -508,6 +482,7 @@ fill_smpte_rgb24(const struct rgb_info *rgb, void *mem, MAKE_RGB24(rgb, 29, 29, 29), /* 11.5% */ MAKE_RGB24(rgb, 19, 19, 19), /* black */ }; + unsigned int x; unsigned int y; @@ -517,36 +492,36 @@ fill_smpte_rgb24(const struct rgb_info *rgb, void *mem, for (y = 0; y < height * 6 / 9; ++y) { for (x = 0; x < width; ++x) ((struct color_rgb24 *)mem)[x] = - colors_top[x * 7 / width]; + colors_rgb24_top[x * 7 / width]; mem += stride; } for (; y < height * 7 / 9; ++y) { for (x = 0; x < width; ++x) ((struct color_rgb24 *)mem)[x] = - colors_middle[x * 7 / width]; + colors_rgb24_middle[x * 7 / width]; mem += stride; } for (; y < height; ++y) { for (x = 0; x < width * 5 / 7; ++x) ((struct color_rgb24 *)mem)[x] = - colors_bottom[x * 4 / (width * 5 / 7)]; + colors_rgb24_bottom[x * 4 / (width * 5 / 7)]; for (; x < width * 6 / 7; ++x) ((struct color_rgb24 *)mem)[x] = - colors_bottom[(x - width * 5 / 7) * 3 + colors_rgb24_bottom[(x - width * 5 / 7) * 3 / (width / 7) + 4]; for (; x < width; ++x) - ((struct color_rgb24 *)mem)[x] = colors_bottom[7]; + ((struct color_rgb24 *)mem)[x] = colors_rgb24_bottom[7]; mem += stride; } } static void fill_smpte_rgb32(const struct rgb_info *rgb, unsigned char *mem, - unsigned int width, unsigned int height, unsigned int stride) + unsigned int width, unsigned int height, unsigned int stride, bool alpha) { - const uint32_t colors_top[] = { + const uint32_t colors_rgba32_top[] = { MAKE_RGBA(rgb, 192, 192, 192, ALPHA_VALUE), /* grey */ MAKE_RGBA(rgb, 192, 192, 0, ALPHA_VALUE), /* yellow */ MAKE_RGBA(rgb, 0, 192, 192, ALPHA_VALUE), /* cyan */ @@ -555,7 +530,7 @@ fill_smpte_rgb32(const struct rgb_info *rgb, unsigned char *mem, MAKE_RGBA(rgb, 192, 0, 0, ALPHA_VALUE), /* red */ MAKE_RGBA(rgb, 0, 0, 192, ALPHA_VALUE), /* blue */ }; - const uint32_t colors_middle[] = { + const uint32_t colors_rgba32_middle[] = { MAKE_RGBA(rgb, 0, 0, 192, ALPHA_VALUE), /* blue */ MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE), /* black */ MAKE_RGBA(rgb, 192, 0, 192, ALPHA_VALUE), /* magenta */ @@ -564,7 +539,7 @@ fill_smpte_rgb32(const struct rgb_info *rgb, unsigned char *mem, MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE), /* black */ MAKE_RGBA(rgb, 192, 192, 192, ALPHA_VALUE), /* grey */ }; - const uint32_t colors_bottom[] = { + const uint32_t colors_rgba32_bottom[] = { MAKE_RGBA(rgb, 0, 33, 76, ALPHA_VALUE), /* in-phase */ MAKE_RGBA(rgb, 255, 255, 255, ALPHA_VALUE), /* super white */ MAKE_RGBA(rgb, 50, 0, 106, ALPHA_VALUE), /* quadrature */ @@ -574,43 +549,8 @@ fill_smpte_rgb32(const struct rgb_info *rgb, unsigned char *mem, MAKE_RGBA(rgb, 29, 29, 29, ALPHA_VALUE), /* 11.5% */ MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE), /* black */ }; - unsigned int x; - unsigned int y; - if (width < 8) - return; - - for (y = 0; y < height * 6 / 9; ++y) { - for (x = 0; x < width; ++x) - ((uint32_t *)mem)[x] = colors_top[x * 7 / width]; - mem += stride; - } - - for (; y < height * 7 / 9; ++y) { - for (x = 0; x < width; ++x) - ((uint32_t *)mem)[x] = colors_middle[x * 7 / width]; - mem += stride; - } - - for (; y < height; ++y) { - for (x = 0; x < width * 5 / 7; ++x) - ((uint32_t *)mem)[x] = - colors_bottom[x * 4 / (width * 5 / 7)]; - for (; x < width * 6 / 7; ++x) - ((uint32_t *)mem)[x] = - colors_bottom[(x - width * 5 / 7) * 3 - / (width / 7) + 4]; - for (; x < width; ++x) - ((uint32_t *)mem)[x] = (rand_r(&rand_seed) % 2) ? MAKE_RGBA(rgb, 255, 255, 255, ALPHA_VALUE) : MAKE_RGBA(rgb, 0, 0, 0, ALPHA_VALUE); - mem += stride; - } -} - -static void -fill_smpte_rgb32_dont_care_alpha(const struct rgb_info *rgb, unsigned char *mem, - unsigned int width, unsigned int height, unsigned int stride) -{ - const uint32_t colors_top[] = { + const uint32_t colors_rgbx32_top[] = { MAKE_RGBX(rgb, 192, 192, 192), /* grey */ MAKE_RGBX(rgb, 192, 192, 0), /* yellow */ MAKE_RGBX(rgb, 0, 192, 192), /* cyan */ @@ -619,7 +559,7 @@ fill_smpte_rgb32_dont_care_alpha(const struct rgb_info *rgb, unsigned char *mem, MAKE_RGBX(rgb, 192, 0, 0), /* red */ MAKE_RGBX(rgb, 0, 0, 192), /* blue */ }; - const uint32_t colors_middle[] = { + const uint32_t colors_rgbx32_middle[] = { MAKE_RGBX(rgb, 0, 0, 192), /* blue */ MAKE_RGBX(rgb, 19, 19, 19), /* black */ MAKE_RGBX(rgb, 192, 0, 192), /* magenta */ @@ -628,7 +568,7 @@ fill_smpte_rgb32_dont_care_alpha(const struct rgb_info *rgb, unsigned char *mem, MAKE_RGBX(rgb, 19, 19, 19), /* black */ MAKE_RGBX(rgb, 192, 192, 192), /* grey */ }; - const uint32_t colors_bottom[] = { + const uint32_t colors_rgbx32_bottom[] = { MAKE_RGBX(rgb, 0, 33, 76), /* in-phase */ MAKE_RGBX(rgb, 255, 255, 255), /* super white */ MAKE_RGBX(rgb, 50, 0, 106), /* quadrature */ @@ -638,9 +578,24 @@ fill_smpte_rgb32_dont_care_alpha(const struct rgb_info *rgb, unsigned char *mem, MAKE_RGBX(rgb, 29, 29, 29), /* 11.5% */ MAKE_RGBX(rgb, 19, 19, 19), /* black */ }; + + const uint32_t *colors_top; + const uint32_t *colors_middle; + const uint32_t *colors_bottom; + unsigned int x; unsigned int y; + if (alpha) { + colors_top = colors_rgba32_top; + colors_middle = colors_rgba32_middle; + colors_bottom = colors_rgba32_bottom; + } else { + colors_top = colors_rgbx32_top; + colors_middle = colors_rgbx32_middle; + colors_bottom = colors_rgbx32_bottom; + } + if (width < 8) return; @@ -664,8 +619,12 @@ fill_smpte_rgb32_dont_care_alpha(const struct rgb_info *rgb, unsigned char *mem, ((uint32_t *)mem)[x] = colors_bottom[(x - width * 5 / 7) * 3 / (width / 7) + 4]; - for (; x < width; ++x) - ((uint32_t *)mem)[x] = (rand_r(&rand_seed) % 2) ? MAKE_RGBX(rgb, 255, 255, 255) : MAKE_RGBX(rgb, 0, 0, 0); + for (; x < width; ++x) { + if (alpha) + ((uint32_t *)mem)[x] = (rand_r(&rand_seed) % 2) ? MAKE_RGBA(rgb, 255, 255, 255, ALPHA_VALUE) : MAKE_RGBA(rgb, 0, 0, 0, ALPHA_VALUE); + else + ((uint32_t *)mem)[x] = (rand_r(&rand_seed) % 2) ? MAKE_RGBX(rgb, 255, 255, 255) : MAKE_RGBX(rgb, 0, 0, 0); + } mem += stride; } } @@ -742,10 +701,10 @@ fill_smpte(const struct format_info *info, void *planes[3], unsigned int width, case TBM_FORMAT_BGRA1010102: case TBM_FORMAT_BGRX1010102: return fill_smpte_rgb32(&info->rgb, planes[0], - width, height, stride); + width, height, stride, true); case TBM_FORMAT_XRGB8888: - return fill_smpte_rgb32_dont_care_alpha(&info->rgb, planes[0], - width, height, stride); + return fill_smpte_rgb32(&info->rgb, planes[0], + width, height, stride, false); } } -- 2.7.4 From d4f5e2fb17ceb2217db8e18b92119bb4498d25ee Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Fri, 1 Jul 2022 17:36:19 +0900 Subject: [PATCH 06/16] haltest/hwc: Remove duplicate code Change-Id: I277f74abb85ecc4eb29e1259a4fde7f67a19d90f --- haltests/src/tc_tdm_hwc.cpp | 98 ++++++++++++++++++--------------------------- 1 file changed, 40 insertions(+), 58 deletions(-) diff --git a/haltests/src/tc_tdm_hwc.cpp b/haltests/src/tc_tdm_hwc.cpp index c8b3210..7917b69 100644 --- a/haltests/src/tc_tdm_hwc.cpp +++ b/haltests/src/tc_tdm_hwc.cpp @@ -504,6 +504,44 @@ TEST_P(TDMHwc, AcceptChangesFailNoHwc) } } +static bool +_tc_tdm_hwc_prepare_commit(tdm_hwc *hwc, tdm_hwc_window **hwc_wnds) +{ + tdm_error error = TDM_ERROR_NONE; + tdm_hwc_window **changed_hwc_window = NULL; + tdm_hwc_window_composition *composition_types = NULL; + uint32_t num_types; + uint32_t get_num = 0; + + for (int w = 0; w < HWC_WIN_NUM; w++) { + hwc_wnds[w] = tdm_hwc_create_window(hwc, &error); + TDM_UT_RETURN_FALSE_IF_FAIL(error == TDM_ERROR_NONE); + error = tdm_hwc_window_set_composition_type(hwc_wnds[w], TDM_HWC_WIN_COMPOSITION_DEVICE); + TDM_UT_RETURN_FALSE_IF_FAIL(error == TDM_ERROR_NONE); + } + + error = tdm_hwc_validate(hwc, hwc_wnds, HWC_WIN_NUM, &num_types); + TDM_UT_RETURN_FALSE_IF_FAIL(error == TDM_ERROR_NONE); + + if (num_types > 0) { + changed_hwc_window = (tdm_hwc_window **)calloc(num_types, sizeof(tdm_hwc_window *)); + composition_types = (tdm_hwc_window_composition *)calloc(num_types, sizeof(tdm_hwc_window_composition)); + + get_num = num_types; + error = tdm_hwc_get_changed_composition_types(hwc, &get_num, changed_hwc_window, composition_types); + TDM_UT_RETURN_FALSE_IF_FAIL(error == TDM_ERROR_NONE); + TDM_UT_RETURN_FALSE_IF_FAIL(get_num == num_types); + + error = tdm_hwc_accept_validation(hwc); + TDM_UT_RETURN_FALSE_IF_FAIL(error == TDM_ERROR_NONE); + + free(composition_types); + free(changed_hwc_window); + } + + return true; +} + TEST_P(TDMHwc, AcceptChangesSuccessful) { TDM_UT_SKIP_FLAG(has_outputs); @@ -511,10 +549,6 @@ TEST_P(TDMHwc, AcceptChangesSuccessful) tdm_hwc *hwc = NULL; tdm_error error = TDM_ERROR_NONE; tdm_hwc_window *hwc_wnds[HWC_WIN_NUM]; - tdm_hwc_window **changed_hwc_window = NULL; - tdm_hwc_window_composition *composition_types = NULL; - uint32_t num_types; - uint32_t get_num = 0; for (int o = 0; o < output_count; o++) { if (tc_tdm_output_is_connected(outputs[o]) == false) @@ -522,31 +556,7 @@ TEST_P(TDMHwc, AcceptChangesSuccessful) EXPECT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true); hwc = tdm_output_get_hwc(outputs[o], &error); if (hwc) { - for (int w = 0; w < HWC_WIN_NUM; w++) { - hwc_wnds[w] = tdm_hwc_create_window(hwc, &error); - EXPECT_EQ(TDM_ERROR_NONE, error); - error = tdm_hwc_window_set_composition_type(hwc_wnds[w], TDM_HWC_WIN_COMPOSITION_DEVICE); - EXPECT_EQ(TDM_ERROR_NONE, error); - } - - error = tdm_hwc_validate(hwc, hwc_wnds, HWC_WIN_NUM, &num_types); - EXPECT_EQ(TDM_ERROR_NONE, error); - - if (num_types > 0) { - changed_hwc_window = (tdm_hwc_window **)calloc(num_types, sizeof(tdm_hwc_window *)); - composition_types = (tdm_hwc_window_composition *)calloc(num_types, sizeof(tdm_hwc_window_composition)); - - get_num = num_types; - error = tdm_hwc_get_changed_composition_types(hwc, &get_num, changed_hwc_window, composition_types); - EXPECT_EQ(TDM_ERROR_NONE, error); - EXPECT_EQ(get_num, num_types); - - error = tdm_hwc_accept_validation(hwc); - EXPECT_EQ(TDM_ERROR_NONE, error); - - free(composition_types); - free(changed_hwc_window); - } + EXPECT_EQ(_tc_tdm_hwc_prepare_commit(hwc, hwc_wnds), true); for (int w = 0; w < HWC_WIN_NUM; w++) tdm_hwc_window_destroy(hwc_wnds[w]); @@ -572,10 +582,6 @@ TEST_P(TDMHwc, CommitSuccessful) tdm_hwc *hwc = NULL; tdm_error error = TDM_ERROR_NONE; tdm_hwc_window *hwc_wnds[HWC_WIN_NUM]; - tdm_hwc_window **changed_hwc_window = NULL; - tdm_hwc_window_composition *composition_types = NULL; - uint32_t num_types; - uint32_t get_num = 0; for (int o = 0; o < output_count; o++) { if (tc_tdm_output_is_connected(outputs[o]) == false) @@ -583,31 +589,7 @@ TEST_P(TDMHwc, CommitSuccessful) EXPECT_EQ(tc_tdm_output_prepare(dpy, outputs[o], true), true); hwc = tdm_output_get_hwc(outputs[o], &error); if (hwc) { - for (int w = 0; w < HWC_WIN_NUM; w++) { - hwc_wnds[w] = tdm_hwc_create_window(hwc, &error); - EXPECT_EQ(TDM_ERROR_NONE, error); - error = tdm_hwc_window_set_composition_type(hwc_wnds[w], TDM_HWC_WIN_COMPOSITION_DEVICE); - EXPECT_EQ(TDM_ERROR_NONE, error); - } - - error = tdm_hwc_validate(hwc, hwc_wnds, HWC_WIN_NUM, &num_types); - EXPECT_EQ(TDM_ERROR_NONE, error); - - if (num_types > 0) { - changed_hwc_window = (tdm_hwc_window **)calloc(num_types, sizeof(tdm_hwc_window *)); - composition_types = (tdm_hwc_window_composition *)calloc(num_types, sizeof(tdm_hwc_window_composition)); - - get_num = num_types; - error = tdm_hwc_get_changed_composition_types(hwc, &get_num, changed_hwc_window, composition_types); - EXPECT_EQ(TDM_ERROR_NONE, error); - EXPECT_EQ(get_num, num_types); - - error = tdm_hwc_accept_validation(hwc); - EXPECT_EQ(TDM_ERROR_NONE, error); - - free(composition_types); - free(changed_hwc_window); - } + EXPECT_EQ(_tc_tdm_hwc_prepare_commit(hwc, hwc_wnds), true); error = tdm_hwc_commit(hwc, 0, _tc_tdm_hwc_commit_cb, NULL); EXPECT_EQ(TDM_ERROR_NONE, error); -- 2.7.4 From b7ba6b72b720f1ee9798e9ed7cfe75192000c8b0 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Fri, 1 Jul 2022 18:23:50 +0900 Subject: [PATCH 07/16] haltest/backend_pp: Remove duplicate code Change-Id: I10a5850fcfafed122c0f055289629e1427c02c53 --- haltests/src/tc_tdm_backend_pp.cpp | 216 +++++++++++-------------------------- 1 file changed, 65 insertions(+), 151 deletions(-) diff --git a/haltests/src/tc_tdm_backend_pp.cpp b/haltests/src/tc_tdm_backend_pp.cpp index 5bf3a51..c59b7ed 100644 --- a/haltests/src/tc_tdm_backend_pp.cpp +++ b/haltests/src/tc_tdm_backend_pp.cpp @@ -70,6 +70,7 @@ public: bool FindLayerOverPrimary(void); bool PreparePP(void); bool PrepareBuffers(int sw, int sh, tbm_format sf, int dw, int dh, tbm_format df, tdm_transform t); + bool TestLayerShow(int sw, int sh, tbm_format sf, int dw, int dh, tbm_format df, tdm_transform t); void ShowBuffer(int b); void HideLayer(void); void DumpBuffer(int b, char *test); @@ -196,6 +197,51 @@ bool TDMBackendPP::PrepareBuffers(int sw, int sh, tbm_format sf, int dw, int dh, return true; } +static void +_tc_tdm_pp_done_cb(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst, void *user_data) +{ + bool *done = (bool*)user_data; + if (done) + *done = true; +} + +bool TDMBackendPP::TestLayerShow(int sw, int sh, tbm_format sf, int dw, int dh, tbm_format df, tdm_transform t) +{ + bool done; + + TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(df)); + + DestroyPP(); + DestroyBuffers(); + + TDM_UT_RETURN_FALSE_IF_FAIL(PreparePP() == true); + + TDM_UT_RETURN_FALSE_IF_FAIL(PrepareBuffers(sw, sh, sf, + dw, dh, df, + t) == true); + + TDM_UT_RETURN_FALSE_IF_FAIL(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done) == TDM_ERROR_NONE); + + for (int b = 0; b < 3; b++) { + done = false; + + TDM_UT_RETURN_FALSE_IF_FAIL(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]) == TDM_ERROR_NONE); + TDM_UT_RETURN_FALSE_IF_FAIL(tdm_pp_commit(pp) == TDM_ERROR_NONE); + + while (!done) + TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_display_handle_events(dpy) == TDM_ERROR_NONE); + +#if 0 + char temp[256]; + snprintf(temp, sizeof temp, "f%d_b%d", f, b); + DumpBuffer(b, temp); +#endif + ShowBuffer(b); + } + + return true; +} + bool TDMBackendPP::FindLayerUnderPrimary(void) { tdm_error ret; @@ -495,14 +541,6 @@ TEST_P(TDMBackendPP, PPSetInfoNullOther) DestroyPP(); } -static void -_tc_tdm_pp_done_cb(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst, void *user_data) -{ - bool *done = (bool*)user_data; - if (done) - *done = true; -} - TEST_P(TDMBackendPP, PPSetDoneHandler) { TDM_UT_SKIP_FLAG(tc_tdm_display_has_pp_capability(dpy)); @@ -591,35 +629,10 @@ TEST_P(TDMBackendPP, PPConvertUnderlay) EXPECT_NE(dst_layer, NULL); for (int f = 0; f < dst_format_count; f++) { - bool done; - - TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f])); - - EXPECT_EQ(PreparePP(), true); - - EXPECT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f], - TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f], - TDM_TRANSFORM_NORMAL), true); - - EXPECT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE); - retry: - for (int b = 0; b < 3; b++) { - done = false; - - EXPECT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE); - EXPECT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE); - - while (!done) - EXPECT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE); - -#if 0 - char temp[256]; - snprintf(temp, sizeof temp, "f%d_b%d", f, b); - DumpBuffer(b, temp); -#endif - ShowBuffer(b); - } + EXPECT_EQ(TestLayerShow(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f], + TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f], + TDM_TRANSFORM_NORMAL), true); TDM_UT_ASK_YNR("* Successed to convert to '%c%c%c%c' buffers and show them to a underlay layer? (output: %d, layer: %d)", FOURCC_STR(dst_formats[f]), pipe, dst_layer_index); @@ -627,6 +640,7 @@ retry: DestroyPP(); DestroyBuffers(); } + if (tc_tdm_output_is_hwc_enable(output) && pp_formats) { free(pp_formats); pp_formats = NULL; @@ -643,35 +657,10 @@ TEST_P(TDMBackendPP, PPConvertOverlay) TDM_UT_SKIP_FLAG(dst_layer != NULL); for (int f = 0; f < dst_format_count; f++) { - bool done; - - TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f])); - - EXPECT_EQ(PreparePP(), true); - - EXPECT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f], - TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f], - TDM_TRANSFORM_NORMAL), true); - - EXPECT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE); - retry: - for (int b = 0; b < 3; b++) { - done = false; - - EXPECT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE); - EXPECT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE); - - while (!done) - EXPECT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE); - -#if 0 - char temp[256]; - snprintf(temp, sizeof temp, "f%d_b%d", f, b); - DumpBuffer(b, temp); -#endif - ShowBuffer(b); - } + EXPECT_EQ(TestLayerShow(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f], + TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f], + TDM_TRANSFORM_NORMAL), true); TDM_UT_ASK_YNR("* Successed to convert '%c%c%c%c' buffers and show them to a overlay layer? (output: %d, layer: %d)", FOURCC_STR(dst_formats[f]), pipe, dst_layer_index); @@ -679,6 +668,7 @@ retry: DestroyPP(); DestroyBuffers(); } + if (tc_tdm_output_is_hwc_enable(output) && pp_formats) { free(pp_formats); pp_formats = NULL; @@ -695,35 +685,10 @@ TEST_P(TDMBackendPP, PPConvertScale) EXPECT_NE(dst_layer, NULL); for (int f = 0; f < dst_format_count; f++) { - bool done; - - TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f])); - - EXPECT_EQ(PreparePP(), true); - - EXPECT_EQ(PrepareBuffers(640, 480, dst_formats[f], - mode->hdisplay, mode->vdisplay, dst_formats[f], - TDM_TRANSFORM_NORMAL), true); - - EXPECT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE); - retry: - for (int b = 0; b < 3; b++) { - done = false; - - EXPECT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE); - EXPECT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE); - - while (!done) - EXPECT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE); - -#if 0 - char temp[256]; - snprintf(temp, sizeof temp, "f%d_b%d", f, b); - DumpBuffer(b, temp); -#endif - ShowBuffer(b); - } + EXPECT_EQ(TestLayerShow(640, 480 / 2, dst_formats[f], + mode->hdisplay, mode->vdisplay, dst_formats[f], + TDM_TRANSFORM_NORMAL), true); TDM_UT_ASK_YNR("* Successed to scale '%c%c%c%c' buffers? (output: %d, layer: %d)", FOURCC_STR(dst_formats[f]), pipe, dst_layer_index); @@ -731,6 +696,7 @@ retry: DestroyPP(); DestroyBuffers(); } + if (tc_tdm_output_is_hwc_enable(output) && pp_formats) { free(pp_formats); pp_formats = NULL; @@ -749,35 +715,10 @@ TEST_P(TDMBackendPP, PPConvertTransform) for (int f = 0; f < dst_format_count; f++) { for (int t = (int)TDM_TRANSFORM_90; t <= (int)TDM_TRANSFORM_FLIPPED_270; t++) { - bool done; - - TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(dst_formats[f])); - - EXPECT_EQ(PreparePP(), true); - - EXPECT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f], - TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f], - (tdm_transform)t), true); - - EXPECT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE); - retry: - for (int b = 0; b < 3; b++) { - done = false; - - EXPECT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE); - EXPECT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE); - - while (!done) - EXPECT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE); - -#if 0 - char temp[256]; - snprintf(temp, sizeof temp, "f%d_b%d_t%d", f, b, t); - DumpBuffer(b, temp); -#endif - ShowBuffer(b); - } + EXPECT_EQ(TestLayerShow(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f], + TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[f], + (tdm_transform)t), true); TDM_UT_ASK_YNR("* Successed to rotate '%c%c%c%c' buffers? (transform: %s, output: %d, layer: %d)", FOURCC_STR(dst_formats[f]), tdm_transform_str(t), pipe, dst_layer_index); @@ -786,6 +727,7 @@ retry: DestroyBuffers(); } } + if (tc_tdm_output_is_hwc_enable(output) && pp_formats) { free(pp_formats); pp_formats = NULL; @@ -804,36 +746,10 @@ TEST_P(TDMBackendPP, PPConvertCSC) for (int df = 0; df < dst_format_count; df++) { for (int sf = 0; sf < format_count; sf++) { - bool done; - - TDM_UT_INFO("* testing for format(%c%c%c%c) -> format(%c%c%c%c)", - FOURCC_STR(formats[sf]), FOURCC_STR(dst_formats[df])); - - EXPECT_EQ(PreparePP(), true); - - EXPECT_EQ(PrepareBuffers(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, formats[sf], - TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[df], - TDM_TRANSFORM_NORMAL), true); - - EXPECT_EQ(tdm_pp_set_done_handler(pp, _tc_tdm_pp_done_cb, &done), TDM_ERROR_NONE); - retry: - for (int b = 0; b < 3; b++) { - done = false; - - EXPECT_EQ(tdm_pp_attach(pp, srcbuf[b], dstbuf[b]), TDM_ERROR_NONE); - EXPECT_EQ(tdm_pp_commit(pp), TDM_ERROR_NONE); - - while (!done) - EXPECT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE); - -#if 0 - char temp[256]; - snprintf(temp, sizeof temp, "sf%d_df%d_b%d", sf, df, b); - DumpBuffer(b, temp); -#endif - ShowBuffer(b); - } + EXPECT_EQ(TestLayerShow(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, formats[sf], + TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE / 2, dst_formats[df], + TDM_TRANSFORM_NORMAL), true); TDM_UT_ASK_YNR("* Successed to convert from '%c%c%c%c' to '%c%c%c%c'? (output: %d, layer: %d)", FOURCC_STR(formats[sf]), FOURCC_STR(dst_formats[df]), pipe, dst_layer_index); @@ -848,8 +764,6 @@ retry: } } - - static void _tc_tdm_pp_done_cb2(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst, void *user_data) { -- 2.7.4 From 8411b5f389b981e6641d5e5915339bfffb6350da Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Thu, 30 Jun 2022 18:59:33 +0900 Subject: [PATCH 08/16] haltest/backend_display: Remove duplicate code Change-Id: I151a8a6cce2a741af8fd95ad0d1ac8b2e8a0e5ea --- haltests/src/tc_tdm.h | 9 + haltests/src/tc_tdm_backend_display.cpp | 597 +++++++++++--------------------- 2 files changed, 220 insertions(+), 386 deletions(-) diff --git a/haltests/src/tc_tdm.h b/haltests/src/tc_tdm.h index e118e77..2838c79 100644 --- a/haltests/src/tc_tdm.h +++ b/haltests/src/tc_tdm.h @@ -224,6 +224,13 @@ public: tdm_layer **layers; int layer_count; + const tbm_format *layer_formats; + int layer_format_count; + unsigned int layer_flags; + tdm_output *layer_output; + unsigned int layer_output_pipe; + const tdm_output_mode *layer_output_mode; + tbm_surface_h buffers[3]; TDMBackendBasic(); @@ -231,6 +238,8 @@ public: void TearDown(void); void UnsetOutput(void); void DestroyBuffers(void); + bool PrepareLayer(tdm_layer *layer); + bool PrepareOutputVblank(tdm_output *output); }; class TDMBackendDisplay : public TDMBackendBasic diff --git a/haltests/src/tc_tdm_backend_display.cpp b/haltests/src/tc_tdm_backend_display.cpp index 5b4d0b9..98e886a 100644 --- a/haltests/src/tc_tdm_backend_display.cpp +++ b/haltests/src/tc_tdm_backend_display.cpp @@ -42,6 +42,13 @@ TDMBackendBasic::TDMBackendBasic() layers = NULL; layer_count = 0; + layer_output = NULL; + layer_output_pipe = 0; + layer_output_mode = NULL; + layer_flags = 0; + layer_formats = NULL; + layer_format_count = 0; + for (int b = 0; b < 3; b++) buffers[b] = NULL; } @@ -124,6 +131,57 @@ void TDMBackendBasic::DestroyBuffers(void) } } +bool TDMBackendBasic::PrepareLayer(tdm_layer *layer) +{ + tdm_error ret; + + layer_output = NULL; + layer_output_pipe = 0; + layer_output_mode = NULL; + layer_flags = 0; + layer_formats = NULL; + layer_format_count = 0; + + layer_output = tdm_layer_get_output(layer, &ret); + TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE); + + TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_pipe(layer_output, &layer_output_pipe) == TDM_ERROR_NONE); + + TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_buffer_flags(layer, &layer_flags) == TDM_ERROR_NONE); + + if (tc_tdm_output_is_connected(layer_output)) { + TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_mode(layer_output, &layer_output_mode) == TDM_ERROR_NONE); + TDM_UT_RETURN_FALSE_IF_FAIL(layer_output_mode != NULL); + + TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_set_dpms(layer_output, TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE); + } + + TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_available_formats(layer, &layer_formats, &layer_format_count) == TDM_ERROR_NONE); + + return true; +} + +bool TDMBackendBasic::PrepareOutputVblank(tdm_output *output) +{ + tdm_layer *layer; + + TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_output_mode_setting(output) == true); + TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON) == TDM_ERROR_NONE); + + if (!tc_tdm_output_is_hwc_enable(output)) { + layer = tc_tdm_output_get_primary_layer(output); + TDM_UT_RETURN_FALSE_IF_FAIL(layer != NULL); + + TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_layer_prepare_buffer(layer, buffers, 1, true) == true); + TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_layer_set_buffer(layer, buffers[0]) == true); + DestroyBuffers(); + + TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_commit(output, 0, NULL, NULL) == TDM_ERROR_NONE); + } + + return true; +} + char tc_tdm_backend_getchar(void) { @@ -471,9 +529,9 @@ retry: if (tdm_layer_get_output(layers[l], &ret) != outputs[o]) continue; EXPECT_EQ(ret, TDM_ERROR_NONE); - if (tc_tdm_layer_is_primary_layer(layers[l])) + if (tc_tdm_layer_is_primary_layer(layer)) continue; - if (tc_tdm_layer_is_cursor_layer(layers[l])) + if (tc_tdm_layer_is_cursor_layer(layer)) continue; EXPECT_EQ(tc_tdm_layer_prepare_buffer(layers[l], buffers, 1, true), true); EXPECT_EQ(tc_tdm_layer_set_buffer(layers[l], buffers[0]), true); @@ -521,9 +579,9 @@ TEST_P(TDMBackendBasic, VerifyOverlayLayersShowManyFrames) if (tdm_layer_get_output(layers[l], &ret) != outputs[o]) continue; EXPECT_EQ(ret, TDM_ERROR_NONE); - if (tc_tdm_layer_is_primary_layer(layers[l])) + if (tc_tdm_layer_is_primary_layer(layer)) continue; - if (tc_tdm_layer_is_cursor_layer(layers[l])) + if (tc_tdm_layer_is_cursor_layer(layer)) continue; retry: @@ -564,27 +622,44 @@ _tc_tdm_backend_output_done_cb(tdm_output *output, unsigned int sequence, *done = true; } +static void +_tc_tdm_backend_display_print_wait_vblank_info(double start, double end, double interval, int t) +{ + /* "+ interval" consider the delay of socket communication between kernel and platform */ + //EXPECT_GT((end - start), (interval * (t - 1))); + double a = end - start; + double b = interval * (t - 1); + if (a > b) { + std::cout << "\033[0;35m" << "==> Error: " << "\033[0;33m" + << "Expected: ((end - start) > (interval * (t - 1))), " + << "actual: " << a << " vs " << b << "\033[0;0m" << std::endl; + std::cout << "\033[0;34m" << " \t The vblank event should happen after "<< t + << " vsync intervals( "<< t * interval * 1000 + interval * 1000 << " ms).\n" + << "\t But it happened at " << (end - start) * 1000 << " ms. " + << "Check output_wait_vblank(), output_set_vblank_handler().\n"; + } + + //EXPECT_LT((end - start), (interval * t + interval)); + a = end - start; + b = interval * t + interval; + if (a < b) { + std::cout << "\033[0;35m" << "==> Error: " << "\033[0;33m" + << "Expected: ((end - start) < (interval * t + interval)), " + << "actual: " << a << " vs " << b << "\033[0;0m" << std::endl; + std::cout << "\033[0;34m" << "\t The vblank event should happen after "<< t + << " vsync intervals( "<< t * interval * 1000 + interval * 1000 << " ms).\n" + << "\t But it happened at " << (end - start) * 1000 << " ms. " + << "Check output_wait_vblank(), output_set_vblank_handler().\n"; + } +} + TEST_P(TDMBackendBasic, VerifyOutputWaitVblank) { for (int o = 0; o < output_count; o++) { - tdm_layer *layer; - if (!tc_tdm_output_is_connected(outputs[o])) continue; - EXPECT_EQ(tc_tdm_output_mode_setting(outputs[o]), true); - EXPECT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE); - - if (!tc_tdm_output_is_hwc_enable(outputs[o])) { - layer = tc_tdm_output_get_primary_layer(outputs[o]); - EXPECT_NE(layer, NULL); - - EXPECT_EQ(tc_tdm_layer_prepare_buffer(layer, buffers, 1, true), true); - EXPECT_EQ(tc_tdm_layer_set_buffer(layer, buffers[0]), true); - DestroyBuffers(); - - EXPECT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE); - } + EXPECT_EQ(PrepareOutputVblank(outputs[o]), true); /* start from 1 */ for (int t = 1; t < 10; t++) { @@ -602,32 +677,7 @@ TEST_P(TDMBackendBasic, VerifyOutputWaitVblank) "Check display_get_fd(), display_handle_events()"); end = tdm_helper_get_time(); - /* "+ interval" consider the delay of socket communication between kernel and platform */ - //EXPECT_GT((end - start), (interval * (t - 1))); - double a = end - start; - double b = interval * (t - 1); - if (a > b) { - std::cout << "\033[0;35m" << "==> Error: " << "\033[0;33m" - << "Expected: ((end - start) > (interval * (t - 1))), " - << "actual: " << a << " vs " << b << "\033[0;0m" << std::endl; - std::cout << "\033[0;34m" << "\t The vblank event should happen after "<< t - << " vsync intervals( "<< t * interval * 1000 + interval * 1000 << " ms).\n" - << "\t But it happened at " << (end - start) * 1000 << " ms. " - << "Check output_wait_vblank(), output_set_vblank_handler().\n"; - } - - //EXPECT_LT((end - start), (interval * t + interval)); - a = end - start; - b = interval * t + interval; - if (a < b) { - std::cout << "\033[0;35m" << "==> Error: " << "\033[0;33m" - << "Expected: ((end - start) < (interval * t + interval)), " - << "actual: " << a << " vs " << b << "\033[0;0m" << std::endl; - std::cout << "\033[0;34m" << "\t The vblank event should happen after "<< t - << " vsync intervals( "<< t * interval * 1000 + interval * 1000 << " ms).\n" - << "\t But it happened at " << (end - start) * 1000 << " ms. " - << "Check output_wait_vblank(), output_set_vblank_handler().\n"; - } + _tc_tdm_backend_display_print_wait_vblank_info(start, end, interval, t); } } } @@ -635,24 +685,10 @@ TEST_P(TDMBackendBasic, VerifyOutputWaitVblank) TEST_P(TDMBackendBasic, VerifyOutputWaitVblankInterval) { for (int o = 0; o < output_count; o++) { - tdm_layer *layer; - if (!tc_tdm_output_is_connected(outputs[o])) continue; - EXPECT_EQ(tc_tdm_output_mode_setting(outputs[o]), true); - EXPECT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE); - - if (!tc_tdm_output_is_hwc_enable(outputs[o])) { - layer = tc_tdm_output_get_primary_layer(outputs[o]); - EXPECT_NE(layer, NULL); - - EXPECT_EQ(tc_tdm_layer_prepare_buffer(layer, buffers, 1, true), true); - EXPECT_EQ(tc_tdm_layer_set_buffer(layer, buffers[0]), true); - DestroyBuffers(); - - EXPECT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE); - } + EXPECT_EQ(PrepareOutputVblank(outputs[o]), true); /* start from 1 */ for (int t = 1; t < 10; t++) { @@ -668,32 +704,7 @@ TEST_P(TDMBackendBasic, VerifyOutputWaitVblankInterval) EXPECT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE); end = tdm_helper_get_time(); - /* "+ interval" consider the delay of socket communication between kernel and platform */ - //EXPECT_GT((end - start), (interval * (t - 1))); - double a = end - start; - double b = interval * (t - 1); - if (a > b) { - std::cout << "\033[0;35m" << "==> Error: " << "\033[0;33m" - << "Expected: ((end - start) > (interval * (t - 1))), " - << "actual: " << a << " vs " << b << "\033[0;0m" << std::endl; - std::cout << "\033[0;34m" << " \t The vblank event should happen after "<< t - << " vsync intervals( "<< t * interval * 1000 + interval * 1000 << " ms).\n" - << "\t But it happened at " << (end - start) * 1000 << " ms. " - << "Check output_wait_vblank(), output_set_vblank_handler().\n"; - } - - //EXPECT_LT((end - start), (interval * t + interval)); - a = end - start; - b = interval * t + interval; - if (a < b) { - std::cout << "\033[0;35m" << "==> Error: " << "\033[0;33m" - << "Expected: ((end - start) < (interval * t + interval)), " - << "actual: " << a << " vs " << b << "\033[0;0m" << std::endl; - std::cout << "\033[0;34m" << "\t The vblank event should happen after "<< t - << " vsync intervals( "<< t * interval * 1000 + interval * 1000 << " ms).\n" - << "\t But it happened at " << (end - start) * 1000 << " ms. " - << "Check output_wait_vblank(), output_set_vblank_handler().\n"; - } + _tc_tdm_backend_display_print_wait_vblank_info(start, end, interval, t); } } } @@ -701,24 +712,10 @@ TEST_P(TDMBackendBasic, VerifyOutputWaitVblankInterval) TEST_P(TDMBackendBasic, VerifyOutputWaitVblankFewTimesInOneVblank) { for (int o = 0; o < output_count; o++) { - tdm_layer *layer; - if (!tc_tdm_output_is_connected(outputs[o])) continue; - EXPECT_EQ(tc_tdm_output_mode_setting(outputs[o]), true); - EXPECT_EQ(tdm_output_set_dpms(outputs[o], TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE); - - if (!tc_tdm_output_is_hwc_enable(outputs[o])) { - layer = tc_tdm_output_get_primary_layer(outputs[o]); - EXPECT_NE(layer, NULL); - - EXPECT_EQ(tc_tdm_layer_prepare_buffer(layer, buffers, 1, true), true); - EXPECT_EQ(tc_tdm_layer_set_buffer(layer, buffers[0]), true); - DestroyBuffers(); - - EXPECT_EQ(tdm_output_commit(outputs[o], 0, NULL, NULL), TDM_ERROR_NONE); - } + EXPECT_EQ(PrepareOutputVblank(outputs[o]), true); /* start from 1 */ for (int t = 1; t < 10; t++) { @@ -736,32 +733,7 @@ TEST_P(TDMBackendBasic, VerifyOutputWaitVblankFewTimesInOneVblank) EXPECT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE); end = tdm_helper_get_time(); - /* "+ interval" consider the delay of socket communication between kernel and platform */ - //EXPECT_GT((end - start), (interval * (t - 1))); - double a = end - start; - double b = interval * (t - 1); - if (a > b) { - std::cout << "\033[0;35m" << "==> Error: " << "\033[0;33m" - << "Expected: ((end - start) > (interval * (t - 1))), " - << "actual: " << a << " vs " << b << "\033[0;0m" << std::endl; - std::cout << "\033[0;34m" << "\t The vblank event should happen after "<< t - << " vsync intervals( "<< t * interval * 1000 + interval * 1000 << " ms).\n" - << "\t But it happened at " << (end - start) * 1000 << " ms. " - << "Check output_wait_vblank(), output_set_vblank_handler().\n"; - } - - //EXPECT_LT((end - start), (interval * t + interval)); - a = end - start; - b = interval * t + interval; - if (a < b) { - std::cout << "\033[0;35m" << "==> Error: " << "\033[0;33m" - << "Expected: ((end - start) < (interval * t + interval)), " - << "actual: " << a << " vs " << b << "\033[0;0m" << std::endl; - std::cout << "\033[0;34m" << "\t The vblank event should happen after " << t - << " vsync intervals( "<< t * interval * 1000 + interval * 1000 << " ms).\n" - << "\t But it happened at " << (end - start) * 1000 << " ms. " - << "Check output_wait_vblank(), output_set_vblank_handler().\n"; - } + _tc_tdm_backend_display_print_wait_vblank_info(start, end, interval, t); } } } @@ -907,13 +879,51 @@ INSTANTIATE_TEST_CASE_P(TDMBackendBasicParams, Values(TDM_DEFAULT_MODULE)); #endif +static bool +_tc_tdm_backend_display_layer_test(tdm_display *dpy, tdm_output *output, tdm_layer *layer, tdm_info_layer *info, + tbm_surface_h *buffers, int test_count, bool test_move) +{ + int next_buffer = 0; + bool done = false; + tdm_error ret; + int dst_x = 0, dst_y = 0; + + if (info && test_move) { + dst_x = info->dst_pos.x; + dst_y = info->dst_pos.y; + } + + for (int t = 0; t < test_count; t++) { + tbm_surface_h displaying_buffer; + + if (info && test_move) { + info->dst_pos.x = dst_x * t; + info->dst_pos.y = dst_y * t; + } + + if (info) + EXPECT_EQ(tdm_layer_set_info(layer, info), TDM_ERROR_NONE); + + EXPECT_EQ(tc_tdm_layer_set_buffer(layer, buffers[next_buffer]), true); + done = false; + EXPECT_EQ(tdm_output_commit(output, 0, _tc_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE); + while (!done) + EXPECT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE); + displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret); + EXPECT_EQ(ret, TDM_ERROR_NONE); + EXPECT_EQ(displaying_buffer, buffers[next_buffer]); + next_buffer++; + if (next_buffer == 3) + next_buffer = 0; + } + + return true; +} + TEST_P(TDMBackendDisplay, VerifyPirmaryLayerFormat) { for (int o = 0; o < output_count; o++) { tdm_layer *layer; - int next_buffer = 0; - bool done = false; - tdm_error ret; const tbm_format *formats; int format_count = 0; const tdm_output_mode *mode = NULL; @@ -941,21 +951,7 @@ retry: TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f])); EXPECT_EQ(tc_tdm_buffer_create(mode->hdisplay, mode->vdisplay, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true); - /* set buffer & commit for 60 times */ - for (int t = 0; t < 60; t++) { - tbm_surface_h displaying_buffer; - EXPECT_EQ(tc_tdm_layer_set_buffer(layer, buffers[next_buffer]), true); - done = false; - EXPECT_EQ(tdm_output_commit(outputs[o], 0, _tc_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE); - while (!done) - EXPECT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE); - displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret); - EXPECT_EQ(ret, TDM_ERROR_NONE); - EXPECT_EQ(displaying_buffer, buffers[next_buffer]); - next_buffer++; - if (next_buffer == 3) - next_buffer = 0; - } + EXPECT_EQ(_tc_tdm_backend_display_layer_test(dpy, outputs[o], layer, NULL, buffers, 60, false), true); DestroyBuffers(); @@ -976,63 +972,31 @@ TEST_P(TDMBackendDisplay, VerifyOverlayLayerFormat) } for (int l = 0; l < layer_count; l++) { - tdm_error ret; - tdm_output *output; tdm_layer *layer; - int next_buffer = 0; - bool done = false; - const tbm_format *formats; - int format_count = 0; - const tdm_output_mode *mode = NULL; - unsigned int flags = 0; - unsigned int pipe = 0; layer = layers[l]; - output = tdm_layer_get_output(layer, &ret); - EXPECT_EQ(ret, TDM_ERROR_NONE); + EXPECT_EQ(PrepareLayer(layer), true); - if (!tc_tdm_output_is_connected(output)) + if (!tc_tdm_output_is_connected(layer_output)) continue; if (tc_tdm_layer_is_primary_layer(layer)) continue; if (tc_tdm_layer_is_cursor_layer(layer)) continue; - EXPECT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE); - - TDM_UT_INFO("* testing for (output: %d, layer: %d)", pipe, l); - - EXPECT_EQ(tdm_layer_get_buffer_flags(layer, &flags), TDM_ERROR_NONE); - EXPECT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE); - EXPECT_NE(mode, NULL); + TDM_UT_INFO("* testing for (output: %d, layer: %d)", layer_output_pipe, l); - EXPECT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE); - - EXPECT_EQ(tdm_layer_get_available_formats(layer, &formats, &format_count), TDM_ERROR_NONE); - - for (int f = 0; f < format_count; f++) { + for (int f = 0; f < layer_format_count; f++) { retry: - TDM_UT_INFO("** testing for %c%c%c%c", FOURCC_STR(formats[f])); - EXPECT_EQ(tc_tdm_buffer_create(mode->hdisplay, mode->vdisplay, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true); + TDM_UT_INFO("** testing for %c%c%c%c", FOURCC_STR(layer_formats[f])); + EXPECT_EQ(tc_tdm_buffer_create(layer_output_mode->hdisplay, layer_output_mode->vdisplay, layer_formats[f], + layer_flags | TBM_BO_SCANOUT, true, 3, buffers), true); - /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */ - for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) { - tbm_surface_h displaying_buffer; - EXPECT_EQ(tc_tdm_layer_set_buffer(layer, buffers[next_buffer]), true); - done = false; - EXPECT_EQ(tdm_output_commit(output, 0, _tc_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE); - while (!done) - EXPECT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE); - displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret); - EXPECT_EQ(ret, TDM_ERROR_NONE); - EXPECT_EQ(displaying_buffer, buffers[next_buffer]); - next_buffer++; - if (next_buffer == 3) - next_buffer = 0; - } + EXPECT_EQ(_tc_tdm_backend_display_layer_test(dpy, layer_output, layer, NULL, buffers, TDM_UT_BACKEND_TEST_CNT, false), true); - TDM_UT_ASK_YNR("* Successed to display '%c%c%c%c' frames to a layer? (output: %d, layer: %d)", FOURCC_STR(formats[f]), pipe, l); + TDM_UT_ASK_YNR("* Successed to display '%c%c%c%c' frames to a layer? (output: %d, layer: %d)", + FOURCC_STR(layer_formats[f]), layer_output_pipe, l); DestroyBuffers(); } @@ -1053,70 +1017,36 @@ TEST_P(TDMBackendDisplay, VerifyOverlayLayerSize) } for (int l = 0; l < layer_count; l++) { - tdm_error ret; - tdm_output *output; tdm_layer *layer; - int next_buffer = 0; - bool done = false; - const tbm_format *formats; - int format_count = 0; - const tdm_output_mode *mode = NULL; - unsigned int flags = 0; - unsigned int pipe = 0; layer = layers[l]; - output = tdm_layer_get_output(layer, &ret); - EXPECT_EQ(ret, TDM_ERROR_NONE); + EXPECT_EQ(PrepareLayer(layer), true); - if (!tc_tdm_output_is_connected(output)) + if (!tc_tdm_output_is_connected(layer_output)) continue; if (tc_tdm_layer_is_primary_layer(layer)) continue; if (tc_tdm_layer_is_cursor_layer(layer)) continue; - EXPECT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE); - - TDM_UT_INFO("* testing for (output: %d, layer: %d)", pipe, l); + TDM_UT_INFO("* testing for (output: %d, layer: %d)", layer_output_pipe, l); - EXPECT_EQ(tdm_layer_get_buffer_flags(layer, &flags), TDM_ERROR_NONE); - EXPECT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE); - EXPECT_NE(mode, NULL); - - EXPECT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE); - - EXPECT_EQ(tdm_layer_get_available_formats(layer, &formats, &format_count), TDM_ERROR_NONE); - - for (int f = 0; f < format_count; f++) { - int diffw = mode->hdisplay / (format_count + 2); - int diffh = mode->vdisplay / (format_count + 2); - int w = mode->hdisplay - diffw * (f + 1); - int h = mode->vdisplay - diffh * (f + 1); + for (int f = 0; f < layer_format_count; f++) { + int diffw = layer_output_mode->hdisplay / (layer_format_count + 2); + int diffh = layer_output_mode->vdisplay / (layer_format_count + 2); + int w = layer_output_mode->hdisplay - diffw * (f + 1); + int h = layer_output_mode->vdisplay - diffh * (f + 1); retry: - TDM_UT_INFO("** testing for %c%c%c%c", FOURCC_STR(formats[f])); - EXPECT_EQ(tc_tdm_buffer_create(w, h, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true); + TDM_UT_INFO("** testing for %c%c%c%c", FOURCC_STR(layer_formats[f])); + EXPECT_EQ(tc_tdm_buffer_create(w, h, layer_formats[f], layer_flags | TBM_BO_SCANOUT, true, 3, buffers), true); - /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */ - for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) { - tbm_surface_h displaying_buffer; - EXPECT_EQ(tc_tdm_layer_set_buffer(layer, buffers[next_buffer]), true); - done = false; - EXPECT_EQ(tdm_output_commit(output, 0, _tc_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE); - while (!done) - EXPECT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE); - displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret); - EXPECT_EQ(ret, TDM_ERROR_NONE); - EXPECT_EQ(displaying_buffer, buffers[next_buffer]); - next_buffer++; - if (next_buffer == 3) - next_buffer = 0; - } + EXPECT_EQ(_tc_tdm_backend_display_layer_test(dpy, layer_output, layer, NULL, buffers, TDM_UT_BACKEND_TEST_CNT, false), true); DestroyBuffers(); TDM_UT_ASK_YNR("* Successed to display '%c%c%c%c' small size(%dx%d) frames to a layer? (output: %d, layer: %d)", - FOURCC_STR(formats[f]), w, h, pipe, l); + FOURCC_STR(layer_formats[f]), w, h, layer_output_pipe, l); } EXPECT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE); @@ -1135,25 +1065,13 @@ TEST_P(TDMBackendDisplay, VerifyOverlayLayerScale) } for (int l = 0; l < layer_count; l++) { - tdm_error ret; - tdm_output *output; tdm_layer *layer; - int next_buffer = 0; - bool done = false; - const tbm_format *formats; - int format_count = 0; - const tdm_output_mode *mode = NULL; - unsigned int flags = 0; - unsigned int pipe = 0; layer = layers[l]; - output = tdm_layer_get_output(layer, &ret); - EXPECT_EQ(ret, TDM_ERROR_NONE); - - EXPECT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE); + EXPECT_EQ(PrepareLayer(layer), true); - if (!tc_tdm_output_is_connected(output)) + if (!tc_tdm_output_is_connected(layer_output)) continue; if (tc_tdm_layer_is_primary_layer(layer)) continue; @@ -1164,18 +1082,10 @@ TEST_P(TDMBackendDisplay, VerifyOverlayLayerScale) continue; } - EXPECT_EQ(tdm_layer_get_buffer_flags(layer, &flags), TDM_ERROR_NONE); - EXPECT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE); - EXPECT_NE(mode, NULL); - - EXPECT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE); - - EXPECT_EQ(tdm_layer_get_available_formats(layer, &formats, &format_count), TDM_ERROR_NONE); - - for (int f = 0; f < format_count; f++) { + for (int f = 0; f < layer_format_count; f++) { retry: - TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f])); - EXPECT_EQ(tc_tdm_buffer_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true); + TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(layer_formats[f])); + EXPECT_EQ(tc_tdm_buffer_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, layer_formats[f], layer_flags | TBM_BO_SCANOUT, true, 3, buffers), true); tdm_info_layer info; memset(&info, 0, sizeof info); @@ -1185,34 +1095,19 @@ retry: info.src_config.pos.y = 0; info.src_config.pos.w = TDM_UT_BUFFER_SIZE; info.src_config.pos.h = TDM_UT_BUFFER_SIZE; - info.src_config.format = formats[f]; + info.src_config.format = layer_formats[f]; info.dst_pos.x = 0; info.dst_pos.y = 0; - info.dst_pos.w = mode->hdisplay; - info.dst_pos.h = mode->vdisplay; + info.dst_pos.w = layer_output_mode->hdisplay; + info.dst_pos.h = layer_output_mode->vdisplay; info.transform = TDM_TRANSFORM_NORMAL; - EXPECT_EQ(tdm_layer_set_info(layer, &info), TDM_ERROR_NONE); - /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */ - for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) { - tbm_surface_h displaying_buffer; - EXPECT_EQ(tdm_layer_set_buffer(layer, buffers[next_buffer]), TDM_ERROR_NONE); - done = false; - EXPECT_EQ(tdm_output_commit(output, 0, _tc_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE); - while (!done) - EXPECT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE); - displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret); - EXPECT_EQ(ret, TDM_ERROR_NONE); - EXPECT_EQ(displaying_buffer, buffers[next_buffer]); - next_buffer++; - if (next_buffer == 3) - next_buffer = 0; - } + EXPECT_EQ(_tc_tdm_backend_display_layer_test(dpy, layer_output, layer, &info, buffers, TDM_UT_BACKEND_TEST_CNT, false), true); DestroyBuffers(); TDM_UT_ASK_YNR("* Successed to scale '%c%c%c%c' small size(%dx%d) frames to fullsreen? (output: %d, layer: %d)", - FOURCC_STR(formats[f]), TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, pipe, l); + FOURCC_STR(layer_formats[f]), TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, layer_output_pipe, l); } EXPECT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE); @@ -1231,83 +1126,47 @@ TEST_P(TDMBackendDisplay, VerifyOverlayLayerMovePosition) } for (int l = 0; l < layer_count; l++) { - tdm_error ret; - tdm_output *output; tdm_layer *layer; - int next_buffer = 0; - bool done = false; - const tbm_format *formats; - int format_count = 0; - const tdm_output_mode *mode = NULL; - unsigned int flags = 0; - unsigned int pipe = 0; layer = layers[l]; - output = tdm_layer_get_output(layer, &ret); - EXPECT_EQ(ret, TDM_ERROR_NONE); + EXPECT_EQ(PrepareLayer(layer), true); - if (!tc_tdm_output_is_connected(output)) + if (!tc_tdm_output_is_connected(layer_output)) continue; if (tc_tdm_layer_is_primary_layer(layer)) continue; if (tc_tdm_layer_is_cursor_layer(layer)) continue; - EXPECT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE); - - TDM_UT_INFO("* testing for (output: %d, layer: %d)", pipe, l); - - EXPECT_EQ(tdm_layer_get_buffer_flags(layer, &flags), TDM_ERROR_NONE); - EXPECT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE); - EXPECT_NE(mode, NULL); - - EXPECT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE); - - EXPECT_EQ(tdm_layer_get_available_formats(layer, &formats, &format_count), TDM_ERROR_NONE); + TDM_UT_INFO("* testing for (output: %d, layer: %d)", layer_output_pipe, l); - for (int f = 0; f < format_count; f++) { + for (int f = 0; f < layer_format_count; f++) { retry: - TDM_UT_INFO("** testing for %c%c%c%c", FOURCC_STR(formats[f])); - EXPECT_EQ(tc_tdm_buffer_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true); + TDM_UT_INFO("** testing for %c%c%c%c", FOURCC_STR(layer_formats[f])); + EXPECT_EQ(tc_tdm_buffer_create(TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, layer_formats[f], layer_flags | TBM_BO_SCANOUT, true, 3, buffers), true); - /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */ - for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) { - tbm_surface_h displaying_buffer; - - tdm_info_layer info; - memset(&info, 0, sizeof info); - info.src_config.size.h = TDM_UT_BUFFER_SIZE; - info.src_config.size.v = TDM_UT_BUFFER_SIZE; - info.src_config.pos.x = 0; - info.src_config.pos.y = 0; - info.src_config.pos.w = TDM_UT_BUFFER_SIZE; - info.src_config.pos.h = TDM_UT_BUFFER_SIZE; - info.src_config.format = formats[f]; - info.dst_pos.x = ((mode->hdisplay - TDM_UT_BUFFER_SIZE) / TDM_UT_BACKEND_TEST_CNT) * t; - info.dst_pos.y = ((mode->vdisplay - TDM_UT_BUFFER_SIZE) / TDM_UT_BACKEND_TEST_CNT) * t; - info.dst_pos.w = TDM_UT_BUFFER_SIZE; - info.dst_pos.h = TDM_UT_BUFFER_SIZE; - info.transform = TDM_TRANSFORM_NORMAL; - EXPECT_EQ(tdm_layer_set_info(layer, &info), TDM_ERROR_NONE); - - EXPECT_EQ(tdm_layer_set_buffer(layer, buffers[next_buffer]), TDM_ERROR_NONE); - done = false; - EXPECT_EQ(tdm_output_commit(output, 0, _tc_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE); - while (!done) - EXPECT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE); - displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret); - EXPECT_EQ(ret, TDM_ERROR_NONE); - EXPECT_EQ(displaying_buffer, buffers[next_buffer]); - next_buffer++; - if (next_buffer == 3) - next_buffer = 0; - } + tdm_info_layer info; + memset(&info, 0, sizeof info); + info.src_config.size.h = TDM_UT_BUFFER_SIZE; + info.src_config.size.v = TDM_UT_BUFFER_SIZE; + info.src_config.pos.x = 0; + info.src_config.pos.y = 0; + info.src_config.pos.w = TDM_UT_BUFFER_SIZE; + info.src_config.pos.h = TDM_UT_BUFFER_SIZE; + info.src_config.format = layer_formats[f]; + info.dst_pos.x = ((layer_output_mode->hdisplay - TDM_UT_BUFFER_SIZE) / TDM_UT_BACKEND_TEST_CNT); + info.dst_pos.y = ((layer_output_mode->vdisplay - TDM_UT_BUFFER_SIZE) / TDM_UT_BACKEND_TEST_CNT); + info.dst_pos.w = TDM_UT_BUFFER_SIZE; + info.dst_pos.h = TDM_UT_BUFFER_SIZE; + info.transform = TDM_TRANSFORM_NORMAL; + + EXPECT_EQ(_tc_tdm_backend_display_layer_test(dpy, layer_output, layer, &info, buffers, TDM_UT_BACKEND_TEST_CNT, false), true); DestroyBuffers(); TDM_UT_ASK_YNR("* Successed to move '%c%c%c%c' small size(%dx%d) frames on screen? (output: %d, layer: %d)", - FOURCC_STR(formats[f]), TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, pipe, l); + FOURCC_STR(layer_formats[f]), TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, layer_output_pipe, l); } EXPECT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE); @@ -1326,86 +1185,52 @@ TEST_P(TDMBackendDisplay, VerifyOverlayLayerCrop) } for (int l = 0; l < layer_count; l++) { - tdm_error ret; - tdm_output *output; tdm_layer *layer; - int next_buffer = 0; - bool done = false; - const tbm_format *formats; - int format_count = 0; - const tdm_output_mode *mode = NULL; - unsigned int flags = 0; - unsigned int pipe = 0; layer = layers[l]; - output = tdm_layer_get_output(layer, &ret); - EXPECT_EQ(ret, TDM_ERROR_NONE); - - EXPECT_EQ(tdm_output_get_pipe(output, &pipe), TDM_ERROR_NONE); + EXPECT_EQ(PrepareLayer(layer), true); - if (!tc_tdm_output_is_connected(output)) + if (!tc_tdm_output_is_connected(layer_output)) continue; if (tc_tdm_layer_is_primary_layer(layer)) continue; if (tc_tdm_layer_is_cursor_layer(layer)) continue; if (tc_tdm_layer_support_no_crop(layer)) { - TDM_UT_INFO("no crop capability. (output: %d, layer: %d)", pipe, l); + TDM_UT_INFO("no crop capability. (output: %d, layer: %d)", layer_output_pipe, l); continue; } - TDM_UT_INFO("* testing for (output: %d, layer: %d)", pipe, l); + TDM_UT_INFO("* testing for (output: %d, layer: %d)", layer_output_pipe, l); - EXPECT_EQ(tdm_layer_get_buffer_flags(layer, &flags), TDM_ERROR_NONE); - EXPECT_EQ(tdm_output_get_mode(output, &mode), TDM_ERROR_NONE); - EXPECT_NE(mode, NULL); - - EXPECT_EQ(tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON), TDM_ERROR_NONE); - - EXPECT_EQ(tdm_layer_get_available_formats(layer, &formats, &format_count), TDM_ERROR_NONE); - - for (int f = 0; f < format_count; f++) { + for (int f = 0; f < layer_format_count; f++) { retry: - TDM_UT_INFO("** testing for %c%c%c%c", FOURCC_STR(formats[f])); - EXPECT_EQ(tc_tdm_buffer_create(mode->hdisplay, mode->vdisplay, formats[f], flags | TBM_BO_SCANOUT, true, 3, buffers), true); + TDM_UT_INFO("** testing for %c%c%c%c", FOURCC_STR(layer_formats[f])); + EXPECT_EQ(tc_tdm_buffer_create(layer_output_mode->hdisplay, layer_output_mode->vdisplay, + layer_formats[f], layer_flags | TBM_BO_SCANOUT, true, 3, buffers), true); tdm_info_layer info; memset(&info, 0, sizeof info); - info.src_config.size.h = mode->hdisplay; - info.src_config.size.v = mode->vdisplay; - info.src_config.pos.x = mode->hdisplay / 2; - info.src_config.pos.y = mode->vdisplay / 2; + info.src_config.size.h = layer_output_mode->hdisplay; + info.src_config.size.v = layer_output_mode->vdisplay; + info.src_config.pos.x = layer_output_mode->hdisplay / 2; + info.src_config.pos.y = layer_output_mode->vdisplay / 2; info.src_config.pos.w = info.src_config.size.h / 2; info.src_config.pos.h = info.src_config.size.v / 2; - info.src_config.format = formats[f]; + info.src_config.format = layer_formats[f]; info.dst_pos.x = info.src_config.pos.x; info.dst_pos.y = info.src_config.pos.y; info.dst_pos.w = info.src_config.pos.w; info.dst_pos.h = info.src_config.pos.h; info.transform = TDM_TRANSFORM_NORMAL; - EXPECT_EQ(tdm_layer_set_info(layer, &info), TDM_ERROR_NONE); - /* set buffer & commit for TDM_UT_BACKEND_TEST_CNT times */ - for (int t = 0; t < TDM_UT_BACKEND_TEST_CNT; t++) { - tbm_surface_h displaying_buffer; - EXPECT_EQ(tdm_layer_set_buffer(layer, buffers[next_buffer]), TDM_ERROR_NONE); - done = false; - EXPECT_EQ(tdm_output_commit(output, 0, _tc_tdm_backend_output_commit_cb, &done), TDM_ERROR_NONE); - while (!done) - EXPECT_EQ(tc_tdm_display_handle_events(dpy), TDM_ERROR_NONE); - displaying_buffer = tdm_layer_get_displaying_buffer(layer, &ret); - EXPECT_EQ(ret, TDM_ERROR_NONE); - EXPECT_EQ(displaying_buffer, buffers[next_buffer]); - next_buffer++; - if (next_buffer == 3) - next_buffer = 0; - } + EXPECT_EQ(_tc_tdm_backend_display_layer_test(dpy, layer_output, layer, &info, buffers, TDM_UT_BACKEND_TEST_CNT, false), true); DestroyBuffers(); TDM_UT_ASK_YNR("* Successed to crop '%c%c%c%c' frames and display it? (output: %d, layer: %d)", - FOURCC_STR(formats[f]), pipe, l); + FOURCC_STR(layer_formats[f]), layer_output_pipe, l); } EXPECT_EQ(tdm_layer_unset_buffer(layer), TDM_ERROR_NONE); -- 2.7.4 From a5ee0f359144d666c1813158a786f21f4066f3d8 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Mon, 4 Jul 2022 14:46:08 +0900 Subject: [PATCH 09/16] haltest/backend_capture: Remove duplicate code Change-Id: Ie16363ad898dcb72874ce98e9542ff80fab72da7 --- haltests/src/tc_tdm_backend_capture.cpp | 171 ++++++++++++-------------------- 1 file changed, 66 insertions(+), 105 deletions(-) diff --git a/haltests/src/tc_tdm_backend_capture.cpp b/haltests/src/tc_tdm_backend_capture.cpp index 0e23486..8b2ede9 100644 --- a/haltests/src/tc_tdm_backend_capture.cpp +++ b/haltests/src/tc_tdm_backend_capture.cpp @@ -67,6 +67,7 @@ public: void TearDown(void); bool FindLayer(int output_idx, tbm_format fmt, tdm_pos *punch); + bool DstPosPrepare(int output_idx, bool half); bool TestPrepareDefault(void); bool TestPrepare(int output_idx, int w, int h, tbm_format fmt, tdm_transform t, tdm_capture_type c, int frequency, bool stretch); void TestDone(void); @@ -157,7 +158,14 @@ bool TDMBackendCapture::FindLayer(int output_idx, tbm_format fmt, tdm_pos *punch tdm_error ret; int count; int primary_zpos, zpos; - tdm_layer *primary = tc_tdm_output_get_primary_layer(outputs[output_idx]); + tdm_layer *primary; + + if (tc_tdm_output_is_hwc_enable(outputs[output_idx])) { + dst_layer = NULL; + return false; + } + + primary = tc_tdm_output_get_primary_layer(outputs[output_idx]); TDM_UT_RETURN_FALSE_IF_FAIL(primary != NULL); TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_layer_count(outputs[output_idx], &count) == TDM_ERROR_NONE); TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_zpos(primary, &primary_zpos) == TDM_ERROR_NONE); @@ -205,6 +213,30 @@ bool TDMBackendCapture::FindLayer(int output_idx, tbm_format fmt, tdm_pos *punch return true; } +bool TDMBackendCapture::DstPosPrepare(int output_idx, bool half) +{ + const tdm_output_mode *mode; + int half_size; + + TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_mode(outputs[output_idx], &mode) == TDM_ERROR_NONE); + + if (half) { + half_size = ((mode->hdisplay <= mode->vdisplay) ? mode->hdisplay : mode->vdisplay) / 2; + + dst_pos.x = (mode->hdisplay - half_size) / 2; + dst_pos.y = (mode->vdisplay - half_size) / 2; + dst_pos.w = half_size; + dst_pos.h = half_size; + } else { + dst_pos.x = 0; + dst_pos.y = 0; + dst_pos.w = mode->hdisplay; + dst_pos.h = mode->vdisplay; + } + + return true; +} + bool TDMBackendCapture::TestPrepareDefault(void) { tdm_error ret; @@ -577,10 +609,7 @@ TEST_P(TDMBackendCapture, CaptureAttach) continue; for (int f = 0; f < format_count; f++) { - if (tc_tdm_output_is_hwc_enable(outputs[o])) - dst_layer = NULL; - else - FindLayer(o, formats[f], &dst_pos); + FindLayer(o, formats[f], &dst_pos); EXPECT_EQ(TestPrepare(o, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f], TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, false), true); @@ -673,10 +702,7 @@ TEST_P(TDMBackendCapture, CaptureDestroyWithoutCommit) EXPECT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE); - if (tc_tdm_output_is_hwc_enable(outputs[o])) - dst_layer = NULL; - else - FindLayer(o, formats[f], &dst_pos); + FindLayer(o, formats[f], &dst_pos); EXPECT_EQ(TestPrepare(o, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f], TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, false), true); @@ -707,10 +733,7 @@ TEST_P(TDMBackendCapture, CaptureDestroyBeforeDone) EXPECT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE); - if (tc_tdm_output_is_hwc_enable(outputs[o])) - dst_layer = NULL; - else - FindLayer(o, formats[f], &dst_pos); + FindLayer(o, formats[f], &dst_pos); EXPECT_EQ(TestPrepare(o, TDM_UT_BUFFER_SIZE, TDM_UT_BUFFER_SIZE, formats[f], TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, false), true); @@ -738,35 +761,22 @@ TEST_P(TDMBackendCapture, CaptureOneshotLetterboxSize) bool done; for (int o = 0; o < output_count; o++) { - const tdm_output_mode *mode = NULL; - if (!tc_tdm_output_is_connected(outputs[o])) continue; - EXPECT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE); + EXPECT_EQ(DstPosPrepare(o, true), true); for (int f = 0; f < format_count; f++) { - int half_size = ((mode->hdisplay <= mode->vdisplay) ? mode->hdisplay : mode->vdisplay) / 2; - - dst_pos.x = (mode->hdisplay - half_size) / 2; - dst_pos.y = (mode->vdisplay - half_size) / 2; - dst_pos.w = half_size; - dst_pos.h = half_size; - TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f])); - if (tc_tdm_output_is_hwc_enable(outputs[o])) - dst_layer = NULL; - else { - FindLayer(o, formats[f], &dst_pos); + FindLayer(o, formats[f], &dst_pos); - if (!dst_layer) { - TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f])); - continue; - } + if (!dst_layer && !tc_tdm_output_is_hwc_enable(outputs[o])) { + TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f])); + continue; } - EXPECT_EQ(TestPrepare(o, half_size, half_size, formats[f], + EXPECT_EQ(TestPrepare(o, dst_pos.w, dst_pos.h, formats[f], TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, false), true); EXPECT_EQ(tdm_capture_set_done_handler(capture, _tc_tdm_capture_done_cb, &done), TDM_ERROR_NONE); @@ -811,35 +821,23 @@ TEST_P(TDMBackendCapture, CaptureOneshotFullSize) bool done; for (int o = 0; o < output_count; o++) { - const tdm_output_mode *mode = NULL; if (!tc_tdm_output_is_connected(outputs[o])) continue; - EXPECT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE); + EXPECT_EQ(DstPosPrepare(o, true), true); for (int f = 0; f < format_count; f++) { - int half_size = ((mode->hdisplay <= mode->vdisplay) ? mode->hdisplay : mode->vdisplay) / 2; - - dst_pos.x = (mode->hdisplay - half_size) / 2; - dst_pos.y = (mode->vdisplay - half_size) / 2; - dst_pos.w = half_size; - dst_pos.h = half_size; - TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f])); - if (tc_tdm_output_is_hwc_enable(outputs[o])) - dst_layer = NULL; - else { - FindLayer(o, formats[f], &dst_pos); + FindLayer(o, formats[f], &dst_pos); - if (!dst_layer) { - TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f])); - continue; - } + if (!dst_layer && !tc_tdm_output_is_hwc_enable(outputs[o])) { + TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f])); + continue; } - EXPECT_EQ(TestPrepare(o, half_size, half_size, formats[f], + EXPECT_EQ(TestPrepare(o, dst_pos.w, dst_pos.h, formats[f], TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, true), true); EXPECT_EQ(tdm_capture_set_done_handler(capture, _tc_tdm_capture_done_cb, &done), TDM_ERROR_NONE); @@ -884,35 +882,23 @@ TEST_P(TDMBackendCapture, CaptureOneshotAttachFewTimesInOneCommit) int done; for (int o = 0; o < output_count; o++) { - const tdm_output_mode *mode = NULL; if (!tc_tdm_output_is_connected(outputs[o])) continue; - EXPECT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE); + EXPECT_EQ(DstPosPrepare(o, true), true); for (int f = 0; f < format_count; f++) { - int half_size = ((mode->hdisplay <= mode->vdisplay) ? mode->hdisplay : mode->vdisplay) / 2; - - dst_pos.x = (mode->hdisplay - half_size) / 2; - dst_pos.y = (mode->vdisplay - half_size) / 2; - dst_pos.w = half_size; - dst_pos.h = half_size; - TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f])); - if (tc_tdm_output_is_hwc_enable(outputs[o])) - dst_layer = NULL; - else { - FindLayer(o, formats[f], &dst_pos); + FindLayer(o, formats[f], &dst_pos); - if (!dst_layer) { - TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f])); - continue; - } + if (!dst_layer && !tc_tdm_output_is_hwc_enable(outputs[o])) { + TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f])); + continue; } - EXPECT_EQ(TestPrepare(o, half_size, half_size, formats[f], + EXPECT_EQ(TestPrepare(o, dst_pos.w, dst_pos.h, formats[f], TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_ONESHOT, -1, false), true); done = 0; @@ -996,35 +982,23 @@ TEST_P(TDMBackendCapture, CaptureStreamLetterboxSize) TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_STREAM); for (int o = 0; o < output_count; o++) { - const tdm_output_mode *mode = NULL; if (!tc_tdm_output_is_connected(outputs[o])) continue; - EXPECT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE); + EXPECT_EQ(DstPosPrepare(o, true), true); for (int f = 0; f < format_count; f++) { - int half_size = ((mode->hdisplay <= mode->vdisplay) ? mode->hdisplay : mode->vdisplay) / 2; - - dst_pos.x = (mode->hdisplay - half_size) / 2; - dst_pos.y = (mode->vdisplay - half_size) / 2; - dst_pos.w = half_size; - dst_pos.h = half_size; - TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f])); - if (tc_tdm_output_is_hwc_enable(outputs[o])) - dst_layer = NULL; - else { - FindLayer(o, formats[f], &dst_pos); + FindLayer(o, formats[f], &dst_pos); - if (!dst_layer) { - TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f])); - continue; - } + if (!dst_layer && !tc_tdm_output_is_hwc_enable(outputs[o])) { + TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f])); + continue; } - EXPECT_EQ(TestPrepare(o, half_size, half_size, formats[f], + EXPECT_EQ(TestPrepare(o, dst_pos.w, dst_pos.h, formats[f], TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_STREAM, -1, false), true); EXPECT_EQ(tdm_capture_set_done_handler(capture, _tc_tdm_capture_stream_done_cb, (void*)this), TDM_ERROR_NONE); @@ -1060,35 +1034,22 @@ TEST_P(TDMBackendCapture, CaptureStreamFullSize) TDM_UT_SKIP_FLAG(capabilities & TDM_CAPTURE_CAPABILITY_STREAM); for (int o = 0; o < output_count; o++) { - const tdm_output_mode *mode = NULL; - if (!tc_tdm_output_is_connected(outputs[o])) continue; - EXPECT_EQ(tdm_output_get_mode(outputs[o], &mode), TDM_ERROR_NONE); + EXPECT_EQ(DstPosPrepare(o, true), true); for (int f = 0; f < format_count; f++) { - int half_size = ((mode->hdisplay <= mode->vdisplay) ? mode->hdisplay : mode->vdisplay) / 2; - - dst_pos.x = (mode->hdisplay - half_size) / 2; - dst_pos.y = (mode->vdisplay - half_size) / 2; - dst_pos.w = half_size; - dst_pos.h = half_size; - TDM_UT_INFO("* testing for %c%c%c%c", FOURCC_STR(formats[f])); - if (tc_tdm_output_is_hwc_enable(outputs[o])) - dst_layer = NULL; - else { - FindLayer(o, formats[f], &dst_pos); + FindLayer(o, formats[f], &dst_pos); - if (!dst_layer) { - TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f])); - continue; - } + if (!dst_layer && !tc_tdm_output_is_hwc_enable(outputs[o])) { + TDM_UT_INFO("no proper layer for %c%c%c%c", FOURCC_STR(formats[f])); + continue; } - EXPECT_EQ(TestPrepare(o, half_size, half_size, formats[f], + EXPECT_EQ(TestPrepare(o, dst_pos.w, dst_pos.h, formats[f], TDM_TRANSFORM_NORMAL, TDM_CAPTURE_TYPE_STREAM, -1, true), true); EXPECT_EQ(tdm_capture_set_done_handler(capture, _tc_tdm_capture_stream_done_cb, (void*)this), TDM_ERROR_NONE); -- 2.7.4 From 1a815398d29963913549f5ec0e09268c39dff9e9 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Mon, 4 Jul 2022 17:38:20 +0900 Subject: [PATCH 10/16] haltest/layer: Remove duplicate code Change-Id: I94ae91b632c40f2e03ea24f7872fc55707c308b2 --- haltests/src/tc_tdm_layer.cpp | 42 +++++++----------------------------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/haltests/src/tc_tdm_layer.cpp b/haltests/src/tc_tdm_layer.cpp index 1e1aef6..68045a1 100644 --- a/haltests/src/tc_tdm_layer.cpp +++ b/haltests/src/tc_tdm_layer.cpp @@ -356,36 +356,7 @@ tc_tdm_layer_fill_info(tdm_layer *layer, tbm_surface_h buffer, tbm_surface_queue bool tc_tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer) { - tdm_info_layer old_info, info; - - TDM_UT_RETURN_FALSE_IF_FAIL(buffer != NULL); - - TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_info(layer, &old_info) == TDM_ERROR_NONE); - TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_layer_fill_info(layer, buffer, NULL, &info) == true); - - if (memcmp(&old_info, &info, sizeof info)) { - TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_set_info(layer, &info) == TDM_ERROR_NONE); - - tdm_output *output; - tdm_error ret; - int index = -1; - unsigned int pipe = 0; - output = tdm_layer_get_output(layer, &ret); - TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE); - TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_index(layer, &index) == TDM_ERROR_NONE); - TDM_UT_RETURN_FALSE_IF_FAIL(tdm_output_get_pipe(output, &pipe) == TDM_ERROR_NONE); - TDM_INFO("filling output(%d) layer(%d) info done: src_config(%dx%d: %d,%d %dx%d: %c%c%c%c) dst_pos(%d,%d %dx%d) transform(%s)", - pipe, index, - info.src_config.size.h, info.src_config.size.v, - info.src_config.pos.x, info.src_config.pos.y, info.src_config.pos.w, info.src_config.pos.h, - FOURCC_STR(info.src_config.format), - info.dst_pos.x, info.dst_pos.y, info.dst_pos.w, info.dst_pos.h, - tdm_transform_str(info.transform)); - } - - TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_set_buffer(layer, buffer) == TDM_ERROR_NONE); - - return true; + return tc_tdm_layer_set_buffer_with_pos(layer, buffer, NULL); } bool tc_tdm_layer_set_buffer_with_pos(tdm_layer *layer, tbm_surface_h buffer, tdm_pos *pos) @@ -393,15 +364,16 @@ bool tc_tdm_layer_set_buffer_with_pos(tdm_layer *layer, tbm_surface_h buffer, td tdm_info_layer old_info, info; TDM_UT_RETURN_FALSE_IF_FAIL(buffer != NULL); - TDM_UT_RETURN_FALSE_IF_FAIL(pos != NULL); TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_get_info(layer, &old_info) == TDM_ERROR_NONE); TDM_UT_RETURN_FALSE_IF_FAIL(tc_tdm_layer_fill_info(layer, buffer, NULL, &info) == true); - info.dst_pos.x = pos->x; - info.dst_pos.y = pos->y; - TDM_UT_RETURN_FALSE_IF_FAIL(info.dst_pos.w = pos->w); - TDM_UT_RETURN_FALSE_IF_FAIL(info.dst_pos.h = pos->h); + if (pos) { + info.dst_pos.x = pos->x; + info.dst_pos.y = pos->y; + TDM_UT_RETURN_FALSE_IF_FAIL(info.dst_pos.w = pos->w); + TDM_UT_RETURN_FALSE_IF_FAIL(info.dst_pos.h = pos->h); + } if (memcmp(&old_info, &info, sizeof info)) { TDM_UT_RETURN_FALSE_IF_FAIL(tdm_layer_set_info(layer, &info) == TDM_ERROR_NONE); -- 2.7.4 From 0527dc4d7ceca0ce5c2013e969c3641a8e07e09b Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Mon, 4 Jul 2022 19:24:50 +0900 Subject: [PATCH 11/16] haltest/client: Remove duplicate code Change-Id: I31311d011e5af46eb6a5323bdc9b0db402b9ca27 --- haltests/src/tc_tdm_client.cpp | 207 ++++++++++++++++------------------------- 1 file changed, 80 insertions(+), 127 deletions(-) diff --git a/haltests/src/tc_tdm_client.cpp b/haltests/src/tc_tdm_client.cpp index 2b5847a..ee35135 100644 --- a/haltests/src/tc_tdm_client.cpp +++ b/haltests/src/tc_tdm_client.cpp @@ -62,6 +62,7 @@ enum { static int _tc_tdm_pipe_read_msg(int fd); static bool _tc_tdm_pipe_write_msg(int fd, int reply_fd, int msg); static pid_t _tc_tdm_client_server_fork(int *pipe_to_parent, int *pipe_to_child); +static void _tc_tdm_client_server_kill(int *pipe_parent, int *pipe_child, pid_t server_pid); class TDMClient : public TDMEnv { @@ -112,28 +113,7 @@ void TDMClient::ServerFork(void) void TDMClient::ServerKill(void) { - if (pipe_child[0] >= 0) - close(pipe_child[0]); - if (pipe_child[1] >= 0) { - if (server_pid > 0) { - bool ret = _tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_TERMINATE_SERVER); - if (ret) { - if (waitpid(server_pid, NULL, 0) == server_pid) - TDM_INFO("*** server terminated ***"); - else - TDM_ERR("*** failed to terminate server ***"); - } else { - if (kill(server_pid, 9) < 0) - TDM_ERR("*** failed to kill server ***"); - } - } - close(pipe_child[1]); - } - - if (pipe_parent[0] >= 0) - close(pipe_parent[0]); - if (pipe_parent[1] >= 0) - close(pipe_parent[1]); + _tc_tdm_client_server_kill(pipe_parent, pipe_child, server_pid); server_pid = -1; pipe_parent[0] = pipe_parent[1] = -1; @@ -462,6 +442,33 @@ failed: } +static void +_tc_tdm_client_server_kill(int *pipe_parent, int *pipe_child, pid_t server_pid) +{ + if (pipe_child[0] >= 0) + close(pipe_child[0]); + if (pipe_child[1] >= 0) { + if (server_pid > 0) { + bool ret = _tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_TERMINATE_SERVER); + if (ret) { + if (waitpid(server_pid, NULL, 0) == server_pid) + TDM_INFO("*** server terminated ***"); + else + TDM_ERR("*** failed to terminate server ***"); + } else { + if (kill(server_pid, 9) < 0) + TDM_ERR("*** failed to kill server ***"); + } + } + close(pipe_child[1]); + } + + if (pipe_parent[0] >= 0) + close(pipe_parent[0]); + if (pipe_parent[1] >= 0) + close(pipe_parent[1]); +} + static void _tc_tdm_client_sig_handler(int sig) { TDM_UT_ERR("got signal: %d", sig); @@ -1163,6 +1170,31 @@ TEST_P(TDMClient, ClientVblankWaitInterval0) EXPECT_EQ(tdm_client_vblank_wait(vblank, 0, _tc_tdm_client_vblank_cb2, NULL), TDM_ERROR_INVALID_PARAMETER); } +static void +_tc_tdm_client_print_vblank_info(double start, double end, int vrefresh_interval, int t) +{ + /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */ + //EXPECT_GT((end - start), (vrefresh_interval * (t - 1))); + double a = end - start; + double b = vrefresh_interval * (t - 1); + if (a > b) + std::cout << "\033[0;35m" + << "==> Error: " + << "\033[0;33m" + << "Expected: ((end - start) > (vrefresh_interval * (t - 1))), " + << "actual: " << a << " vs " << b << "\033[0;0m" << std::endl; + + //EXPECT_LT((end - start), (vrefresh_interval * t + vrefresh_interval)); + a = end - start; + b = vrefresh_interval * t + vrefresh_interval; + if (a < b) + std::cout << "\033[0;35m" + << "==> Error: " + << "\033[0;33m" + << "Expected: ((end - start) < (vrefresh_interval * t + vrefresh_interval)), " + << "actual: " << a << " vs " << b << "\033[0;0m" << std::endl; +} + TEST_P(TDMClient, ClientVblankWaitInterval) { bool done; @@ -1181,26 +1213,7 @@ TEST_P(TDMClient, ClientVblankWaitInterval) EXPECT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE); end = tdm_helper_get_time(); - /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */ - //EXPECT_GT((end - start), (vrefresh_interval * (t - 1))); - double a = end - start; - double b = vrefresh_interval * (t - 1); - if (a > b) - std::cout << "\033[0;35m" - << "==> Error: " - << "\033[0;33m" - << "Expected: ((end - start) > (vrefresh_interval * (t - 1))), " - << "actual: " << a << " vs " << b << "\033[0;0m" << std::endl; - - //EXPECT_LT((end - start), (vrefresh_interval * t + vrefresh_interval)); - a = end - start; - b = vrefresh_interval * t + vrefresh_interval; - if (a < b) - std::cout << "\033[0;35m" - << "==> Error: " - << "\033[0;33m" - << "Expected: ((end - start) < (vrefresh_interval * t + vrefresh_interval)), " - << "actual: " << a << " vs " << b << "\033[0;0m" << std::endl; + _tc_tdm_client_print_vblank_info(start, end, vrefresh_interval, t); } } @@ -1261,26 +1274,7 @@ TEST_P(TDMClient, ClientVblankWaitSeqInterval) EXPECT_EQ(tdm_client_handle_events_timeout(client, 3000), TDM_ERROR_NONE); end = tdm_helper_get_time(); - /* "+ vrefresh_interval" consider the delay of socket communication between kernel and platform */ - //EXPECT_GT((end - start), (vrefresh_interval * (t - 1))); - double a = end - start; - double b = vrefresh_interval * (t - 1); - if (a > b) - std::cout << "\033[0;35m" - << "==> Error: " - << "\033[0;33m" - << "Expected: ((end - start) > (vrefresh_interval * (t - 1))), " - << "actual: " << a << " vs " << b << "\033[0;0m" << std::endl; - - //EXPECT_LT((end - start), (vrefresh_interval * t + vrefresh_interval)); - a = end - start; - b = vrefresh_interval * t + vrefresh_interval; - if (a < b) - std::cout << "\033[0;35m" - << "==> Error: " - << "\033[0;33m" - << "Expected: ((end - start) < (vrefresh_interval * t + vrefresh_interval)), " - << "actual: " << a << " vs " << b << "\033[0;0m" << std::endl; + _tc_tdm_client_print_vblank_info(start, end, vrefresh_interval, t); } } @@ -1568,6 +1562,7 @@ public: static void SetUpTestCase(); static void TearDownTestCase(); static bool PrepareVOutput(void); + static bool ConnectVOutput(unsigned int mmWidth, unsigned int mmHeight, int mode_count); protected: static tdm_client *client; @@ -1593,28 +1588,7 @@ tdm_client_voutput* TDMVirtualOutput::voutput = nullptr; void TDMVirtualOutput::ServerKill(void) { - if (pipe_child[0] >= 0) - close(pipe_child[0]); - if (pipe_child[1] >= 0) { - if (server_pid > 0) { - bool ret = _tc_tdm_pipe_write_msg(pipe_child[1], pipe_parent[0], TDM_UT_PIPE_MSG_TERMINATE_SERVER); - if (ret) { - if (waitpid(server_pid, NULL, 0) == server_pid) - TDM_INFO("*** server terminated ***"); - else - TDM_ERR("*** failed to terminate server ***"); - } else { - if (kill(server_pid, 9) < 0) - TDM_ERR("*** failed to kill server ***"); - } - } - close(pipe_child[1]); - } - - if (pipe_parent[0] >= 0) - close(pipe_parent[0]); - if (pipe_parent[1] >= 0) - close(pipe_parent[1]); + _tc_tdm_client_server_kill(pipe_parent, pipe_child, server_pid); server_pid = -1; pipe_parent[0] = pipe_parent[1] = -1; @@ -1704,6 +1678,24 @@ _tc_tdm_client_virutual_make_available_mode(tdm_client_output_mode *modes, int c } } +bool TDMVirtualOutput::ConnectVOutput(unsigned int mmWidth, unsigned int mmHeight, int mode_count) +{ + tdm_client_output_mode modes[mode_count]; + tdm_error ret; + + ret = tdm_client_voutput_set_physical_size(voutput, mmWidth, mmHeight); + TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE); + + _tc_tdm_client_virutual_make_available_mode(modes, mode_count); + ret = tdm_client_voutput_set_available_modes(voutput, modes, mode_count); + TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE); + + ret = tdm_client_voutput_connect(voutput); + TDM_UT_RETURN_FALSE_IF_FAIL(ret == TDM_ERROR_NONE); + + return true; +} + TEST_F(TDMVirtualOutput, SetAvailableModes) { tdm_error ret; @@ -1894,8 +1886,6 @@ TEST_F(TDMVirtualOutput, ConnectDisconnect) tdm_error ret; tdm_client_output *output; unsigned int mmWidth = 300, mmHeight = 150; - tdm_client_output_mode modes[this->MODE_COUNT]; - int count = this->MODE_COUNT; int virtual_conf; bool done = false; bool done2 = false; @@ -1917,15 +1907,7 @@ TEST_F(TDMVirtualOutput, ConnectDisconnect) ret = tdm_client_output_add_change_handler(output, _tc_voutput_output_handler_cb2, &done2); EXPECT_EQ(ret, TDM_ERROR_NONE); - ret = tdm_client_voutput_set_physical_size(this->voutput, mmWidth, mmHeight); - EXPECT_EQ(ret, TDM_ERROR_NONE); - - _tc_tdm_client_virutual_make_available_mode(modes, count); - ret = tdm_client_voutput_set_available_modes(this->voutput, modes, count); - EXPECT_EQ(ret, TDM_ERROR_NONE); - - ret = tdm_client_voutput_connect(this->voutput); - EXPECT_EQ(ret, TDM_ERROR_NONE); + EXPECT_EQ(ConnectVOutput(mmWidth, mmHeight, this->MODE_COUNT), true); while (!done) EXPECT_EQ(tdm_client_handle_events_timeout(this->client, 3000), TDM_ERROR_NONE); @@ -1945,7 +1927,6 @@ TEST_F(TDMVirtualOutput, SetMode) tdm_error ret; tdm_client_output *output; unsigned int mmWidth = 300, mmHeight = 150; - tdm_client_output_mode modes[this->MODE_COUNT]; int count = this->MODE_COUNT; int virtual_conf; bool done = false; @@ -1970,15 +1951,7 @@ TEST_F(TDMVirtualOutput, SetMode) ret = tdm_client_output_add_change_handler(output, _tc_voutput_output_handler_cb3, &done3); EXPECT_EQ(ret, TDM_ERROR_NONE); - ret = tdm_client_voutput_set_physical_size(this->voutput, mmWidth, mmHeight); - EXPECT_EQ(ret, TDM_ERROR_NONE); - - _tc_tdm_client_virutual_make_available_mode(modes, count); - ret = tdm_client_voutput_set_available_modes(this->voutput, modes, count); - EXPECT_EQ(ret, TDM_ERROR_NONE); - - ret = tdm_client_voutput_connect(this->voutput); - EXPECT_EQ(ret, TDM_ERROR_NONE); + EXPECT_EQ(ConnectVOutput(mmWidth, mmHeight, this->MODE_COUNT), true); while (!done) EXPECT_EQ(tdm_client_handle_events_timeout(this->client, 3000), TDM_ERROR_NONE); @@ -2003,8 +1976,6 @@ TEST_F(TDMVirtualOutput, SetModeNullObject) { tdm_error ret; unsigned int mmWidth = 300, mmHeight = 150; - tdm_client_output_mode modes[this->MODE_COUNT]; - int count = this->MODE_COUNT; int virtual_conf; if (this->voutput == NULL) { @@ -2014,15 +1985,7 @@ TEST_F(TDMVirtualOutput, SetModeNullObject) return; } - ret = tdm_client_voutput_set_physical_size(this->voutput, mmWidth, mmHeight); - EXPECT_EQ(ret, TDM_ERROR_NONE); - - _tc_tdm_client_virutual_make_available_mode(modes, count); - ret = tdm_client_voutput_set_available_modes(this->voutput, modes, count); - EXPECT_EQ(ret, TDM_ERROR_NONE); - - ret = tdm_client_voutput_connect(this->voutput); - EXPECT_EQ(ret, TDM_ERROR_NONE); + EXPECT_EQ(ConnectVOutput(mmWidth, mmHeight, this->MODE_COUNT), true); tdm_client_handle_events_timeout(this->client, 50); @@ -2038,8 +2001,6 @@ TEST_F(TDMVirtualOutput, SetModeInvalidIndex) { tdm_error ret; unsigned int mmWidth = 300, mmHeight = 150; - tdm_client_output_mode modes[this->MODE_COUNT]; - int count = this->MODE_COUNT; int virtual_conf; if (this->voutput == NULL) { @@ -2049,15 +2010,7 @@ TEST_F(TDMVirtualOutput, SetModeInvalidIndex) return; } - ret = tdm_client_voutput_set_physical_size(this->voutput, mmWidth, mmHeight); - EXPECT_EQ(ret, TDM_ERROR_NONE); - - _tc_tdm_client_virutual_make_available_mode(modes, count); - ret = tdm_client_voutput_set_available_modes(this->voutput, modes, count); - EXPECT_EQ(ret, TDM_ERROR_NONE); - - ret = tdm_client_voutput_connect(this->voutput); - EXPECT_EQ(ret, TDM_ERROR_NONE); + EXPECT_EQ(ConnectVOutput(mmWidth, mmHeight, this->MODE_COUNT), true); tdm_client_handle_events_timeout(this->client, 50); -- 2.7.4 From e34df6ba2dd29732ff443666571e956e2238fd6d Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Tue, 5 Jul 2022 13:39:06 +0900 Subject: [PATCH 12/16] tdm_server: Remove duplicate code Change-Id: I04f6bc9b4064589e1609d78ceded9b8a08bbc96e --- src/tdm_server.c | 81 ++++++++++++++++++++------------------------------------ 1 file changed, 28 insertions(+), 53 deletions(-) diff --git a/src/tdm_server.c b/src/tdm_server.c index 7e8fb20..903a659 100644 --- a/src/tdm_server.c +++ b/src/tdm_server.c @@ -126,6 +126,11 @@ typedef struct _tdm_server_client_info { struct wl_resource *resource; } tdm_server_client_info; +typedef enum { + VBLANK_WAIT_TYPE_INTERVAL, + VBLANK_WAIT_TYPE_SEQUENCE, +} tdm_server_vblank_wait_type; + static tdm_private_server *keep_private_server; static struct list_head client_list; @@ -415,10 +420,9 @@ _tdm_server_vblank_cb_set_enable_fake(struct wl_client *client, struct wl_resour } static void -_tdm_server_vblank_cb_wait_vblank(struct wl_client *client, struct wl_resource *resource, - uint32_t interval, uint32_t req_id, uint32_t req_sec, uint32_t req_usec) +_tdm_server_vblank_wait_vblank(tdm_server_vblank_info *vblank_info, tdm_server_vblank_wait_type wait_type, + uint32_t wait_value, uint32_t req_id, uint32_t req_sec, uint32_t req_usec) { - tdm_server_vblank_info *vblank_info = wl_resource_get_user_data(resource); tdm_server_output_info *output_info = vblank_info->output_info; tdm_private_server *private_server = output_info->private_server; tdm_private_loop *private_loop = private_server->private_loop; @@ -448,7 +452,11 @@ _tdm_server_vblank_cb_wait_vblank(struct wl_client *client, struct wl_resource * if (tdm_ttrace_module & TDM_TTRACE_SERVER_VBLANK) TDM_TRACE_ASYNC_BEGIN((int)wait_info->req_time, "TDM_Server_Vblank:%u", vblank_info->stamp); - ret = tdm_vblank_wait(vblank_info->vblank, req_sec, req_usec, interval, _tdm_server_cb_vblank, wait_info); + if (wait_type == VBLANK_WAIT_TYPE_INTERVAL) + ret = tdm_vblank_wait(vblank_info->vblank, req_sec, req_usec, wait_value, _tdm_server_cb_vblank, wait_info); + else + ret = tdm_vblank_wait_seq(vblank_info->vblank, req_sec, req_usec, wait_value, _tdm_server_cb_vblank, wait_info); + tdm_vblank_get_enable_fake(vblank_info->vblank, &enable_fake); if (!enable_fake && ret == TDM_ERROR_DPMS_OFF) @@ -456,71 +464,38 @@ _tdm_server_vblank_cb_wait_vblank(struct wl_client *client, struct wl_resource * TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, wait_failed); - tdm_display_lock(private_loop->dpy); - _tdm_server_vblank_timeout_update(vblank_info, 1000); - tdm_display_unlock(private_loop->dpy); + if (wait_type == VBLANK_WAIT_TYPE_INTERVAL) { + tdm_display_lock(private_loop->dpy); + _tdm_server_vblank_timeout_update(vblank_info, 1000); + tdm_display_unlock(private_loop->dpy); + } return; + wait_failed: /* LCOV_EXCL_START */ - wl_tdm_vblank_send_done(vblank_info->resource, req_id, 0, 0, 0, ret); if (wait_info) destroy_wait(wait_info); - /* LCOV_EXCL_STOP */ } static void -_tdm_server_vblank_cb_wait_vblank_seq(struct wl_client *client, struct wl_resource *resource, - uint32_t sequence, uint32_t req_id, uint32_t req_sec, uint32_t req_usec) +_tdm_server_vblank_cb_wait_vblank(struct wl_client *client, struct wl_resource *resource, + uint32_t interval, uint32_t req_id, uint32_t req_sec, uint32_t req_usec) { tdm_server_vblank_info *vblank_info = wl_resource_get_user_data(resource); - tdm_server_output_info *output_info = vblank_info->output_info; - tdm_private_server *private_server = output_info->private_server; - tdm_server_wait_info *wait_info; - unsigned int enable_fake = 0; - tdm_error ret; - - wait_info = calloc(1, sizeof * wait_info); - if (!wait_info) { - /* LCOV_EXCL_START */ - - TDM_ERR("alloc failed"); - ret = TDM_ERROR_OUT_OF_MEMORY; - goto wait_failed; - /* LCOV_EXCL_STOP */ - } - - LIST_ADDTAIL(&wait_info->link, &private_server->wait_list); - wait_info->vblank_info = vblank_info; - wait_info->req_id = req_id; - wait_info->req_time = TDM_TIME(req_sec, req_usec); - - if (tdm_debug_module & TDM_DEBUG_VBLANK) - TDM_DBG("req_id(%d) wait", req_id); - - if (tdm_ttrace_module & TDM_TTRACE_SERVER_VBLANK) - TDM_TRACE_ASYNC_BEGIN((int)wait_info->req_time, "TDM_Server_Vblank:%u", vblank_info->stamp); - - ret = tdm_vblank_wait_seq(vblank_info->vblank, req_sec, req_usec, sequence, _tdm_server_cb_vblank, wait_info); - - tdm_vblank_get_enable_fake(vblank_info->vblank, &enable_fake); - if (!enable_fake && ret == TDM_ERROR_DPMS_OFF) - goto wait_failed; - - TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, wait_failed); - - return; -wait_failed: - /* LCOV_EXCL_START */ + _tdm_server_vblank_wait_vblank(vblank_info, VBLANK_WAIT_TYPE_INTERVAL, interval, req_id, req_sec, req_usec); +} - wl_tdm_vblank_send_done(vblank_info->resource, req_id, 0, 0, 0, ret); - if (wait_info) - destroy_wait(wait_info); +static void +_tdm_server_vblank_cb_wait_vblank_seq(struct wl_client *client, struct wl_resource *resource, + uint32_t sequence, uint32_t req_id, uint32_t req_sec, uint32_t req_usec) +{ + tdm_server_vblank_info *vblank_info = wl_resource_get_user_data(resource); - /* LCOV_EXCL_STOP */ + _tdm_server_vblank_wait_vblank(vblank_info, VBLANK_WAIT_TYPE_SEQUENCE, sequence, req_id, req_sec, req_usec); } static const struct wl_tdm_vblank_interface tdm_vblank_implementation = { -- 2.7.4 From 89a0317441d3013c36701e890281b2ca7efa12e4 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Thu, 7 Jul 2022 19:12:28 +0900 Subject: [PATCH 13/16] Package version up to 3.1.2 Change-Id: I4b6118735c84f22b904f979ae4194a93ac9c83ac --- packaging/libtdm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index ce44a4f..fcf9ab5 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -2,7 +2,7 @@ %define HALTESTS_GCOV 0 Name: libtdm -Version: 3.1.1 +Version: 3.1.2 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From 45494344b2cbb7678f7fc46601fb17421370b64d Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Tue, 6 Sep 2022 16:54:28 +0900 Subject: [PATCH 14/16] tdm_client: Fix leak of resource Change-Id: I69e700bf91da5d736377033c2c3825eaeb4b82bb --- client/tdm_client.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/client/tdm_client.c b/client/tdm_client.c index 0cf3df4..ddfc222 100644 --- a/client/tdm_client.c +++ b/client/tdm_client.c @@ -1814,9 +1814,6 @@ tdm_client_voutput_cb_buffer_import_with_fd(void *data, TDM_RETURN_IF_FAIL(private_voutput != NULL); - buffer = calloc(1, sizeof *buffer); - TDM_RETURN_IF_FAIL(buffer != NULL); - tbm_surface = _tdm_client_voutput_create_surface_from_param(private_voutput->bufmgr, 1, width, height, format, bpp, size, num_plane, -- 2.7.4 From e20b4e7c5839e5cb95b71f6d403a455c10edcbd2 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Tue, 6 Sep 2022 16:54:54 +0900 Subject: [PATCH 15/16] Package version up to 3.1.3 Change-Id: Iff92bed45ac4827d7609829ec3b8aed28c7d61b2 --- packaging/libtdm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index fcf9ab5..981f2a3 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -2,7 +2,7 @@ %define HALTESTS_GCOV 0 Name: libtdm -Version: 3.1.2 +Version: 3.1.3 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From 69195fef77d571b066093ce9913b079a2425a593 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Tue, 18 Oct 2022 17:06:10 +0900 Subject: [PATCH 16/16] Fix invalid assignment of sizeof Change-Id: I7672cf880560ccde35577a8f956b13a2b7b42bb0 --- client/tdm_client.c | 3 ++- src/tdm_server.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/client/tdm_client.c b/client/tdm_client.c index ddfc222..62eaf6e 100644 --- a/client/tdm_client.c +++ b/client/tdm_client.c @@ -2361,7 +2361,8 @@ _tdm_client_voutput_send_available_modes(tdm_private_client_voutput *private_vou { tdm_client_output_mode *modes, *mode; struct wl_array array; - int i, size; + int i; + size_t size; modes = private_voutput->available_modes.modes; size = sizeof(tdm_client_output_mode); diff --git a/src/tdm_server.c b/src/tdm_server.c index 903a659..a5274e1 100644 --- a/src/tdm_server.c +++ b/src/tdm_server.c @@ -809,7 +809,8 @@ _tdm_voutput_cb_set_available_modes(struct wl_client *client, { tdm_server_voutput_info *voutput_info; tdm_output_mode *mode; - int size, count = 0, i = 0; + int count = 0, i = 0; + size_t size; voutput_info = wl_resource_get_user_data(resource); -- 2.7.4