fix the too many logs when enabled 11/79611/2
authorBoram Park <boram1288.park@samsung.com>
Mon, 11 Jul 2016 07:24:56 +0000 (16:24 +0900)
committerBoram Park <boram1288.park@samsung.com>
Mon, 18 Jul 2016 01:19:43 +0000 (10:19 +0900)
Change-Id: I155b5fc09cc38d0786b5e66867b7565de51cf53e

src/tdm.c
src/tdm_buffer.c
src/tdm_capture.c
src/tdm_dbg_server.c
src/tdm_display.c
src/tdm_event_loop.c
src/tdm_pp.c
src/tdm_private.h
src/tdm_server.c
src/tdm_thread.c
src/tdm_vblank.c

index 0bbd7a7..d388f19 100644 (file)
--- a/src/tdm.c
+++ b/src/tdm.c
@@ -668,9 +668,7 @@ tdm_display_update(tdm_display *dpy)
 #define SUFFIX_MODULE    ".so"
 #define DEFAULT_MODULE   "libtdm-default"SUFFIX_MODULE
 
-int tdm_debug_buffer;
-int tdm_debug_thread;
-int tdm_debug_mutex;
+int tdm_debug_module;
 int tdm_debug_dump;
 
 static tdm_private_display *g_private_display;
@@ -901,22 +899,14 @@ tdm_display_init(tdm_error *error)
                return g_private_display;
        }
 
-       debug = getenv("TDM_DEBUG_BUFFER");
-       if (debug && (strstr(debug, "1")))
-               tdm_debug_buffer = 1;
+       debug = getenv("TDM_DEBUG_MODULE");
+       if (debug)
+               tdm_display_enable_debug_module(debug);
 
        debug = getenv("TDM_DEBUG_DUMP");
        if (debug)
                tdm_display_enable_dump(debug);
 
-       debug = getenv("TDM_DEBUG_THREAD");
-       if (debug && (strstr(debug, "1")))
-               tdm_debug_thread = 1;
-
-       debug = getenv("TDM_DEBUG_MUTEX");
-       if (debug && (strstr(debug, "1")))
-               tdm_debug_mutex = 1;
-
        private_display = calloc(1, sizeof(tdm_private_display));
        if (!private_display) {
                ret = TDM_ERROR_OUT_OF_MEMORY;
@@ -984,7 +974,6 @@ failed_event:
 failed_mutex_init:
        free(private_display);
 failed_alloc:
-       tdm_debug_buffer = 0;
        if (error)
                *error = ret;
        _pthread_mutex_unlock(&gLock);
@@ -1028,7 +1017,6 @@ tdm_display_deinit(tdm_display *dpy)
        pthread_mutex_destroy(&private_display->lock);
        free(private_display);
        g_private_display = NULL;
-       tdm_debug_buffer = 0;
 
        _pthread_mutex_unlock(&gLock);
 
@@ -1049,42 +1037,77 @@ tdm_display_check_module_abi(tdm_private_display *private_display, int abimaj, i
        return 1;
 }
 
-INTERN void
-tdm_display_enable_debug(char *debug, int enable)
+INTERN tdm_error
+tdm_display_enable_debug_module(const char*modules)
 {
-       if (!strncmp(debug, "TDM_DEBUG_BUFFER", 16))
-               tdm_debug_buffer = enable;
-       else if (!strncmp(debug, "TDM_DEBUG_THREAD", 16))
-               tdm_debug_thread = enable;
-       else if (!strncmp(debug, "TDM_DEBUG_MUTEX", 15))
-               tdm_debug_mutex = enable;
+       char temp[TDM_PATH_LEN];
+       char *arg;
+       char *end;
+
+       snprintf(temp, TDM_PATH_LEN, "%s", modules);
+
+       tdm_debug_module = 0;
+
+       arg = strtok_r(temp, TDM_DELIM, &end);
+       while (arg) {
+               if (!strncmp(arg, "none", 4)) {
+                       tdm_debug_module = 0;
+                       return TDM_ERROR_NONE;
+               }
+               if (!strncmp(arg, "all", 3)) {
+                       tdm_debug_module = 0xFFFFFFFF;
+                       return TDM_ERROR_NONE;
+               }
+               if (!strncmp(arg, "buffer", 6))
+                       tdm_debug_module |= TDM_DEBUG_BUFFER;
+               else if (!strncmp(arg, "thread", 6))
+                       tdm_debug_module |= TDM_DEBUG_THREAD;
+               else if (!strncmp(arg, "mutex", 5))
+                       tdm_debug_module |= TDM_DEBUG_MUTEX;
+               else
+                       return TDM_ERROR_BAD_REQUEST;
+
+               arg = strtok_r(NULL, TDM_DELIM, &end);
+       }
+
+       TDM_INFO("module debugging... '%s'", modules);
+
+       return TDM_ERROR_NONE;
 }
 
-INTERN void
+INTERN tdm_error
 tdm_display_enable_dump(const char *dump_str)
 {
        char temp[1024];
        char *arg;
        char *end;
-       int flags = 0;
+
+       tdm_debug_dump = 0;
 
        snprintf(temp, sizeof(temp), "%s", dump_str);
        arg = strtok_r(temp, ",", &end);
        while (arg) {
+               if (!strncmp(arg, "none", 4)) {
+                       tdm_debug_dump = 0;
+                       return TDM_ERROR_NONE;
+               }
                if (!strncmp(arg, "all", 3)) {
-                       flags = TDM_DUMP_FLAG_LAYER|TDM_DUMP_FLAG_PP|TDM_DUMP_FLAG_CAPTURE;
-                       break;
+                       tdm_debug_dump = 0xFFFFFFFF;
+                       return TDM_ERROR_NONE;
                }
-               else if (!strncmp(arg, "layer", 5))
-                       flags |= TDM_DUMP_FLAG_LAYER;
+               if (!strncmp(arg, "layer", 5))
+                       tdm_debug_dump |= TDM_DUMP_FLAG_LAYER;
                else if (!strncmp(arg, "pp", 2))
-                       flags |= TDM_DUMP_FLAG_PP;
+                       tdm_debug_dump |= TDM_DUMP_FLAG_PP;
                else if (!strncmp(arg, "capture", 7))
-                       flags |= TDM_DUMP_FLAG_CAPTURE;
-               else if (!strncmp(arg, "none", 4))
-                       flags = 0;
+                       tdm_debug_dump |= TDM_DUMP_FLAG_CAPTURE;
+               else
+                       return TDM_ERROR_BAD_REQUEST;
+
                arg = strtok_r(NULL, ",", &end);
        }
 
-       tdm_debug_dump = flags;
+       TDM_INFO("dump... '%s'", dump_str);
+
+       return TDM_ERROR_NONE;
 }
index 93bbd61..9b4bdb8 100644 (file)
@@ -60,7 +60,7 @@ _tdm_buffer_destroy_info(void *user_data)
 
        if (buf_info->backend_ref_count > 0) {
                TDM_NEVER_GET_HERE();
-               if (tdm_debug_buffer)
+               if (tdm_debug_module & TDM_DEBUG_BUFFER)
                        TDM_INFO("%p", buf_info->buffer);
        }
 
@@ -77,7 +77,7 @@ _tdm_buffer_destroy_info(void *user_data)
                free(func_info);
        }
 
-       if (tdm_debug_buffer)
+       if (tdm_debug_module & TDM_DEBUG_BUFFER)
                TDM_INFO("%p destroyed", buf_info->buffer);
 
        free(buf_info);
@@ -107,7 +107,7 @@ tdm_buffer_get_info(tbm_surface_h buffer)
                        return NULL;
                }
 
-               if (tdm_debug_buffer)
+               if (tdm_debug_module & TDM_DEBUG_BUFFER)
                        TDM_INFO("%p created", buf_info->buffer);
        }
 
index cc79f62..f5bcfc2 100644 (file)
@@ -112,7 +112,7 @@ tdm_capture_cb_done(tdm_capture *capture_backend, tbm_surface_h buffer,
                tdm_helper_dump_buffer_str(buffer, str);
        }
 
-       if (tdm_debug_buffer)
+       if (tdm_debug_module & TDM_DEBUG_BUFFER)
                TDM_INFO("capture(%p) done: %p", private_capture, buffer);
 
        first_entry = tdm_buffer_list_get_first_entry(&private_capture->buffer_list);
@@ -387,7 +387,7 @@ tdm_capture_attach(tdm_capture *capture, tbm_surface_h buffer)
                if ((buf_info = tdm_buffer_get_info(buffer)))
                        LIST_ADDTAIL(&buf_info->link, &private_capture->pending_buffer_list);
 
-               if (tdm_debug_buffer) {
+               if (tdm_debug_module & TDM_DEBUG_BUFFER) {
                        TDM_INFO("capture(%p) attached:", private_capture);
                        tdm_buffer_list_dump(&private_capture->buffer_list);
                }
index 76f895f..c5db70a 100644 (file)
@@ -89,7 +89,7 @@ _tdm_dbg_server_dpms(unsigned int pid, char *cwd, int argc, char *argv[], char *
 static void
 _tdm_dbg_server_debug(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
 {
-       int value;
+       int level;
        char *arg;
        char *end;
 
@@ -99,29 +99,17 @@ _tdm_dbg_server_debug(unsigned int pid, char *cwd, int argc, char *argv[], char
        }
 
        arg = argv[2];
-       value = strtol(arg, &end, 10);
+       level = strtol(arg, &end, 10);
 
-       tdm_log_set_debug_level(value);
+       tdm_log_set_debug_level(level);
+       TDM_SNPRINTF(reply, len, "debug level: %d\n", level);
 
-       value = !!value;
-       tdm_log_enable_debug(value);
+       if (*end == '@') {
+               char *arg = end + 1;
 
-       TDM_SNPRINTF(reply, len, "debug '%s'\n", (value) ? "on" : "off");
+               tdm_display_enable_debug_module((const char *)arg);
 
-       if (argc > 3) {
-               char temp[TDM_PATH_LEN];
-               char *arg;
-               char *end;
-
-               snprintf(temp, TDM_PATH_LEN, "%s", argv[3]);
-
-               arg = strtok_r(temp, TDM_DELIM, &end);
-               while (arg) {
-                       tdm_display_enable_debug(arg, value);
-                       if (value)
-                               TDM_SNPRINTF(reply, len, "debuging '%s'...\n", arg);
-                       arg = strtok_r(NULL, TDM_DELIM, &end);
-               }
+               TDM_SNPRINTF(reply, len, "debugging... '%s'\n", arg);
        }
 }
 
@@ -296,9 +284,9 @@ static struct {
        },
        {
                "debug", _tdm_dbg_server_debug,
-               "enable the debug level log",
-               "<enable>",
-               "0 or 1"
+               "set the debug level and modules(none,mutex,buffer,thread,vblank)",
+               "<level>[@<module1>[,<module2>]]",
+               NULL
        },
        {
                "log_path", _tdm_dbg_server_log_path,
index fd4dff6..8dcf66f 100644 (file)
@@ -332,7 +332,7 @@ tdm_display_handle_events(tdm_display *dpy)
        fds.fd = fd;
        fds.revents = 0;
 
-       if (tdm_debug_thread)
+       if (tdm_debug_module & TDM_DEBUG_THREAD)
                TDM_INFO("fd(%d) polling in", fd);
 
        while (poll(&fds, 1, -1) < 0) {
@@ -344,7 +344,7 @@ tdm_display_handle_events(tdm_display *dpy)
                }
        }
 
-       if (tdm_debug_thread)
+       if (tdm_debug_module & TDM_DEBUG_THREAD)
                TDM_INFO("fd(%d) polling out", fd);
 
        if (tdm_thread_is_running())
@@ -898,7 +898,7 @@ tdm_output_cb_commit(tdm_output *output_backend, unsigned int sequence,
                private_layer->showing_buffer = private_layer->waiting_buffer;
                private_layer->waiting_buffer = NULL;
 
-               if (tdm_debug_buffer)
+               if (tdm_debug_module & TDM_DEBUG_BUFFER)
                        TDM_INFO("layer(%p) waiting_buffer(%p) showing_buffer(%p)",
                                         private_layer, private_layer->waiting_buffer,
                                         private_layer->showing_buffer);
@@ -1496,7 +1496,7 @@ tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer)
                }
 
                private_layer->waiting_buffer = tdm_buffer_ref_backend(buffer);
-               if (tdm_debug_buffer)
+               if (tdm_debug_module & TDM_DEBUG_BUFFER)
                        TDM_INFO("layer(%p) waiting_buffer(%p)",
                                         private_layer, private_layer->waiting_buffer);
        }
@@ -1522,7 +1522,7 @@ tdm_layer_unset_buffer(tdm_layer *layer)
                _pthread_mutex_lock(&private_display->lock);
                private_layer->waiting_buffer = NULL;
 
-               if (tdm_debug_buffer)
+               if (tdm_debug_module & TDM_DEBUG_BUFFER)
                        TDM_INFO("layer(%p) waiting_buffer(%p)",
                                         private_layer, private_layer->waiting_buffer);
        }
@@ -1533,7 +1533,7 @@ tdm_layer_unset_buffer(tdm_layer *layer)
                _pthread_mutex_lock(&private_display->lock);
                private_layer->showing_buffer = NULL;
 
-               if (tdm_debug_buffer)
+               if (tdm_debug_module & TDM_DEBUG_BUFFER)
                        TDM_INFO("layer(%p) showing_buffer(%p)",
                                         private_layer, private_layer->showing_buffer);
        }
@@ -1622,7 +1622,7 @@ _tbm_layer_queue_acquirable_cb(tbm_surface_queue_h surface_queue, void *data)
 
                private_layer->waiting_buffer = tdm_buffer_ref_backend(surface);
 
-               if (tdm_debug_buffer)
+               if (tdm_debug_module & TDM_DEBUG_BUFFER)
                        TDM_INFO("layer(%p) waiting_buffer(%p)",
                                         private_layer, private_layer->waiting_buffer);
 
@@ -1693,7 +1693,7 @@ tdm_layer_set_buffer_queue(tdm_layer *layer, tbm_surface_queue_h buffer_queue)
                private_layer->waiting_buffer = NULL;
                _pthread_mutex_lock(&private_display->lock);
 
-               if (tdm_debug_buffer)
+               if (tdm_debug_module & TDM_DEBUG_BUFFER)
                        TDM_INFO("layer(%p) waiting_buffer(%p)",
                                         private_layer, private_layer->waiting_buffer);
        }
@@ -1728,7 +1728,7 @@ tdm_layer_unset_buffer_queue(tdm_layer *layer)
                private_layer->waiting_buffer = NULL;
                _pthread_mutex_lock(&private_display->lock);
 
-               if (tdm_debug_buffer)
+               if (tdm_debug_module & TDM_DEBUG_BUFFER)
                        TDM_INFO("layer(%p) waiting_buffer(%p)",
                                         private_layer, private_layer->waiting_buffer);
        }
@@ -1741,7 +1741,7 @@ tdm_layer_unset_buffer_queue(tdm_layer *layer)
                _pthread_mutex_lock(&private_display->lock);
                private_layer->showing_buffer = NULL;
 
-               if (tdm_debug_buffer)
+               if (tdm_debug_module & TDM_DEBUG_BUFFER)
                        TDM_INFO("layer(%p) showing_buffer(%p)",
                                         private_layer, private_layer->showing_buffer);
        }
index 4496806..29a9763 100644 (file)
@@ -75,7 +75,7 @@ _tdm_event_loop_main_fd_handler(int fd, tdm_event_loop_mask mask, void *user_dat
 
        private_loop = private_display->private_loop;
 
-       if (tdm_debug_thread)
+       if (tdm_debug_module & TDM_DEBUG_THREAD)
                TDM_INFO("backend fd(%d) event happens", private_loop->backend_fd);
 
        func_display = &private_display->func_display;
@@ -225,7 +225,7 @@ tdm_event_loop_dispatch(tdm_private_display *private_display)
 
        TDM_RETURN_VAL_IF_FAIL(private_loop->wl_loop != NULL, TDM_ERROR_OPERATION_FAILED);
 
-       if (tdm_debug_thread)
+       if (tdm_debug_module & TDM_DEBUG_THREAD)
                TDM_INFO("dispatch");
 
        if (tdm_thread_is_running() &&
index 91a1239..a43d257 100644 (file)
@@ -144,7 +144,7 @@ tdm_pp_cb_done(tdm_pp *pp_backend, tbm_surface_h src, tbm_surface_h dst,
                tdm_helper_dump_buffer_str(dst, str);
        }
 
-       if (tdm_debug_buffer)
+       if (tdm_debug_module & TDM_DEBUG_BUFFER)
                TDM_INFO("pp(%p) done: src(%p) dst(%p)", private_pp, src, dst);
 
        if (!LIST_IS_EMPTY(&private_pp->buffer_list)) {
@@ -399,7 +399,7 @@ tdm_pp_attach(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst)
        pp_buffer->src = tdm_buffer_ref_backend(src);
        pp_buffer->dst = tdm_buffer_ref_backend(dst);
 
-       if (tdm_debug_buffer) {
+       if (tdm_debug_module & TDM_DEBUG_BUFFER) {
                TDM_INFO("pp(%p) attached:", private_pp);
                _tdm_pp_print_list(&private_pp->pending_buffer_list);
        }
index b2b61e6..0e792c8 100644 (file)
@@ -73,9 +73,16 @@ extern "C" {
  * @brief The private header file for a frontend library
  */
 
-extern int tdm_debug_buffer;
-extern int tdm_debug_mutex;
-extern int tdm_debug_thread;
+enum {
+       TDM_DEBUG_NONE,
+       TDM_DEBUG_BUFFER    = (1 << 0),
+       TDM_DEBUG_MUTEX     = (1 << 1),
+       TDM_DEBUG_THREAD    = (1 << 2),
+       TDM_DEBUG_SERVER    = (1 << 3),
+       TDM_DEBUG_VBLANK    = (1 << 4),
+};
+
+extern int tdm_debug_module;
 extern int tdm_debug_dump;
 
 #ifdef HAVE_TTRACE
@@ -466,7 +473,7 @@ extern int tdm_dump_enable;
 
 #define _pthread_mutex_unlock(l) \
        do { \
-               if (tdm_debug_mutex) \
+               if (tdm_debug_module & TDM_DEBUG_MUTEX) \
                        TDM_INFO("mutex unlock"); \
                pthread_mutex_lock(&tdm_mutex_check_lock); \
                tdm_mutex_locked = 0; \
@@ -477,7 +484,7 @@ extern int tdm_dump_enable;
 #define MUTEX_TIMEOUT_SEC 5
 #define _pthread_mutex_lock(l) \
        do { \
-               if (tdm_debug_mutex) \
+               if (tdm_debug_module & TDM_DEBUG_MUTEX) \
                        TDM_INFO("mutex lock"); \
                struct timespec rtime; \
                clock_gettime(CLOCK_REALTIME, &rtime); \
@@ -495,7 +502,7 @@ extern int tdm_dump_enable;
 #else //TDM_CONFIG_MUTEX_TIMEOUT
 #define _pthread_mutex_lock(l) \
        do { \
-               if (tdm_debug_mutex) \
+               if (tdm_debug_module & TDM_DEBUG_MUTEX) \
                        TDM_INFO("mutex lock"); \
                pthread_mutex_lock(l); \
                pthread_mutex_lock(&tdm_mutex_check_lock); \
@@ -522,9 +529,9 @@ static inline int TDM_MUTEX_IS_LOCKED(void)
 tdm_error
 tdm_display_update_output(tdm_private_display *private_display,
                                                  tdm_output *output_backend, int pipe);
-void
-tdm_display_enable_debug(char *debug, int enable);
-void
+tdm_error
+tdm_display_enable_debug_module(const char*modules);
+tdm_error
 tdm_display_enable_dump(const char *dump_str);
 
 /**
index a20984f..ab6467e 100644 (file)
@@ -140,7 +140,8 @@ _tdm_server_send_done(tdm_server_wait_info *wait_info, tdm_error error,
                return;
        }
 
-       TDM_DBG("req_id(%d) done", wait_info->req_id);
+       if (tdm_debug_module & TDM_DEBUG_VBLANK)
+               TDM_INFO("req_id(%d) done", wait_info->req_id);
 
        vblank_info = wait_info->vblank_info;
        wl_tdm_vblank_send_done(vblank_info->resource, wait_info->req_id,
@@ -254,7 +255,8 @@ _tdm_server_vblank_cb_wait_vblank(struct wl_client *client, struct wl_resource *
        wait_info->vblank_info = vblank_info;
        wait_info->req_id = req_id;
 
-       TDM_DBG("req_id(%d) wait", req_id);
+       if (tdm_debug_module & TDM_DEBUG_VBLANK)
+               TDM_INFO("req_id(%d) wait", req_id);
 
        ret = tdm_vblank_wait(vblank_info->vblank, req_sec, req_usec, interval, _tdm_server_cb_vblank, wait_info);
        TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, wait_failed);
@@ -443,8 +445,6 @@ _tdm_server_bind(struct wl_client *client, void *data,
                return;
        }
 
-       TDM_DBG("tdm server binding");
-
        wl_resource_set_implementation(resource, &tdm_implementation, data, NULL);
 }
 
index b9490a5..03ce03a 100644 (file)
@@ -86,16 +86,16 @@ _tdm_thread_main(void *data)
        fds.revents = 0;
 
        while (1) {
-               if (tdm_debug_thread)
+               if (tdm_debug_module & TDM_DEBUG_THREAD)
                        TDM_INFO("server flush");
                tdm_event_loop_flush(private_loop->dpy);
 
-               if (tdm_debug_thread)
+               if (tdm_debug_module & TDM_DEBUG_THREAD)
                        TDM_INFO("fd(%d) polling in", fd);
 
                ret = poll(&fds, 1, -1);
 
-               if (tdm_debug_thread)
+               if (tdm_debug_module & TDM_DEBUG_THREAD)
                        TDM_INFO("fd(%d) polling out", fd);
 
                if (ret < 0) {
@@ -107,7 +107,7 @@ _tdm_thread_main(void *data)
                        }
                }
 
-               if (tdm_debug_thread)
+               if (tdm_debug_module & TDM_DEBUG_THREAD)
                        TDM_INFO("thread got events");
 
                if (tdm_event_loop_dispatch(private_loop->dpy) < 0)
@@ -229,7 +229,7 @@ tdm_thread_send_cb(tdm_private_loop *private_loop, tdm_thread_cb_base *base)
 
        private_thread = private_loop->private_thread;
 
-       if (tdm_debug_thread)
+       if (tdm_debug_module & TDM_DEBUG_THREAD)
                TDM_INFO("fd(%d) type(%d), length(%d)",
                                 private_thread->pipe[1], base->type, base->length);
 
@@ -261,7 +261,7 @@ tdm_thread_handle_cb(tdm_private_loop *private_loop)
 
        len = read(private_thread->pipe[0], buffer, sizeof buffer);
 
-       if (tdm_debug_thread)
+       if (tdm_debug_module & TDM_DEBUG_THREAD)
                TDM_INFO("fd(%d) read length(%d)", private_thread->pipe[0], len);
 
        if (len == 0)
@@ -277,7 +277,7 @@ tdm_thread_handle_cb(tdm_private_loop *private_loop)
        i = 0;
        while (i < len) {
                base = (tdm_thread_cb_base*)&buffer[i];
-               if (tdm_debug_thread)
+               if (tdm_debug_module & TDM_DEBUG_THREAD)
                        TDM_INFO("type(%d), length(%d)", base->type, base->length);
                switch (base->type) {
                case TDM_THREAD_CB_OUTPUT_COMMIT: {
index 30ed7df..0f278c2 100644 (file)
@@ -335,8 +335,9 @@ tdm_vblank_create(tdm_display *dpy, tdm_output *output, tdm_error *error)
 
        LIST_ADD(&private_vblank->link, &vblank_list);
 
-       VDB("created. vrefresh(%d) dpms(%d)",
-               private_vblank->vrefresh, private_vblank->dpms);
+       if (tdm_debug_module & TDM_DEBUG_VBLANK)
+               VIN("created. vrefresh(%d) dpms(%d)",
+                       private_vblank->vrefresh, private_vblank->dpms);
 
        return (tdm_vblank*)private_vblank;
 }
@@ -382,7 +383,8 @@ tdm_vblank_destroy(tdm_vblank *vblank)
                free(w);
        }
 
-       VIN("destroyed");
+       if (tdm_debug_module & TDM_DEBUG_VBLANK)
+               VIN("destroyed");
 
        free(private_vblank);
 }
@@ -401,7 +403,8 @@ tdm_vblank_set_fps(tdm_vblank *vblank, unsigned int fps)
        private_vblank->fps = fps;
        private_vblank->check_HW_or_SW = 1;
 
-       VDB("fps(%d)", private_vblank->fps);
+       if (tdm_debug_module & TDM_DEBUG_VBLANK)
+               VIN("fps(%d)", private_vblank->fps);
 
        return TDM_ERROR_NONE;
 }
@@ -419,7 +422,8 @@ tdm_vblank_set_offset(tdm_vblank *vblank, int offset)
        private_vblank->offset = offset;
        private_vblank->check_HW_or_SW = 1;
 
-       VDB("offset(%d)", private_vblank->offset);
+       if (tdm_debug_module & TDM_DEBUG_VBLANK)
+               VIN("offset(%d)", private_vblank->offset);
 
        return TDM_ERROR_NONE;
 }
@@ -436,7 +440,8 @@ tdm_vblank_set_enable_fake(tdm_vblank *vblank, unsigned int enable_fake)
 
        private_vblank->enable_fake = enable_fake;
 
-       VDB("enable_fake(%d)", private_vblank->enable_fake);
+       if (tdm_debug_module & TDM_DEBUG_VBLANK)
+               VIN("enable_fake(%d)", private_vblank->enable_fake);
 
        return TDM_ERROR_NONE;
 }
@@ -473,7 +478,8 @@ _tdm_vblank_cb_vblank_HW(tdm_output *output, unsigned int sequence,
                wait_info->func(private_vblank, TDM_ERROR_NONE, private_vblank->last_seq,
                                                tv_sec, tv_usec, wait_info->user_data);
 
-       VDB("wait(%p) done", wait_info);
+       if (tdm_debug_module & TDM_DEBUG_VBLANK)
+               VIN("wait(%p) done", wait_info);
 
        free(wait_info);
 }
@@ -497,7 +503,8 @@ _tdm_vblank_wait_HW(tdm_vblank_wait_info *wait_info)
                return ret;
        }
 
-       VDB("wait(%p) waiting", wait_info);
+       if (tdm_debug_module & TDM_DEBUG_VBLANK)
+               VIN("wait(%p) waiting", wait_info);
 
        return TDM_ERROR_NONE;
 }
@@ -518,7 +525,8 @@ _tdm_vblank_cb_vblank_SW(void *user_data)
        first_wait_info = container_of(private_vblank->SW_wait_list.next, first_wait_info, link);
        TDM_RETURN_VAL_IF_FAIL(first_wait_info != NULL, TDM_ERROR_OPERATION_FAILED);
 
-       VDB("wait(%p) done", first_wait_info);
+       if (tdm_debug_module & TDM_DEBUG_VBLANK)
+               VIN("wait(%p) done", first_wait_info);
 
        private_vblank->last_seq = first_wait_info->target_seq;
        private_vblank->last_tv_sec = first_wait_info->target_sec;
@@ -568,7 +576,8 @@ _tdm_vblank_cb_vblank_SW_first(tdm_output *output, unsigned int sequence,
        w = container_of((&private_vblank->SW_pending_wait_list)->next, w, link);
        TDM_RETURN_IF_FAIL(w != NULL);
 
-       VDB("wait(%p) done", w);
+       if (tdm_debug_module & TDM_DEBUG_VBLANK)
+               VIN("wait(%p) done", w);
 
        min_interval = w->interval;
 
@@ -621,8 +630,9 @@ _tdm_vblank_sw_timer_update(tdm_private_vblank *private_vblank)
        if (ms_delay < 1)
                ms_delay = 1;
 
-       VDB("wait(%p) curr(%4lu) target(%4lu) ms_delay(%d)",
-               first_wait_info, curr, target, ms_delay);
+       if (tdm_debug_module & TDM_DEBUG_VBLANK)
+               VIN("wait(%p) curr(%4lu) target(%4lu) ms_delay(%d)",
+                       first_wait_info, curr, target, ms_delay);
 
        tdm_display_lock(private_vblank->dpy);
 
@@ -749,7 +759,8 @@ _tdm_vblank_wait_SW(tdm_vblank_wait_info *wait_info)
                                LIST_DEL(&wait_info->link);
                                return ret;
                        }
-                       VDB("wait(%p) waiting", wait_info);
+                       if (tdm_debug_module & TDM_DEBUG_VBLANK)
+                               VIN("wait(%p) waiting", wait_info);
                }
                return TDM_ERROR_NONE;
        }
@@ -823,8 +834,9 @@ _tdm_vblank_calculate_target(tdm_vblank_wait_info *wait_info)
                }
        }
 
-       VDB("target_seq(%d) last_seq(%d) skip(%d)",
-               wait_info->target_seq, private_vblank->last_seq, skip);
+       if (tdm_debug_module & TDM_DEBUG_VBLANK)
+               VIN("target_seq(%d) last_seq(%d) skip(%d)",
+                       wait_info->target_seq, private_vblank->last_seq, skip);
 
 #if 0
        target -= (private_vblank->SW_align_offset * skip * private_vblank->HW_quotient);
@@ -834,9 +846,10 @@ _tdm_vblank_calculate_target(tdm_vblank_wait_info *wait_info)
        wait_info->target_sec = target / 1000000;
        wait_info->target_usec = target % 1000000;
 
-       VDB("wait(%p) last(%4lu) req(%4lu) prev(%4lu) curr(%4lu) skip(%d) hw_interval(%d) target(%4lu,%4lu)",
-               wait_info, last, req - last, prev - last, curr - last,
-               skip, wait_info->target_hw_interval, target, target - last);
+       if (tdm_debug_module & TDM_DEBUG_VBLANK)
+               VIN("wait(%p) last(%4lu) req(%4lu) prev(%4lu) curr(%4lu) skip(%d) hw_interval(%d) target(%4lu,%4lu)",
+                       wait_info, last, req - last, prev - last, curr - last,
+                       skip, wait_info->target_hw_interval, target, target - last);
 }
 
 tdm_error