From ea1924cbdffc6ba69cf537c97a1e78334512db80 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Wed, 23 Nov 2016 11:45:38 +0900 Subject: [PATCH] treat 0 also as a "not-defined" value Change-Id: I208c7bb8a151433dd808ccb4ccafe84315577318 --- include/tdm_backend.h | 54 +++++++++++++++++++++++---------------------------- src/tdm.c | 2 +- src/tdm_display.c | 42 +++++++++++++++++++-------------------- src/tdm_helper.c | 24 ++++++++++++++--------- src/tdm_macro.h | 3 +++ 5 files changed, 64 insertions(+), 61 deletions(-) diff --git a/include/tdm_backend.h b/include/tdm_backend.h index 9255c4a..0949372 100644 --- a/include/tdm_backend.h +++ b/include/tdm_backend.h @@ -85,7 +85,7 @@ typedef void (*tdm_output_dpms_handler)(tdm_output *output, * @see The display_get_capability() function of #tdm_func_display */ typedef struct _tdm_caps_display { - int max_layer_count; /**< The maximum layer count. -1 means "not defined" */ + int max_layer_count; /**< The maximum layer count */ } tdm_caps_display; /** @@ -112,19 +112,19 @@ typedef struct _tdm_caps_output { unsigned int mmHeight; /**< The physical height (milimeter) */ unsigned int subpixel; /**< The subpixel */ - int min_w; /**< The minimun width. -1 means "not defined" */ - int min_h; /**< The minimun height. -1 means "not defined" */ - int max_w; /**< The maximum width. -1 means "not defined" */ - int max_h; /**< The maximum height. -1 means "not defined" */ - int preferred_align; /**< The prefered align. -1 means "not defined" */ + int min_w; /**< The minimun width */ + int min_h; /**< The minimun height */ + int max_w; /**< The maximum width */ + int max_h; /**< The maximum height */ + int preferred_align; /**< The prefered align */ tdm_output_capability capabilities; /**< The capabilities of output. @since 1.4.1 */ - int cursor_min_w; /**< The minimun width. -1 means "not defined" @since 1.5.0 */ - int cursor_min_h; /**< The minimun height. -1 means "not defined" @since 1.5.0 */ - int cursor_max_w; /**< The maximum width. -1 means "not defined" @since 1.5.0 */ - int cursor_max_h; /**< The maximum height. -1 means "not defined" @since 1.5.0 */ - int cursor_preferred_align; /**< The prefered align. -1 means "not defined" @since 1.5.0 */ + int cursor_min_w; /**< The minimun width. @since 1.5.0 */ + int cursor_min_h; /**< The minimun height. @since 1.5.0 */ + int cursor_max_w; /**< The maximum width. @since 1.5.0 */ + int cursor_max_h; /**< The maximum height. @since 1.5.0 */ + int cursor_preferred_align; /**< The prefered align. @since 1.5.0 */ } tdm_caps_output; /** @@ -168,16 +168,13 @@ typedef struct _tdm_caps_pp { tbm_format *formats; /**< The @b newly-allocated array. will be freed in frontend. */ - int min_w; /**< The minimun width. -1 means "not defined" */ - int min_h; /**< The minimun height. -1 means "not defined" */ - int max_w; /**< The maximum width. -1 means "not defined" */ - int max_h; /**< The maximum height. -1 means "not defined" */ - int preferred_align; /**< The prefered align. -1 means "not defined" */ + int min_w; /**< The minimun width */ + int min_h; /**< The minimun height */ + int max_w; /**< The maximum width */ + int max_h; /**< The maximum height */ + int preferred_align; /**< The prefered align */ - /**< The attach count which a PP object can handle. - * -1 means "not defined". - * @since 1.2.0 - */ + /**< The attach count which a PP object can handle. @since 1.2.0 */ int max_attach_count; } tdm_caps_pp; @@ -192,16 +189,13 @@ typedef struct _tdm_caps_capture { tbm_format *formats; /**< The @b newly-allocated array of formats. will be freed in frontend. */ - int min_w; /**< The minimun width. -1 means "not defined" */ - int min_h; /**< The minimun height. -1 means "not defined" */ - int max_w; /**< The maximum width. -1 means "not defined" */ - int max_h; /**< The maximum height. -1 means "not defined" */ - int preferred_align; /**< The prefered align. -1 means "not defined" */ + int min_w; /**< The minimun width */ + int min_h; /**< The minimun height */ + int max_w; /**< The maximum width */ + int max_h; /**< The maximum height */ + int preferred_align; /**< The prefered align */ - /**< The attach count which a capture object can handle. - * -1 means "not defined". - * @since 1.2.0 - */ + /**< The attach count which a capture object can handle. @since 1.2.0 */ int max_attach_count; } tdm_caps_capture; @@ -220,7 +214,7 @@ typedef struct _tdm_func_display { * is connected.\n * If a hardware has the restriction of the number of max usable layer count, * a backend module can set the max count to max_layer_count of #tdm_caps_display - * structure. Otherwise, set -1. + * structure. */ tdm_error (*display_get_capability)(tdm_backend_data *bdata, tdm_caps_display *caps); diff --git a/src/tdm.c b/src/tdm.c index 74ebcb2..4918a22 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -213,7 +213,7 @@ _tdm_display_destroy_private_display(tdm_private_display *private_display) _tdm_display_destroy_caps_capture(&private_display->caps_capture); private_display->capabilities = 0; - private_display->caps_display.max_layer_count = -1; + private_display->caps_display.max_layer_count = 0; } static tdm_error diff --git a/src/tdm_display.c b/src/tdm_display.c index d240d97..a34daab 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -182,15 +182,15 @@ tdm_display_get_pp_available_size(tdm_display *dpy, int *min_w, int *min_h, } if (min_w) - *min_w = private_display->caps_pp.min_w; + *min_w = TDM_FRONT_VALUE(private_display->caps_pp.min_w); if (min_h) - *min_h = private_display->caps_pp.min_h; + *min_h = TDM_FRONT_VALUE(private_display->caps_pp.min_h); if (max_w) - *max_w = private_display->caps_pp.max_w; + *max_w = TDM_FRONT_VALUE(private_display->caps_pp.max_w); if (max_h) - *max_h = private_display->caps_pp.max_h; + *max_h = TDM_FRONT_VALUE(private_display->caps_pp.max_h); if (preferred_align) - *preferred_align = private_display->caps_pp.preferred_align; + *preferred_align = TDM_FRONT_VALUE(private_display->caps_pp.preferred_align); _pthread_mutex_unlock(&private_display->lock); @@ -260,15 +260,15 @@ tdm_display_get_capture_available_size(tdm_display *dpy, int *min_w, int *min_h, } if (min_w) - *min_w = private_display->caps_capture.min_w; + *min_w = TDM_FRONT_VALUE(private_display->caps_capture.min_w); if (min_h) - *min_h = private_display->caps_capture.min_h; + *min_h = TDM_FRONT_VALUE(private_display->caps_capture.min_h); if (max_w) - *max_w = private_display->caps_capture.max_w; + *max_w = TDM_FRONT_VALUE(private_display->caps_capture.max_w); if (max_h) - *max_h = private_display->caps_capture.max_h; + *max_h = TDM_FRONT_VALUE(private_display->caps_capture.max_h); if (preferred_align) - *preferred_align = private_display->caps_capture.preferred_align; + *preferred_align = TDM_FRONT_VALUE(private_display->caps_capture.preferred_align); _pthread_mutex_unlock(&private_display->lock); @@ -284,7 +284,7 @@ tdm_display_get_max_layer_count(tdm_display *dpy, int *max_count) _pthread_mutex_lock(&private_display->lock); - *max_count = private_display->caps_display.max_layer_count; + *max_count = TDM_FRONT_VALUE(private_display->caps_display.max_layer_count); _pthread_mutex_unlock(&private_display->lock); @@ -744,15 +744,15 @@ tdm_output_get_available_size(tdm_output *output, int *min_w, int *min_h, _pthread_mutex_lock(&private_display->lock); if (min_w) - *min_w = private_output->caps.min_w; + *min_w = TDM_FRONT_VALUE(private_output->caps.min_w); if (min_h) - *min_h = private_output->caps.min_h; + *min_h = TDM_FRONT_VALUE(private_output->caps.min_h); if (max_w) - *max_w = private_output->caps.max_w; + *max_w = TDM_FRONT_VALUE(private_output->caps.max_w); if (max_h) - *max_h = private_output->caps.max_h; + *max_h = TDM_FRONT_VALUE(private_output->caps.max_h); if (preferred_align) - *preferred_align = private_output->caps.preferred_align; + *preferred_align = TDM_FRONT_VALUE(private_output->caps.preferred_align); _pthread_mutex_unlock(&private_display->lock); @@ -786,15 +786,15 @@ tdm_output_get_cursor_available_size(tdm_output *output, int *min_w, int *min_h, } if (min_w) - *min_w = private_output->caps.cursor_min_w; + *min_w = TDM_FRONT_VALUE(private_output->caps.cursor_min_w); if (min_h) - *min_h = private_output->caps.cursor_min_h; + *min_h = TDM_FRONT_VALUE(private_output->caps.cursor_min_h); if (max_w) - *max_w = private_output->caps.cursor_max_w; + *max_w = TDM_FRONT_VALUE(private_output->caps.cursor_max_w); if (max_h) - *max_h = private_output->caps.cursor_max_h; + *max_h = TDM_FRONT_VALUE(private_output->caps.cursor_max_h); if (preferred_align) - *preferred_align = private_output->caps.cursor_preferred_align; + *preferred_align = TDM_FRONT_VALUE(private_output->caps.cursor_preferred_align); _pthread_mutex_unlock(&private_display->lock); diff --git a/src/tdm_helper.c b/src/tdm_helper.c index 999bd1a..f5e39b3 100644 --- a/src/tdm_helper.c +++ b/src/tdm_helper.c @@ -613,9 +613,11 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) tdm_status_str(private_output->caps.status), tdm_dpms_str(private_output->current_dpms_value), private_output->caps.subpixel, - private_output->caps.preferred_align, - private_output->caps.min_w, private_output->caps.min_h, - private_output->caps.max_w, private_output->caps.max_h, + TDM_FRONT_VALUE(private_output->caps.preferred_align), + TDM_FRONT_VALUE(private_output->caps.min_w), + TDM_FRONT_VALUE(private_output->caps.min_h), + TDM_FRONT_VALUE(private_output->caps.max_w), + TDM_FRONT_VALUE(private_output->caps.max_h), private_output->caps.mmWidth, private_output->caps.mmHeight); TDM_SNPRINTF(reply, len, "\t%d modes:\n", private_output->caps.mode_count); @@ -766,9 +768,11 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) } TDM_SNPRINTF(reply, len, "\n"); TDM_SNPRINTF(reply, len, "size\t: min(%dx%d) max(%dx%d) align_w(%d)\n", - private_display->caps_pp.min_w, private_display->caps_pp.min_h, - private_display->caps_pp.max_w, private_display->caps_pp.max_h, - private_display->caps_pp.preferred_align); + TDM_FRONT_VALUE(private_display->caps_pp.min_w), + TDM_FRONT_VALUE(private_display->caps_pp.min_h), + TDM_FRONT_VALUE(private_display->caps_pp.max_w), + TDM_FRONT_VALUE(private_display->caps_pp.max_h), + TDM_FRONT_VALUE(private_display->caps_pp.preferred_align)); if (!LIST_IS_EMPTY(&private_display->pp_list)) { TDM_SNPRINTF(reply, len, "-------------------------------------------------------------\n"); TDM_SNPRINTF(reply, len, "src(format size crop) | dst(format size crop) | transform\n"); @@ -808,9 +812,11 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) } TDM_SNPRINTF(reply, len, "\n"); TDM_SNPRINTF(reply, len, "size\t: min(%dx%d) max(%dx%d) align_w(%d)\n", - private_display->caps_capture.min_w, private_display->caps_capture.min_h, - private_display->caps_capture.max_w, private_display->caps_capture.max_h, - private_display->caps_capture.preferred_align); + TDM_FRONT_VALUE(private_display->caps_capture.min_w), + TDM_FRONT_VALUE(private_display->caps_capture.min_h), + TDM_FRONT_VALUE(private_display->caps_capture.max_w), + TDM_FRONT_VALUE(private_display->caps_capture.max_h), + TDM_FRONT_VALUE(private_display->caps_capture.preferred_align)); if (!LIST_IS_EMPTY(&private_display->capture_list)) { TDM_SNPRINTF(reply, len, "-----------------------------------\n"); TDM_SNPRINTF(reply, len, "dst(format size crop) | transform\n"); diff --git a/src/tdm_macro.h b/src/tdm_macro.h index 2bbadcf..61d8658 100644 --- a/src/tdm_macro.h +++ b/src/tdm_macro.h @@ -135,6 +135,9 @@ extern "C" { } \ } +#define TDM_NOT_DEFINED_VALUE (-1) +#define TDM_FRONT_VALUE(n) (((n) > 0) ? (n) : TDM_NOT_DEFINED_VALUE) + #define TDM_TIME(sec, usec) ((double)(sec) + ((double)(usec)) / 1000000.0) #define TDM_TIME_SEC(time) ((unsigned int)(time)) #define TDM_TIME_USEC(time) (unsigned int)(((time) - (unsigned int)(time)) * 1000000.0) -- 2.7.4