output: add debug logs
[platform/core/uifw/libtdm.git] / src / tdm_helper.c
index fc271fb..74d8bb5 100644 (file)
@@ -41,6 +41,7 @@
 #include <string.h>
 #include <tbm_surface.h>
 #include <tbm_surface_internal.h>
+#include <tbm_drm_helper.h>
 #include <string.h>
 #include <time.h>
 #include <pixman.h>
@@ -206,6 +207,7 @@ _tdm_helper_dump_png(const char *file, const void *data, int width,
        fclose(fp);
 }
 
+/* LCOV_EXCL_START */
 INTERN char *
 tdm_helper_dump_make_directory(const char *path, char *reply, int *len)
 {
@@ -271,6 +273,7 @@ tdm_helper_dump_buffer_str(tbm_surface_h buffer, char *dir, char *str)
 
        tdm_helper_dump_buffer(buffer, file);
 }
+/* LCOV_EXCL_STOP */
 
 EXTERN void
 tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file)
@@ -577,83 +580,29 @@ unmap_srcbuf:
        return ret;
 }
 
+/* LCOV_EXCL_START */
 EXTERN int
 tdm_helper_get_fd(const char *env)
 {
-       const char *value;
-       int fd, newfd, flags, ret;
-       char *end;
-       errno = 0;
-
-       value = (const char*)getenv(env);
-       if (!value)
-               return -1;
-
-       const long int sl = strtol(value, &end, 10);
-       if (end == value) {
-               TDM_ERR("%s: not a decimal number\n", value);
-               return -1;
-       } else if (*end != '\0') {
-               TDM_ERR("%s: extra characters at end of input: %s\n", value, end);
-               return -1;
-       } else if ((sl == LONG_MIN || sl == LONG_MAX) && errno == ERANGE) {
-               TDM_ERR("%s out of range of type long\n", value);
-               return -1;
-       } else if (sl >= INT_MAX) {
-               TDM_ERR("%ld greater than INT_MAX\n", sl);
-               return -1;
-       } else if (sl <= INT_MIN) {
-               TDM_ERR("%ld less than INT_MIN\n", sl);
-               return -1;
-       } else {
-               fd = (int)sl;
-               if (fd < 0) {
-                       TDM_ERR("%d out of fd range\n", fd);
-                       return -1;
-               }
-       }
-
-       flags = fcntl(fd, F_GETFD);
-       if (flags == -1) {
-               TDM_ERR("fcntl failed: %m");
-               return -1;
-       }
-
-       newfd = dup(fd);
-       if (newfd < 0) {
-               TDM_ERR("dup failed: %m");
+       if (strncmp(env, "TBM_DRM_MASTER_FD", 17) && strncmp(env, "TDM_DRM_MASTER_FD", 17)) {
+               TDM_INFO("DEPRECATED! '%s'", env);
                return -1;
        }
 
-       TDM_INFO("%s: fd(%d) newfd(%d)", env, fd, newfd);
-
-       ret = fcntl(newfd, F_SETFD, flags | FD_CLOEXEC);
-       if (ret == -1) {
-               TDM_ERR("fcntl failed: %m");
-               close(newfd);
-               return -1;
-       }
-
-       return newfd;
+       return tbm_drm_helper_get_master_fd();
 }
 
 EXTERN void
 tdm_helper_set_fd(const char *env, int fd)
 {
-       char buf[32];
-       int ret;
-
-       snprintf(buf, sizeof(buf), "%d", fd);
-
-       ret = setenv(env, (const char*)buf, 1);
-       if (ret) {
-               TDM_ERR("setenv failed: %m");
+       if (strncmp(env, "TBM_DRM_MASTER_FD", 17) && strncmp(env, "TDM_DRM_MASTER_FD", 17)) {
+               TDM_INFO("DEPRECATED! '%s'", env);
                return;
        }
 
-       if (fd >= 0)
-               TDM_INFO("%s: fd(%d)", env, fd);
+       tbm_drm_helper_set_tbm_master_fd(fd);
 }
+/* LCOV_EXCL_STOP */
 
 EXTERN void
 tdm_helper_dump_start(char *dumppath, int *count)
@@ -676,6 +625,7 @@ tdm_helper_dump_stop(void)
        TDM_DBG("tdm_helper_dump stop.");
 }
 
+/* LCOV_EXCL_START */
 static tdm_error
 _tdm_helper_buffer_convert(tbm_surface_h srcbuf, tbm_surface_h dstbuf,
                                                   int dx, int dy, int dw, int dh, int count)
@@ -763,6 +713,8 @@ cant_convert:
 
        return TDM_ERROR_OPERATION_FAILED;
 }
+/* LCOV_EXCL_STOP */
+
 
 EXTERN tdm_error
 tdm_helper_capture_output(tdm_output *output, tbm_surface_h dst_buffer,
@@ -1116,15 +1068,23 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len)
        TDM_SNPRINTF(reply, len, "\n");
 }
 
+/* LCOV_EXCL_START */
 EXTERN int
 tdm_helper_commit_per_vblank_enabled(tdm_display *dpy)
 {
-       tdm_private_display *private_display;
+       TDM_ERR("the deprecated function, use 'tdm_helper_output_commit_per_vblank_enabled' instead.");
 
-       TDM_RETURN_VAL_IF_FAIL(dpy != NULL, 0);
+       return 0;
+}
+/* LCOV_EXCL_STOP */
 
-       private_display = dpy;
+EXTERN int
+tdm_helper_output_commit_per_vblank_enabled(tdm_output *output)
+{
+       tdm_private_output *private_output = output;
+
+       TDM_RETURN_VAL_IF_FAIL(private_output != NULL, -1);
 
-       return private_display->commit_per_vblank;
+       return !!private_output->commit_per_vblank;
 }