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 *
+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);
}
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_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_change_handler *h = NULL, *hh = NULL;
-
- LIST_DEL(&private_output->link);
+ 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);
free(lm);
}
- 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(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);
}
_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);
}
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);
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_main);
- LIST_INITHEAD(&private_output->change_handler_list_sub);
+ LIST_INITHEAD(&private_output->change_handler_list);
if (func_output->output_set_status_handler) {
func_output->output_set_status_handler(private_output->output_backend,
static tdm_error
_tdm_display_load_module(tdm_private_display *private_display)
{
- const char *module_name;
- struct dirent **namelist;
- int n, len;
+ 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 = TDM_DEFAULT_MODULE;
+ module_names = tdm_config_get_string(TDM_CONFIG_KEY_GENERAL_BACKENDS, TDM_DEFAULT_MODULE);
- len = strlen(module_name);
- if (len > TDM_NAME_LEN - 1) {
- TDM_ERR("TDM_MODULE is too long\n");
- return TDM_ERROR_OPERATION_FAILED;
- }
+ snprintf(temp, TDM_PATH_LEN, "%s", module_names);
- /* 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;
+ 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;
+
+ arg = strtok_r(NULL, TDM_CONFIG_DELIM, &end);
+ }
/* 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;
- /* 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;
- }
-
- 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);
-
- free(namelist[n]);
- }
- free(namelist);
-
return ret;
}
const char *str;
tdm_error ret;
double stamp1, stamp2, start;
+ int mode;
pthread_mutex_lock(&gLock);
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 */
/* LCOV_EXCL_STOP */
}
- str = getenv("TDM_DEBUG_MODULE");
+ private_display->stamp = tdm_helper_get_time();
+
+ str = tdm_config_get_string(TDM_CONFIG_KEY_DEBUG_MODULE, NULL);
if (str)
tdm_display_enable_debug_module(str);
- str = getenv("TDM_DEBUG_DUMP");
+ str = tdm_config_get_string(TDM_CONFIG_KEY_DEBUG_DUMP, NULL);
if (str)
tdm_display_enable_dump(private_display, str, NULL, NULL);
- str = getenv("TDM_DEBUG_PATH");
- if (str)
- tdm_display_enable_path(str);
-
if (pthread_mutex_init(&private_display->lock, NULL)) {
/* LCOV_EXCL_START */
ret = TDM_ERROR_OPERATION_FAILED;
goto failed_event;
stamp2 = tdm_helper_get_time();
- TDM_DBG("creating event loop time: %.3f ms", (stamp2 - stamp1) * 1000.0);
+ 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_DBG("loading backend time: %.3f ms", (stamp2 - stamp1) * 1000.0);
+ TDM_INFO("loading backend time: %.3f ms", (stamp2 - stamp1) * 1000.0);
stamp1 = stamp2;
#ifdef INIT_BUFMGR
/* 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 */
- str = getenv("TDM_COMMIT_PER_VBLANK");
- if (str) {
+ mode = tdm_config_get_int(TDM_CONFIG_KEY_GENERAL_COMMIT_PER_VBLANK, 0);
+ if (mode > 0) {
tdm_private_output *o = NULL;
- char *end;
- int mode = strtol(str, &end, 10);
/* outputs which support hwc capability can work only
* if commit_per_vblank mode is '0' (default mode) */
*/
_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);
- _pthread_mutex_unlock(&private_display->lock);
- tdm_event_loop_deinit(private_display);
tdm_vblank_deinit(private_display);
#ifdef INIT_BUFMGR
tdm_debug_dump_dir = NULL;
}
+ 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)
{
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))
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);
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);
-
- 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)
return ret;
}
- arg = strtok_r(temp, TDM_DELIM, &end);
+ 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, "client", 6))
- tdm_ttrace_module |= TDM_TTRACE_CLIENT;
else if (!strncmp(arg, "layer", 5))
tdm_ttrace_module |= TDM_TTRACE_LAYER;
else if (!strncmp(arg, "pp", 2))
return TDM_ERROR_NONE;
}
- arg = strtok_r(NULL, TDM_DELIM, &end);
+ 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_VBLANK)
+ 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)
+ 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);