commit: add function to check whether commit-per-vblank is enabled 96/112596/1
authorBoram Park <boram1288.park@samsung.com>
Thu, 2 Feb 2017 01:31:54 +0000 (10:31 +0900)
committerBoram Park <boram1288.park@samsung.com>
Thu, 2 Feb 2017 01:32:27 +0000 (10:32 +0900)
Change-Id: Ib5b58f06c4fe11d81c0cfc61343e0b9ea676c6cb

include/tdm_helper.h
src/tdm.c
src/tdm_helper.c

index ba94a66..c80057d 100644 (file)
@@ -209,6 +209,14 @@ tdm_helper_capture_output(tdm_output *output, tbm_surface_h dst_buffer,
 void
 tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len);
 
+/**
+ * @brief Get whether the commit-per-vblank functionality is enabled or not.
+ * @param[in] dpy A display object
+ * @return 1 if enabled. Otherwise, 0.
+ */
+int
+tdm_helper_commit_per_vblank_enabled(tdm_display *dpy);
+
 #ifdef __cplusplus
 }
 #endif
index 69a81c2..041d4c2 100644 (file)
--- a/src/tdm.c
+++ b/src/tdm.c
@@ -921,8 +921,12 @@ tdm_display_init(tdm_error *error)
                tdm_display_enable_path(str);
 
        str = getenv("TDM_COMMIT_PER_VBLANK");
-       if (str && (strstr(str, "1")))
-               tdm_display_enable_commit_per_vblank(private_display, 1);
+       if (str) {
+               char *end;
+               int enable = strtol(str, &end, 10);
+
+               tdm_display_enable_commit_per_vblank(private_display, enable);
+       }
 
        if (pthread_mutex_init(&private_display->lock, NULL)) {
                ret = TDM_ERROR_OPERATION_FAILED;
@@ -1298,14 +1302,16 @@ tdm_display_enable_commit_per_vblank(tdm_private_display *private_display, int e
 {
        private_display->commit_per_vblank = enable;
 
-       if (private_display->commit_per_vblank == 1)
+       if (private_display->commit_per_vblank == 0)
+               TDM_INFO("commit per vblank: disable");
+       else if (private_display->commit_per_vblank == 1)
                TDM_INFO("commit per vblank: enable (1 layer)");
        else if (private_display->commit_per_vblank == 2)
                TDM_INFO("commit per vblank: enable (previous commit)");
-       else if (private_display->commit_per_vblank > 0)
-               TDM_INFO("commit per vblank: enable (unknown)");
-       else
-               TDM_INFO("commit per vblank: disable");
+       else {
+               private_display->commit_per_vblank = 1;
+               TDM_INFO("commit per vblank: enable (changed to 1 layer)");
+       }
 
        return TDM_ERROR_NONE;
 }
index 87df714..06ecba4 100644 (file)
@@ -987,3 +987,16 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len)
 unlock:
        _pthread_mutex_unlock(&private_display->lock);
 }
+
+EXTERN int
+tdm_helper_commit_per_vblank_enabled(tdm_display *dpy)
+{
+       tdm_private_display *private_display;
+
+       TDM_RETURN_VAL_IF_FAIL(dpy != NULL, 0);
+
+       private_display = dpy;
+
+       return private_display->commit_per_vblank;
+}
+