#include "config.h"
#endif
-#include "tdm.h"
-#include "tdm_backend.h"
#include "tdm_private.h"
-#include "tdm_helper.h"
pthread_mutex_t tdm_mutex_check_lock = PTHREAD_MUTEX_INITIALIZER;
int tdm_mutex_locked;
+const char *tdm_mutex_lock_func;
+int tdm_mutex_lock_line;
+const char *tdm_mutex_unlock_func;
+int tdm_mutex_unlock_line;
+/* LCOV_EXCL_START */
static tdm_private_layer *
_tdm_display_find_private_layer(tdm_private_output *private_output,
tdm_layer *layer_backend)
return NULL;
}
-static tdm_private_output *
-_tdm_display_find_private_output(tdm_private_display *private_display,
- tdm_output *output_backend)
+INTERN tdm_private_output *
+tdm_display_find_private_output(tdm_private_display *private_display, tdm_output *output_backend)
{
tdm_private_output *private_output = NULL;
return NULL;
}
-INTERN tdm_private_output *
-tdm_display_find_output_stamp(tdm_private_display *private_display,
- unsigned long stamp)
+INTERN void *
+tdm_display_find_output_stamp(tdm_private_display *private_display, double stamp)
{
tdm_private_output *private_output = NULL;
{
tdm_private_capture *c = NULL, *cc = NULL;
- LIST_DEL(&private_layer->link);
+ tdm_layer_unset_buffer_internal(private_layer);
LIST_FOR_EACH_ENTRY_SAFE(c, cc, &private_layer->capture_list, link)
tdm_capture_destroy_internal(c);
_tdm_display_destroy_caps_layer(&private_layer->caps);
+ /* when destroying layer, someone could check if layer is valid. So delete
+ * the layer's link at last.
+ */
+ LIST_DEL(&private_layer->link);
+
free(private_layer);
}
static void
_tdm_display_destroy_private_output(tdm_private_output *private_output)
{
+ tdm_private_display *private_display = private_output->private_display;
tdm_private_layer *l = NULL, *ll = NULL;
+ tdm_private_hwc_window *hw = NULL, *hww = NULL;
tdm_private_capture *c = NULL, *cc = NULL;
- tdm_private_vblank_handler *v = NULL, *vv = NULL;
- tdm_private_commit_handler *m = NULL, *mm = NULL;
- tdm_private_change_handler *h = NULL, *hh = NULL;
-
- LIST_DEL(&private_output->link);
+ tdm_private_output_vblank_handler *v = NULL, *vv = NULL;
+ tdm_private_output_commit_handler *om = NULL, *omm = NULL;
+ tdm_private_layer_commit_handler *lm = NULL, *lmm = NULL;
+ tdm_private_output_change_handler *h = NULL, *hh = NULL;
free(private_output->layers_ptr);
+ if (private_output->vblank_timeout_timer)
+ tdm_event_loop_source_remove(private_output->vblank_timeout_timer);
+
LIST_FOR_EACH_ENTRY_SAFE(v, vv, &private_output->vblank_handler_list, link) {
LIST_DEL(&v->link);
free(v);
}
- LIST_FOR_EACH_ENTRY_SAFE(m, mm, &private_output->commit_handler_list, link) {
- LIST_DEL(&m->link);
- free(m);
+ LIST_FOR_EACH_ENTRY_SAFE(om, omm, &private_output->output_commit_handler_list, link) {
+ LIST_DEL(&om->link);
+ free(om);
}
- LIST_FOR_EACH_ENTRY_SAFE(h, hh, &private_output->change_handler_list_main, link) {
- LIST_DEL(&h->link);
- free(h);
+ LIST_FOR_EACH_ENTRY_SAFE(lm, lmm, &private_output->layer_commit_handler_list, link) {
+ LIST_DEL(&lm->link);
+ free(lm);
+ }
+
+ LIST_FOR_EACH_ENTRY_SAFE(lm, lmm, &private_output->pending_commit_handler_list, link) {
+ LIST_DEL(&lm->link);
+ free(lm);
}
- LIST_FOR_EACH_ENTRY_SAFE(h, hh, &private_output->change_handler_list_sub, link) {
+ LIST_FOR_EACH_ENTRY_SAFE(h, hh, &private_output->change_handler_list, link) {
LIST_DEL(&h->link);
+ tdm_thread_cb_remove(h->private_output, TDM_THREAD_CB_OUTPUT_CHANGE, NULL, tdm_output_thread_cb_change, h);
free(h);
}
+ if (private_output->vblank) {
+ /* tdm_vblank APIs is for server. it should be called in unlock status*/
+ _pthread_mutex_unlock(&private_display->lock);
+ tdm_vblank_destroy(private_output->vblank);
+ _pthread_mutex_lock(&private_display->lock);
+ }
+
+ if (private_output->ttrace_vblank) {
+ /* tdm_vblank APIs is for server. it should be called in unlock status*/
+ _pthread_mutex_unlock(&private_display->lock);
+ tdm_vblank_destroy(private_output->ttrace_vblank);
+ _pthread_mutex_lock(&private_display->lock);
+ }
+
LIST_FOR_EACH_ENTRY_SAFE(c, cc, &private_output->capture_list, link)
tdm_capture_destroy_internal(c);
+ LIST_FOR_EACH_ENTRY_SAFE(hw, hww, &private_output->hwc_window_list, link)
+ tdm_hwc_window_destroy_internal(hw);
+
LIST_FOR_EACH_ENTRY_SAFE(l, ll, &private_output->layer_list, link)
_tdm_display_destroy_private_layer(l);
_tdm_display_destroy_caps_output(&private_output->caps);
- if (private_output->dpms_changed_timer)
- tdm_event_loop_source_remove(private_output->dpms_changed_timer);
+ tdm_thread_cb_remove(private_output, TDM_THREAD_CB_NEED_VALIDATE, NULL,
+ tdm_output_need_validate_handler_thread, NULL);
+ tdm_event_loop_source_remove(private_output->need_validate.event_source);
+ close(private_output->need_validate.event_fd);
+
+ /* when destroying output, vblank objects are also destroyed. vblank checks
+ * if output object is valid. So delete the output's link at last.
+ */
+ LIST_DEL(&private_output->link);
private_output->stamp = 0;
free(private_output);
_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
tdm_func_output *func_output = &private_display->func_output;
char temp[TDM_NAME_LEN];
tdm_error ret;
+ double stamp;
if (!func_output->output_get_capability) {
TDM_ERR("no output_get_capability()");
return TDM_ERROR_BAD_MODULE;
}
+ stamp = tdm_helper_get_time();
ret = func_output->output_get_capability(output_backend, caps);
+ TDM_DBG("backend output_get_capability() time: %.3f ms", (tdm_helper_get_time() - stamp) * 1000.0);
+
if (ret != TDM_ERROR_NONE) {
TDM_ERR("output_get_capability() failed");
return TDM_ERROR_BAD_MODULE;
int layer_count = 0, i;
tdm_error ret;
- private_output = _tdm_display_find_private_output(private_display, output_backend);
+ private_output = tdm_display_find_private_output(private_display, output_backend);
if (!private_output) {
private_output = calloc(1, sizeof(tdm_private_output));
TDM_RETURN_VAL_IF_FAIL(private_output != NULL, TDM_ERROR_OUT_OF_MEMORY);
- private_output->stamp = tdm_helper_get_time_in_millis();
+ private_output->stamp = tdm_helper_get_time();
while (tdm_display_find_output_stamp(private_display, private_output->stamp))
private_output->stamp++;
private_output->index = pipe;
LIST_INITHEAD(&private_output->layer_list);
+ LIST_INITHEAD(&private_output->hwc_window_list);
LIST_INITHEAD(&private_output->capture_list);
LIST_INITHEAD(&private_output->vblank_handler_list);
- LIST_INITHEAD(&private_output->commit_handler_list);
- LIST_INITHEAD(&private_output->change_handler_list_main);
- LIST_INITHEAD(&private_output->change_handler_list_sub);
+ LIST_INITHEAD(&private_output->output_commit_handler_list);
+ LIST_INITHEAD(&private_output->layer_commit_handler_list);
+ LIST_INITHEAD(&private_output->pending_commit_handler_list);
+ LIST_INITHEAD(&private_output->change_handler_list);
if (func_output->output_set_status_handler) {
func_output->output_set_status_handler(private_output->output_backend,
_tdm_display_destroy_private_display(private_display);
return ret;
}
+/* LCOV_EXCL_STOP */
EXTERN tdm_error
tdm_display_update(tdm_display *dpy)
tdm_error ret;
TDM_RETURN_VAL_IF_FAIL(dpy != NULL, TDM_ERROR_INVALID_PARAMETER);
+ TDM_RETURN_VAL_IF_FAIL(tdm_display_is_valid(dpy), TDM_ERROR_INVALID_PARAMETER);
private_display = dpy;
_pthread_mutex_lock(&private_display->lock);
}
#define SUFFIX_MODULE ".so"
-#define DEFAULT_MODULE "libtdm-default"SUFFIX_MODULE
+#define TDM_DEFAULT_MODULE "libtdm-default"SUFFIX_MODULE
+#define TDM_DUMMY_MODULE "libtdm-dummy"SUFFIX_MODULE
int tdm_debug_module;
int tdm_debug_dump;
+int tdm_ttrace_module;
+int tdm_ttrace_output;
static tdm_private_display *g_private_display;
static pthread_mutex_t gLock = PTHREAD_MUTEX_INITIALIZER;
+/* LCOV_EXCL_START */
static tdm_error
_tdm_display_check_module(tdm_backend_module *module)
{
/* below functions should be implemented in backend side */
TDM_RETURN_VAL_IF_FAIL(func_display != NULL, TDM_ERROR_BAD_MODULE);
-// TDM_RETURN_VAL_IF_FAIL(func_display->display_get_capabilitiy, TDM_ERROR_BAD_MODULE);
TDM_RETURN_VAL_IF_FAIL(func_display->display_get_outputs, TDM_ERROR_BAD_MODULE);
TDM_RETURN_VAL_IF_FAIL(func_output->output_get_capability, TDM_ERROR_BAD_MODULE);
TDM_RETURN_VAL_IF_FAIL(func_output->output_get_layers, TDM_ERROR_BAD_MODULE);
TDM_RETURN_VAL_IF_FAIL(func_layer->layer_get_capability, TDM_ERROR_BAD_MODULE);
- if (func_display->display_get_capability)
- ret = func_display->display_get_capability(private_display->bdata, &private_display->caps_display);
- else
- ret = func_display->display_get_capabilitiy(private_display->bdata, &private_display->caps_display);
+ ret = func_display->display_get_capability(private_display->bdata, &private_display->caps_display);
if (ret != TDM_ERROR_NONE) {
TDM_ERR("display_get_capability() failed");
return TDM_ERROR_BAD_MODULE;
if (private_display->capabilities & TDM_DISPLAY_CAPABILITY_CAPTURE) {
tdm_func_capture *func_capture = &private_display->func_capture;
TDM_RETURN_VAL_IF_FAIL(func_display->display_get_capture_capability, TDM_ERROR_BAD_MODULE);
- TDM_RETURN_VAL_IF_FAIL(func_output->output_create_capture, TDM_ERROR_BAD_MODULE);
- TDM_RETURN_VAL_IF_FAIL(func_layer->layer_create_capture, TDM_ERROR_BAD_MODULE);
+ if (private_display->caps_capture.capabilities & TDM_CAPTURE_CAPABILITY_OUTPUT)
+ TDM_RETURN_VAL_IF_FAIL(func_output->output_create_capture, TDM_ERROR_BAD_MODULE);
+ if (private_display->caps_capture.capabilities & TDM_CAPTURE_CAPABILITY_LAYER)
+ TDM_RETURN_VAL_IF_FAIL(func_layer->layer_create_capture, TDM_ERROR_BAD_MODULE);
TDM_RETURN_VAL_IF_FAIL(func_capture->capture_destroy, TDM_ERROR_BAD_MODULE);
TDM_RETURN_VAL_IF_FAIL(func_capture->capture_commit, TDM_ERROR_BAD_MODULE);
TDM_RETURN_VAL_IF_FAIL(func_capture->capture_set_done_handler, TDM_ERROR_BAD_MODULE);
_tdm_display_load_module_with_file(tdm_private_display *private_display,
const char *file)
{
- char path[PATH_MAX] = {0,};
+ char path[TDM_PATH_LEN] = {0,};
tdm_backend_module *module_data;
void *module;
tdm_error ret;
+ double stamp;
+ int size;
- snprintf(path, sizeof(path), TDM_MODULE_PATH "/%s", file);
+ size = snprintf(path, sizeof(path), TDM_MODULE_PATH "/%s", file);
+ if (size >= (int)sizeof(path)) {
+ TDM_WRN("too long: %s/%s", TDM_MODULE_PATH, file);
+ return TDM_ERROR_BAD_MODULE;
+ };
- TDM_TRACE_BEGIN(Load_Backend);
+ stamp = tdm_helper_get_time();
+ TDM_TRACE_BEGIN("TDM_Load_Backend");
module = dlopen(path, RTLD_LAZY);
if (!module) {
TDM_ERR("failed to load module: %s(%s)", dlerror(), file);
TDM_TRACE_END();
goto failed_load;
}
+ TDM_TRACE_END();
+
+ TDM_DBG("dlopen, dlsym time: %.3f ms", (tdm_helper_get_time() - stamp) * 1000.0);
private_display->module_data = module_data;
private_display->module = module;
if (ret != TDM_ERROR_NONE)
goto failed_load;
- TDM_TRACE_END();
-
/* We don't care if backend_data is NULL or not. It's up to backend. */
- TDM_TRACE_BEGIN(Init_Backend);
+ TDM_TRACE_BEGIN("TDM_Init_Backend");
+ stamp = tdm_helper_get_time();
private_display->bdata = module_data->init((tdm_display *)private_display, &ret);
+ TDM_DBG("backend init() time: %.3f ms", (tdm_helper_get_time() - stamp) * 1000.0);
TDM_TRACE_END();
+
if (ret != TDM_ERROR_NONE) {
TDM_ERR("failed to init '%s' module", module_data->name);
goto failed_load;
static tdm_error
_tdm_display_load_module(tdm_private_display *private_display)
{
- const char *module_name;
- struct dirent **namelist;
- int n;
+ const char *module_names;
tdm_error ret = 0;
+ char temp[TDM_PATH_LEN];
+ char *arg;
+ char *end;
- module_name = getenv("TDM_MODULE");
- if (!module_name)
- module_name = DEFAULT_MODULE;
-
- /* load bufmgr priv from default lib */
- ret = _tdm_display_load_module_with_file(private_display, module_name);
- if (ret == TDM_ERROR_NONE)
- return TDM_ERROR_NONE;
+ module_names = tdm_config_get_string(TDM_CONFIG_KEY_GENERAL_BACKENDS, TDM_DEFAULT_MODULE);
- /* load bufmgr priv from configured path */
- n = scandir(TDM_MODULE_PATH, &namelist, 0, alphasort);
- if (n < 0) {
- TDM_ERR("no module in '%s'\n", TDM_MODULE_PATH);
- return TDM_ERROR_BAD_MODULE;
- }
+ snprintf(temp, TDM_PATH_LEN, "%s", module_names);
- ret = TDM_ERROR_BAD_MODULE;
- while (n--) {
- if (ret < 0 && strstr(namelist[n]->d_name, SUFFIX_MODULE))
- ret = _tdm_display_load_module_with_file(private_display, namelist[n]->d_name);
+ arg = strtok_r(temp, TDM_CONFIG_DELIM, &end);
+ while (arg) {
+ ret = _tdm_display_load_module_with_file(private_display, arg);
+ if (ret == TDM_ERROR_NONE)
+ return TDM_ERROR_NONE;
- free(namelist[n]);
+ arg = strtok_r(NULL, TDM_CONFIG_DELIM, &end);
}
- free(namelist);
+
+ /* load bufmgr priv from dummy lib */
+ ret = _tdm_display_load_module_with_file(private_display, TDM_DUMMY_MODULE);
+ if (ret == TDM_ERROR_NONE)
+ return TDM_ERROR_NONE;
return ret;
}
private_display->module_data = NULL;
private_display->module = NULL;
}
+/* LCOV_EXCL_STOP */
EXTERN tdm_display *
tdm_display_init(tdm_error *error)
{
tdm_private_display *private_display = NULL;
- const char *debug;
+ const char *str;
tdm_error ret;
+ double stamp1, stamp2, start;
+ int mode;
- _pthread_mutex_lock(&gLock);
+ pthread_mutex_lock(&gLock);
if (g_private_display) {
g_private_display->init_count++;
- _pthread_mutex_unlock(&gLock);
+ pthread_mutex_unlock(&gLock);
if (error)
*error = TDM_ERROR_NONE;
return g_private_display;
}
+ start = stamp1 = tdm_helper_get_time();
+
+ stamp2 = tdm_helper_get_time();
+ TDM_INFO("config init time: %.3f ms", (stamp2 - stamp1) * 1000.0);
+ stamp1 = stamp2;
+
private_display = calloc(1, sizeof(tdm_private_display));
if (!private_display) {
+ /* LCOV_EXCL_START */
ret = TDM_ERROR_OUT_OF_MEMORY;
TDM_ERR("'private_display != NULL' failed");
goto failed_alloc;
+ /* LCOV_EXCL_STOP */
}
- debug = getenv("TDM_DEBUG_MODULE");
- if (debug)
- tdm_display_enable_debug_module(debug);
+ private_display->stamp = tdm_helper_get_time();
- debug = getenv("TDM_DEBUG_DUMP");
- if (debug)
- tdm_display_enable_dump(private_display, debug, NULL, NULL);
+ str = tdm_config_get_string(TDM_CONFIG_KEY_DEBUG_MODULE, NULL);
+ if (str)
+ tdm_display_enable_debug_module(str);
- debug = getenv("TDM_DEBUG_PATH");
- if (debug)
- tdm_display_enable_path(debug);
+ str = tdm_config_get_string(TDM_CONFIG_KEY_DEBUG_DUMP, NULL);
+ if (str)
+ tdm_display_enable_dump(private_display, str, NULL, NULL);
if (pthread_mutex_init(&private_display->lock, NULL)) {
+ /* LCOV_EXCL_START */
ret = TDM_ERROR_OPERATION_FAILED;
TDM_ERR("mutex init failed: %m");
goto failed_mutex_init;
+ /* LCOV_EXCL_STOP */
}
_pthread_mutex_lock(&private_display->lock);
+ stamp2 = tdm_helper_get_time();
+ TDM_DBG("prepare init time: %.3f ms", (stamp2 - stamp1) * 1000.0);
+ stamp1 = stamp2;
+
+ ret = tdm_vblank_init(private_display);
+ if (ret != TDM_ERROR_NONE)
+ goto failed_vblank;
+
ret = tdm_event_loop_init(private_display);
if (ret != TDM_ERROR_NONE)
goto failed_event;
+ stamp2 = tdm_helper_get_time();
+ TDM_INFO("event loop init time: %.3f ms", (stamp2 - stamp1) * 1000.0);
+ stamp1 = stamp2;
+
+ ret = tdm_output_init(private_display);
+ if (ret != TDM_ERROR_NONE)
+ goto failed_load;
+
+ ret = tdm_pp_init(private_display);
+ if (ret != TDM_ERROR_NONE)
+ goto failed_load;
+
+ ret = tdm_capture_init(private_display);
+ if (ret != TDM_ERROR_NONE)
+ goto failed_load;
+
ret = _tdm_display_load_module(private_display);
if (ret != TDM_ERROR_NONE)
goto failed_load;
+ stamp2 = tdm_helper_get_time();
+ TDM_INFO("loading backend time: %.3f ms", (stamp2 - stamp1) * 1000.0);
+ stamp1 = stamp2;
+
#ifdef INIT_BUFMGR
int tdm_drm_fd = tdm_helper_get_fd("TDM_DRM_MASTER_FD");
if (tdm_drm_fd >= 0) {
} else {
TDM_INFO("tbm_bufmgr_init successed");
}
+
+ stamp2 = tdm_helper_get_time();
+ TDM_DBG("initializing bufmgr time: %.3f ms", (stamp2 - stamp1) * 1000.0);
+ stamp1 = stamp2;
}
#endif
- TDM_TRACE_BEGIN(Update_Display);
+ TDM_TRACE_BEGIN("TDM_Update_Display");
ret = _tdm_display_update_internal(private_display, 0);
TDM_TRACE_END();
if (ret != TDM_ERROR_NONE)
goto failed_update;
+ stamp2 = tdm_helper_get_time();
+ TDM_DBG("updating display time: %.3f ms", (stamp2 - stamp1) * 1000.0);
+ stamp1 = stamp2;
+
tdm_event_loop_create_backend_source(private_display);
private_display->init_count = 1;
-
g_private_display = private_display;
+ tdm_private_output *o = NULL;
+ LIST_FOR_EACH_ENTRY(o, &private_display->output_list, link) {
+ if (o->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)
+ tdm_output_need_validate_event_init(o);
+ }
+
+ /* the COMMIT_PER_VBLANK functionality is ability of an output to support
+ * several operational modes (commit_per_vblank modes) related to tdm_commit;
+ * this functionality can be turned off which means a default mode */
+ mode = tdm_config_get_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, 0);
+ if (mode > 0) {
+ tdm_private_output *o = NULL;
+
+ /* outputs which support hwc capability can work only
+ * if commit_per_vblank mode is '0' (default mode) */
+ LIST_FOR_EACH_ENTRY(o, &private_display->output_list, link)
+ if (!(o->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC))
+ tdm_output_choose_commit_per_vblank_mode(o, mode);
+ }
+
if (error)
*error = TDM_ERROR_NONE;
_pthread_mutex_unlock(&private_display->lock);
- _pthread_mutex_unlock(&gLock);
+ pthread_mutex_unlock(&gLock);
+
+ TDM_INFO("init time: %.3f ms", (tdm_helper_get_time() - start) * 1000.0);
return (tdm_display *)private_display;
+/* LCOV_EXCL_START */
failed_update:
_tdm_display_unload_module(private_display);
failed_load:
+ tdm_event_loop_stop(private_display);
tdm_event_loop_deinit(private_display);
failed_event:
+ tdm_vblank_deinit(private_display);
+failed_vblank:
_pthread_mutex_unlock(&private_display->lock);
pthread_mutex_destroy(&private_display->lock);
failed_mutex_init:
failed_alloc:
if (error)
*error = ret;
- _pthread_mutex_unlock(&gLock);
+ pthread_mutex_unlock(&gLock);
return NULL;
+/* LCOV_EXCL_STOP */
}
EXTERN void
if (!private_display)
return;
- _pthread_mutex_lock(&gLock);
+ TDM_RETURN_IF_FAIL(tdm_display_is_valid(dpy));
+
+ pthread_mutex_lock(&gLock);
private_display->init_count--;
if (private_display->init_count > 0) {
- _pthread_mutex_unlock(&gLock);
+ pthread_mutex_unlock(&gLock);
return;
}
* things because it's finalized.
*/
_pthread_mutex_lock(&private_display->lock);
+ tdm_event_loop_stop(private_display);
tdm_event_loop_deinit(private_display);
_pthread_mutex_unlock(&private_display->lock);
+ /* when private_output is destroyed, all vblank resources of client and server
+ * are destroyed. Then we can call tdm_vblank_deinit. After destroying display,
+ * we can unload backend modulues.
+ */
_tdm_display_destroy_private_display(private_display);
_tdm_display_unload_module(private_display);
+ tdm_vblank_deinit(private_display);
+
#ifdef INIT_BUFMGR
if (private_display->bufmgr)
tbm_bufmgr_deinit(private_display->bufmgr);
#endif
- tdm_helper_set_fd("TDM_DRM_MASTER_FD", -1);
+ tbm_drm_helper_unset_tbm_master_fd();
pthread_mutex_destroy(&private_display->lock);
free(private_display);
tdm_debug_dump_dir = NULL;
}
- _pthread_mutex_unlock(&gLock);
+ tdm_config_deinit();
+
+ pthread_mutex_unlock(&gLock);
TDM_INFO("done");
}
+INTERN tdm_private_display *
+tdm_display_get(void)
+{
+ return g_private_display;
+}
+
+INTERN int
+tdm_display_is_valid(tdm_display *dpy)
+{
+ if (dpy != NULL && dpy == g_private_display)
+ return 1;
+ return 0;
+}
+
+INTERN int
+tdm_output_is_valid(tdm_output *output)
+{
+ tdm_private_output *o = NULL, *private_output = output;
+ if (output && g_private_display)
+ LIST_FOR_EACH_ENTRY(o, &g_private_display->output_list, link)
+ if (o == private_output)
+ return 1;
+ return 0;
+}
+
+/* LCOV_EXCL_START */
INTERN int
tdm_display_check_module_abi(tdm_private_display *private_display, int abimaj, int abimin)
{
tdm_debug_module = 0;
- arg = strtok_r(temp, TDM_DELIM, &end);
+ arg = strtok_r(temp, TDM_CONFIG_DELIM, &end);
while (arg) {
if (!strncmp(arg, "none", 4)) {
tdm_debug_module = 0;
}
if (!strncmp(arg, "buffer", 6))
tdm_debug_module |= TDM_DEBUG_BUFFER;
+ else if (!strncmp(arg, "event", 5))
+ tdm_debug_module |= TDM_DEBUG_EVENT;
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 if (!strncmp(arg, "vblank", 6))
tdm_debug_module |= TDM_DEBUG_VBLANK;
- else
- return TDM_ERROR_BAD_REQUEST;
+ else if (!strncmp(arg, "commit", 6))
+ tdm_debug_module |= TDM_DEBUG_COMMIT;
- arg = strtok_r(NULL, TDM_DELIM, &end);
+ arg = strtok_r(NULL, TDM_CONFIG_DELIM, &end);
}
TDM_INFO("module debugging... '%s'", modules);
tdm_display_enable_dump(tdm_private_display *private_display, const char *dump_str, char *reply, int *len)
{
char temp[TDM_PATH_LEN] = {0,}, temp2[TDM_PATH_LEN] = {0,};
- char *path, *path2;
+ char *path = NULL, *path2;
char *arg;
char *end;
else
path2++;
- path = tdm_helper_dump_make_directory(path2, reply, len);
- TDM_GOTO_IF_FAIL(path != NULL, done);
-
tdm_debug_dump = 0;
snprintf(temp, sizeof(temp), "%s", dump_str);
if (!strncmp(arg, "none", 4)) {
tdm_debug_dump = 0;
+ TDM_SNPRINTF(reply, len, "path: %s\n", (tdm_debug_dump_dir) ? : "unknown");
if (tdm_debug_dump_dir) {
free(tdm_debug_dump_dir);
tdm_debug_dump_dir = NULL;
}
- TDM_SNPRINTF(reply, len, "path: %s\n", path);
goto done;
}
+ path = tdm_helper_dump_make_directory(path2, reply, len);
+ TDM_GOTO_IF_FAIL(path != NULL, done);
+
if (!strncmp(arg, "current", 7)) {
tdm_private_output *o = NULL;
if (!private_display) {
tdm_private_layer *l = NULL;
LIST_FOR_EACH_ENTRY(l, &o->layer_list, link) {
char str[TDM_PATH_LEN];
- if (l->usable)
+ if (l->usable || l->caps.capabilities & TDM_LAYER_CAPABILITY_VIDEO)
+ continue;
+ if (!l->showing_buffer)
continue;
snprintf(str, TDM_PATH_LEN, "layer_%d_%d", o->index, l->index);
- tdm_helper_dump_buffer_str(l->showing_buffer, path, str);
+ tdm_helper_dump_buffer_str(l->showing_buffer->buffer, path, str);
}
}
tdm_debug_dump |= TDM_DUMP_FLAG_PP;
} else if (!strncmp(arg, "capture", 7)) {
tdm_debug_dump |= TDM_DUMP_FLAG_CAPTURE;
+ } else if (!strncmp(arg, "window", 6)) {
+ tdm_debug_dump |= TDM_DUMP_FLAG_WINDOW;
} else
goto done;
TDM_INFO("dump... '%s'", dump_str);
done:
- free(path);
- return TDM_ERROR_NONE;
-}
-
-INTERN tdm_error
-tdm_display_enable_path(const char *path)
-{
- static int old_stdout = -1;
- char fd_name[TDM_PATH_LEN];
- int log_fd = -1;
- FILE *log_fl;
-
- if (old_stdout == -1)
- old_stdout = dup(STDOUT_FILENO);
-
- tdm_log_enable_dlog(0);
-
- snprintf(fd_name, TDM_PATH_LEN, "%s", path);
-
- log_fl = fopen(fd_name, "a");
- if (!log_fl) {
- TDM_ERR("failed: open file(%s)\n", fd_name);
- return TDM_ERROR_OPERATION_FAILED;
- }
-
- fflush(stderr);
- close(STDOUT_FILENO);
-
- setvbuf(log_fl, NULL, _IOLBF, 512);
- log_fd = fileno(log_fl);
-
- dup2(log_fd, STDOUT_FILENO);
- fclose(log_fl);
+ if (path)
+ free(path);
return TDM_ERROR_NONE;
}
-
static void
_tdm_display_ttrace_vblank_cb(tdm_vblank *vblank, tdm_error error, unsigned int sequence,
unsigned int tv_sec, unsigned int tv_usec, void *user_data)
{
tdm_error ret = TDM_ERROR_NONE;
- TDM_TRACE_COUNT(VBlank, sequence);
+ TDM_TRACE_MARK("VSYNC");
ret = tdm_vblank_wait(vblank, 0, 0, 1, _tdm_display_ttrace_vblank_cb, NULL);
TDM_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
INTERN tdm_error
tdm_display_enable_ttrace_vblank(tdm_display *dpy, tdm_output *output, int enable)
{
- static tdm_vblank *vblank = NULL;
+ tdm_private_display *private_display = dpy;
+ tdm_private_output *private_output = NULL;
+ const tdm_output_mode *mode = NULL;
+ tdm_vblank *vblank = NULL;
tdm_error ret = TDM_ERROR_NONE;
if (!enable) {
- if (vblank)
- tdm_vblank_destroy(vblank);
- vblank = NULL;
+ LIST_FOR_EACH_ENTRY(private_output, &private_display->output_list, link) {
+ if (private_output->ttrace_vblank)
+ tdm_vblank_destroy(private_output->ttrace_vblank);
+ private_output->ttrace_vblank = NULL;
+ }
return TDM_ERROR_NONE;
- } else {
- const tdm_output_mode *mode = NULL;
+ }
- if (vblank)
- return TDM_ERROR_NONE;
+ private_output = output;
+ TDM_RETURN_VAL_IF_FAIL(private_output != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+ if (private_output->ttrace_vblank)
+ return TDM_ERROR_NONE;
+
+ vblank = tdm_vblank_create(private_display, output, &ret);
+ TDM_RETURN_VAL_IF_FAIL(vblank != NULL, ret);
- vblank = tdm_vblank_create(dpy, output, &ret);
- TDM_RETURN_VAL_IF_FAIL(vblank != NULL, ret);
+ ret = tdm_output_get_mode(output, &mode);
+ TDM_GOTO_IF_FAIL(mode != NULL, enable_fail);
- ret = tdm_output_get_mode(output, &mode);
- TDM_RETURN_VAL_IF_FAIL(mode != NULL, ret);
+ ret = tdm_vblank_set_fps(vblank, mode->vrefresh);
+ TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, enable_fail);
- ret = tdm_vblank_set_fps(vblank, mode->vrefresh);
- TDM_RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, ret);
+ ret = tdm_vblank_set_enable_fake(vblank, 1);
+ TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, enable_fail);
- ret = tdm_vblank_set_enable_fake(vblank, 1);
- TDM_RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, ret);
+ ret = tdm_vblank_wait(vblank, 0, 0, 1, _tdm_display_ttrace_vblank_cb, NULL);
+ TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, enable_fail);
+
+ private_output->ttrace_vblank = vblank;
+
+ return TDM_ERROR_NONE;
+
+enable_fail:
+ if (vblank)
+ tdm_vblank_destroy(vblank);
+
+ return ret;
+}
+
+INTERN tdm_error
+tdm_display_enable_ttrace(tdm_private_display *private_display, const char *ttrace, int output_id, char *reply, int *len)
+{
+ char temp[TDM_PATH_LEN];
+ char *arg;
+ char *end;
+ tdm_output *output;
+ tdm_error ret;
+ tdm_output_type type;
+
+ snprintf(temp, TDM_PATH_LEN, "%s", ttrace);
+
+ tdm_ttrace_output = output_id;
+ tdm_ttrace_module = 0;
+
+ output = tdm_display_get_output(private_display, output_id, &ret);
+ if (!output) {
+ TDM_SNPRINTF(reply, len, "can't find the output_id(%d)\n", output_id);
+ return ret;
+ }
- ret = tdm_vblank_wait(vblank, 0, 0, 1, _tdm_display_ttrace_vblank_cb, NULL);
- TDM_RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, ret);
+ ret = tdm_output_get_output_type(output, &type);
+ if (ret != TDM_ERROR_NONE) {
+ TDM_SNPRINTF(reply, len, "can't find the type of output_id(%d)\n", output_id);
+ return ret;
+ }
+
+ arg = strtok_r(temp, TDM_CONFIG_DELIM, &end);
+ while (arg) {
+ if (!strncmp(arg, "none", 4))
+ tdm_ttrace_module = 0;
+ else if (!strncmp(arg, "all", 3))
+ tdm_ttrace_module = 0xFFFFFFFF;
+ else if (!strncmp(arg, "vsync", 5))
+ tdm_ttrace_module |= TDM_TTRACE_VSYNC;
+ else if (!strncmp(arg, "client_vblank", 13))
+ tdm_ttrace_module |= TDM_TTRACE_CLIENT_VBLANK;
+ else if (!strncmp(arg, "server_vblank", 13))
+ tdm_ttrace_module |= TDM_TTRACE_SERVER_VBLANK;
+ else if (!strncmp(arg, "vblank", 6))
+ tdm_ttrace_module |= TDM_TTRACE_VBLANK;
+ else if (!strncmp(arg, "layer", 5))
+ tdm_ttrace_module |= TDM_TTRACE_LAYER;
+ else if (!strncmp(arg, "pp", 2))
+ tdm_ttrace_module |= TDM_TTRACE_PP;
+ else if (!strncmp(arg, "capture", 7))
+ tdm_ttrace_module |= TDM_TTRACE_CAPTURE;
+ else {
+ tdm_ttrace_module = 0;
+ tdm_display_enable_ttrace_vblank(private_display, NULL, 0);
+ tdm_server_enable_ttrace_client_vblank(private_display, NULL, 0);
+ TDM_SNPRINTF(reply, len, "unknown option: '%s'\n", arg);
+ return TDM_ERROR_NONE;
+ }
+
+ arg = strtok_r(NULL, TDM_CONFIG_DELIM, &end);
}
+ TDM_SNPRINTF(reply, len, "ttrace debugging... '%s' %x\n", ttrace, tdm_ttrace_module);
+
+ if (tdm_ttrace_module & TDM_TTRACE_VSYNC)
+ tdm_display_enable_ttrace_vblank(private_display, output, 1);
+ else
+ tdm_display_enable_ttrace_vblank(private_display, NULL, 0);
+
+ if (tdm_ttrace_module & TDM_TTRACE_CLIENT_VBLANK)
+ tdm_server_enable_ttrace_client_vblank(private_display, output, 1);
+ else
+ tdm_server_enable_ttrace_client_vblank(private_display, NULL, 0);
+
return TDM_ERROR_NONE;
}
+INTERN tdm_error
+tdm_display_enable_fps(tdm_private_display *private_display, int enable)
+{
+ private_display->print_fps = enable;
+
+ TDM_INFO("print fps: %s", (enable) ? "enable" : "disable");
+
+ return TDM_ERROR_NONE;
+}
+/* LCOV_EXCL_STOP */