1 #include "e_client_intern.h"
2 #include "e_utils_intern.h"
3 #include "e_scale_intern.h"
4 #include "e_comp_canvas_intern.h"
5 #include "e_comp_screen_intern.h"
6 #include "e_comp_wl_input_intern.h"
7 #include "e_comp_wl_intern.h"
8 #include "e_explicit_sync_intern.h"
9 #include "e_comp_wl_tizen_hwc_intern.h"
10 #include "e_comp_intern.h"
11 #include "e_input_intern.h"
12 #include "e_error_intern.h"
13 #include "e_pointer_intern.h"
14 #include "e_output_intern.h"
15 #include "e_hwc_intern.h"
16 #include "e_hwc_window_intern.h"
17 #include "e_hwc_windows_intern.h"
18 #include "e_egl_sync_intern.h"
19 #include "e_config_intern.h"
20 #include "e_dbus_conn_intern.h"
21 #include "e_main_intern.h"
22 #include "e_hwc_planes_intern.h"
24 #include <tizen-extension-server-protocol.h>
25 #include <device/board-internal.h>
26 #include <tbm_drm_helper.h>
29 #define PATH "/org/enlightenment/wm"
30 #define IFACE "org.enlightenment.wm.screen_rotation"
32 static Ecore_Event_Handler *dbus_init_done_handler;
33 static Eldbus_Connection *edbus_conn = NULL;
34 static Eldbus_Connection_Type edbus_conn_type = ELDBUS_CONNECTION_TYPE_SYSTEM;
35 static Eldbus_Service_Interface *e_comp_screen_iface;
37 static Eina_List *event_handlers = NULL;
38 static Eina_List *output_hooks = NULL;
40 EINTERN int E_EVENT_SCREEN_CHANGE = 0;
44 E_COMP_SCREEN_SIGNAL_ROTATION_CHANGED = 0
47 typedef struct _E_Comp_Screen_Tzsr
49 struct wl_resource *resource; /* tizen_screen_rotation */
51 struct wl_listener ec_destroy;
54 static Eina_List *tzsr_list;
55 static E_Client_Hook *tzsr_client_hook_del;
57 static void _tz_screen_rotation_cb_ec_destroy(struct wl_listener *listener, void *data);
59 static E_Comp_Screen_Tzsr*
60 _tz_surface_rotation_find(E_Client *ec)
62 E_Comp_Screen_Tzsr *tzsr = NULL;
63 struct wl_listener *listener;
65 listener = e_client_destroy_listener_get(ec, _tz_screen_rotation_cb_ec_destroy);
67 return wl_container_of(listener, tzsr, ec_destroy);
73 _tz_surface_rotation_free(E_Comp_Screen_Tzsr *tzsr)
75 ELOGF("TRANSFORM", "|tzsr(%p) freed", tzsr->ec, tzsr);
76 tzsr_list = eina_list_remove(tzsr_list, tzsr);
77 wl_list_remove(&tzsr->ec_destroy.link);
82 _tz_screen_rotation_cb_ec_destroy(struct wl_listener *listener, void *data)
84 E_Comp_Screen_Tzsr *tzsr;
86 tzsr = wl_container_of(listener, tzsr, ec_destroy);
87 _tz_surface_rotation_free(tzsr);
91 _tz_screen_rotation_get_ignore_output_transform(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface)
93 E_Comp_Screen_Tzsr *tzsr;
95 E_Hwc_Policy hwc_policy;
98 Eina_Bool ignore = EINA_TRUE;
100 ec = e_client_from_surface_resource(surface);
101 EINA_SAFETY_ON_NULL_RETURN(ec);
103 tzsr = _tz_surface_rotation_find(ec);
106 tzsr = E_NEW(E_Comp_Screen_Tzsr, 1);
109 wl_client_post_no_memory(client);
113 tzsr->resource = resource;
116 tzsr->ec_destroy.notify = _tz_screen_rotation_cb_ec_destroy;
117 e_client_destroy_listener_add(ec, &tzsr->ec_destroy);
119 tzsr_list = eina_list_append(tzsr_list, tzsr);
121 zone = e_comp_zone_find_by_ec(ec);
124 output = e_output_find(zone->output_id);
127 hwc_policy = e_hwc_policy_get(output->hwc);
128 if (hwc_policy == E_HWC_POLICY_WINDOWS)
133 ELOGF("TRANSFORM", "|tzsr(%p) client_ignore(%d) ignore(%d)",
134 ec, tzsr, e_config->screen_rotation_client_ignore, ignore);
136 e_comp_screen_rotation_ignore_output_transform_send(ec, ignore);
140 _tz_screen_rotation_iface_cb_destroy(struct wl_client *client, struct wl_resource *resource)
142 wl_resource_destroy(resource);
145 static const struct tizen_screen_rotation_interface _tz_screen_rotation_interface =
147 _tz_screen_rotation_get_ignore_output_transform,
148 _tz_screen_rotation_iface_cb_destroy,
151 static void _tz_screen_rotation_cb_destroy(struct wl_resource *resource)
153 E_Comp_Screen_Tzsr *tzsr;
156 EINA_LIST_FOREACH_SAFE(tzsr_list, l, ll, tzsr)
158 if (tzsr->resource == resource)
159 _tz_surface_rotation_free(tzsr);
164 _tz_screen_rotation_cb_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
166 struct wl_resource *res;
168 if (!(res = wl_resource_create(client, &tizen_screen_rotation_interface, version, id)))
170 ERR("Could not create tizen_screen_rotation resource: %m");
171 wl_client_post_no_memory(client);
175 wl_resource_set_implementation(res, &_tz_screen_rotation_interface, NULL, _tz_screen_rotation_cb_destroy);
178 static Eldbus_Message *
179 _e_comp_screen_dbus_get_cb(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
181 Eldbus_Message *reply = eldbus_message_method_return_new(msg);
184 if (e_comp && e_comp->e_comp_screen)
185 rotation = e_comp->e_comp_screen->rotation;
187 ELOGF("COMP_SCREEN","got screen-rotation 'get' request: %d", NULL, rotation);
189 eldbus_message_arguments_append(reply, "i", rotation);
194 static const Eldbus_Method methods[] =
196 {"get", NULL, ELDBUS_ARGS({"i", "int32"}), _e_comp_screen_dbus_get_cb, 0},
200 static const Eldbus_Signal signals[] = {
201 [E_COMP_SCREEN_SIGNAL_ROTATION_CHANGED] = {"changed", ELDBUS_ARGS({ "i", "rotation" }), 0},
205 static const Eldbus_Service_Interface_Desc iface_desc = {
206 IFACE, methods, signals, NULL, NULL, NULL
210 _e_comp_screen_dbus_init()
212 E_Comp_Screen *e_comp_screen = e_comp->e_comp_screen;
214 e_comp_screen_iface = eldbus_service_interface_register(edbus_conn,
217 EINA_SAFETY_ON_NULL_GOTO(e_comp_screen_iface, err);
219 if (e_comp_screen->rotation)
221 eldbus_service_signal_emit(e_comp_screen_iface, E_COMP_SCREEN_SIGNAL_ROTATION_CHANGED, e_comp_screen->rotation);
222 ELOGF("TRANSFORM", "screen-rotation sends signal: %d", NULL, e_comp_screen->rotation);
230 e_dbus_conn_connection_unref(edbus_conn);
238 _layer_cap_to_str(tdm_layer_capability caps, tdm_layer_capability cap)
242 if (cap == TDM_LAYER_CAPABILITY_CURSOR) return "cursor ";
243 else if (cap == TDM_LAYER_CAPABILITY_PRIMARY) return "primary ";
244 else if (cap == TDM_LAYER_CAPABILITY_OVERLAY) return "overlay ";
245 else if (cap == TDM_LAYER_CAPABILITY_GRAPHIC) return "graphics ";
246 else if (cap == TDM_LAYER_CAPABILITY_VIDEO) return "video ";
247 else if (cap == TDM_LAYER_CAPABILITY_TRANSFORM) return "transform ";
248 else if (cap == TDM_LAYER_CAPABILITY_RESEVED_MEMORY) return "reserved_memory ";
249 else if (cap == TDM_LAYER_CAPABILITY_NO_CROP) return "no_crop ";
250 else return "unkown";
256 _e_comp_screen_commit_idle_cb(void *data EINA_UNUSED)
259 E_Comp_Screen *e_comp_screen = NULL;
260 E_Output *output = NULL;
262 if (!e_comp->e_comp_screen) goto end;
264 if (e_config->comp_canvas_norender.use)
265 evas_norender(e_comp->evas);
267 if (e_comp->canvas_render_delayed) goto end;
269 e_comp_screen = e_comp->e_comp_screen;
271 EINA_LIST_FOREACH_SAFE(e_comp_screen->outputs, l, ll, output)
273 if (!output) continue;
274 if (!output->config.enabled) continue;
276 if (!e_output_commit(output))
277 ERR("fail to commit e_comp_screen->outputs.");
279 if (!e_output_render(output))
280 ERR("fail to render e_comp_screen->outputs.");
283 return ECORE_CALLBACK_RENEW;
287 _e_comp_screen_input_rotation_set(int rotation)
294 EINA_LIST_FOREACH(e_input_devices_get(), l, dev)
296 e_input_device_touch_rotation_set(dev, rotation);
297 e_input_device_rotation_set(dev, rotation);
299 ELOGF("COMP_SCREEN","EE Input Device Rotate: %d", NULL, rotation);
305 _e_comp_screen_cb_input_device_add(void *data, int type, void *event)
307 Ecore_Event_Device_Info *e;
310 if (!(e = event)) goto end;
312 if (e->clas == ECORE_DEVICE_CLASS_MOUSE)
314 if (comp->wl_comp_data->ptr.num_devices == 0)
316 e_pointer_object_set(comp->pointer, NULL, 0, 0);
317 e_comp_wl_input_pointer_enabled_set(EINA_TRUE);
319 comp->wl_comp_data->ptr.num_devices++;
321 else if (e->clas == ECORE_DEVICE_CLASS_KEYBOARD)
323 comp->wl_comp_data->kbd.num_devices++;
324 e_comp_wl_input_keyboard_enabled_set(EINA_TRUE);
326 else if (e->clas == ECORE_DEVICE_CLASS_TOUCH)
328 e_comp_wl_input_touch_enabled_set(EINA_TRUE);
329 _e_comp_screen_input_rotation_set(e_comp->e_comp_screen->rotation);
330 comp->wl_comp_data->touch.num_devices++;
334 return ECORE_CALLBACK_PASS_ON;
338 _e_comp_screen_pointer_renew(void)
340 if ((e_comp_wl->ptr.num_devices == 0) && e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->pointer_enter_sent)
342 if (e_devicemgr->last_device_ptr)
344 Evas_Device *last_ptr = NULL, *dev;
347 const char *description;
349 list = (Eina_List *)evas_device_list(evas_object_evas_get(e_comp_wl->ptr.ec->frame), NULL);
350 EINA_LIST_FOREACH(list, l, dev)
352 name = evas_device_name_get(dev);
353 description = evas_device_description_get(dev);
355 if (!name || !description) continue;
356 if ((!strncmp(name, e_devicemgr->last_device_ptr->name, strlen(e_devicemgr->last_device_ptr->name))) &&
357 (!strncmp(description, e_devicemgr->last_device_ptr->identifier, strlen(e_devicemgr->last_device_ptr->identifier))) &&
358 (evas_device_class_get(dev) == (Evas_Device_Class)e_devicemgr->last_device_ptr->clas))
365 e_comp_wl_mouse_out_renew(e_comp_wl->ptr.ec, 0, wl_fixed_to_int(e_comp_wl->ptr.x), wl_fixed_to_int(e_comp_wl->ptr.y), NULL, NULL, NULL, ecore_time_get(), EVAS_EVENT_FLAG_NONE, last_ptr, NULL);
371 _e_comp_screen_cb_input_device_del(void *data, int type, void *event)
373 Ecore_Event_Device_Info *e;
376 if (!(e = event)) goto end;
378 if (e->clas == ECORE_DEVICE_CLASS_MOUSE)
380 comp->wl_comp_data->ptr.num_devices--;
381 if (comp->wl_comp_data->ptr.num_devices == 0)
383 e_comp_wl_input_pointer_enabled_set(EINA_FALSE);
384 e_pointer_object_set(comp->pointer, NULL, 0, 0);
385 e_pointer_hide(e_comp->pointer);
387 _e_comp_screen_pointer_renew();
390 else if (e->clas == ECORE_DEVICE_CLASS_KEYBOARD)
392 comp->wl_comp_data->kbd.num_devices--;
393 if (comp->wl_comp_data->kbd.num_devices == 0)
395 e_comp_wl_input_keyboard_enabled_set(EINA_FALSE);
398 else if (e->clas == ECORE_DEVICE_CLASS_TOUCH)
400 comp->wl_comp_data->touch.num_devices--;
401 if (comp->wl_comp_data->touch.num_devices == 0)
403 e_comp_wl_input_touch_enabled_set(EINA_FALSE);
409 return ECORE_CALLBACK_PASS_ON;
413 _e_comp_screen_size_update(E_Comp_Screen *e_comp_screen)
416 int sum_w = 0, max_h = 0, output_w, output_h;
419 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
421 /* we place external output to the right of primary output */
422 EINA_LIST_FOREACH(e_comp_screen->outputs, l, output)
424 if (!e_output_connected(output)) continue;
426 e_output_size_get(output, &output_w, &output_h);
429 if (max_h < output_h)
433 e_comp_screen->w = sum_w;
434 e_comp_screen->h = max_h;
438 /* rotation should be reset because tbm_surface_queue or gbm_surface of
439 * ecore_evas is created without rotation
440 * and rotation of ecore_evas is reset after it is resized
442 if (e_comp_screen->rotation)
443 ecore_evas_rotation_with_resize_set(e_comp->ee, 0);
445 ecore_evas_resize(e_comp->ee, e_comp_screen->w, e_comp_screen->h);
447 if (e_comp_screen->rotation)
448 ecore_evas_rotation_with_resize_set(e_comp->ee, e_comp_screen->rotation);
455 _e_comp_screen_cb_event(void *data, Ecore_Fd_Handler *hdlr EINA_UNUSED)
457 E_Comp_Screen *e_comp_screen;
460 if (!(e_comp_screen = data)) return ECORE_CALLBACK_RENEW;
462 ret = tdm_display_handle_events(e_comp_screen->tdisplay);
463 if (ret != TDM_ERROR_NONE)
464 ERR("tdm_display_handle_events failed");
466 return ECORE_CALLBACK_RENEW;
469 static E_Comp_Screen *
470 _e_comp_screen_new(E_Comp *comp)
472 E_Comp_Screen *e_comp_screen = NULL;
473 tdm_error error = TDM_ERROR_NONE;
474 tdm_display_capability capabilities;
475 const tbm_format *pp_formats;
479 e_comp_screen = E_NEW(E_Comp_Screen, 1);
480 if (!e_comp_screen) return NULL;
482 /* tdm display init */
483 e_main_ts_begin("\tTDM Display Init");
484 e_comp_screen->tdisplay = tdm_display_init(&error);
485 if (!e_comp_screen->tdisplay)
487 e_main_ts_end("\tTDM Display Init Failed");
488 ERR("fail to get tdm_display\n");
492 e_main_ts_end("\tTDM Display Init Done");
494 e_comp_screen->gdevice_fd = -1;
495 e_comp_screen->fd = -1;
496 tdm_display_get_fd(e_comp_screen->tdisplay, &fd);
499 ERR("fail to get tdm_display fd\n");
503 e_comp_screen->fd = dup(fd);
505 e_comp_screen->hdlr =
506 ecore_main_fd_handler_add(e_comp_screen->fd, ECORE_FD_READ,
507 _e_comp_screen_cb_event, e_comp_screen, NULL, NULL);
508 /* tdm display init */
509 e_main_ts_begin("\tTBM Bufmgr Server Init");
510 e_comp_screen->bufmgr = tbm_bufmgr_server_init();
511 if (!e_comp_screen->bufmgr)
513 e_main_ts_end("\tTBM Bufmgr Server Init Failed");
514 ERR("tbm_bufmgr_init failed\n");
517 e_main_ts_end("\tTBM Bufmgr Server Init Done");
519 error = tdm_display_get_capabilities(e_comp_screen->tdisplay, &capabilities);
520 if (error != TDM_ERROR_NONE)
522 ERR("tdm get_capabilities failed");
526 /* check the pp_support */
527 if (capabilities & TDM_DISPLAY_CAPABILITY_PP)
529 error = tdm_display_get_pp_available_formats(e_comp_screen->tdisplay, &pp_formats, &count);
530 if (error != TDM_ERROR_NONE)
531 ERR("fail to get available pp formats");
534 e_comp_screen->pp_enabled = EINA_TRUE;
535 for (i = 0 ; i < count ; i++)
536 e_comp_screen->available_pp_formats = eina_list_append(e_comp_screen->available_pp_formats, &pp_formats[i]);
540 e_main_ts_begin("\ttdm-socket Init");
541 if (e_comp_socket_init("tdm-socket"))
542 PRCTL("[Winsys] change permission and create sym link for %s", "tdm-socket");
543 e_main_ts_end("\ttdm-socket Init Done");
545 return e_comp_screen;
548 if (e_comp_screen->bufmgr) tbm_bufmgr_deinit(e_comp_screen->bufmgr);
549 if (e_comp_screen->fd >= 0) close(e_comp_screen->fd);
550 if (e_comp_screen->hdlr) ecore_main_fd_handler_del(e_comp_screen->hdlr);
551 if (e_comp_screen->tdisplay) tdm_display_deinit(e_comp_screen->tdisplay);
560 _e_comp_screen_del(E_Comp_Screen *e_comp_screen)
562 Eina_List *l = NULL, *ll = NULL;
565 if (!e_comp_screen) return;
567 if (e_comp_screen->pp_enabled)
569 EINA_LIST_FOREACH_SAFE(e_comp_screen->available_pp_formats, l, ll, formats)
571 if (!formats) continue;
572 e_comp_screen->available_pp_formats = eina_list_remove(e_comp_screen->available_pp_formats, l);
576 if (e_comp_screen->gdevice) gbm_device_destroy(e_comp_screen->gdevice);
577 if (e_comp_screen->gdevice_fd >= 0) close(e_comp_screen->gdevice_fd);
578 if (e_comp_screen->bufmgr) tbm_bufmgr_deinit(e_comp_screen->bufmgr);
579 if (e_comp_screen->fd >= 0) close(e_comp_screen->fd);
580 if (e_comp_screen->hdlr) ecore_main_fd_handler_del(e_comp_screen->hdlr);
581 if (e_comp_screen->tdisplay) tdm_display_deinit(e_comp_screen->tdisplay);
587 _e_comp_screen_output_mode_change_cb(tdm_output *toutput, unsigned int index, void *user_data)
589 E_Comp_Screen *e_comp_screen = user_data;
590 E_Output *output = NULL;
591 Eina_Bool find = EINA_FALSE;
593 E_Output_Mode *set_emode = NULL, *current_emode = NULL;
594 E_Output_Mode *emode = NULL;
595 Eina_List *modelist = NULL, *l, *ll;
597 EINA_SAFETY_ON_NULL_RETURN(e_comp_screen);
599 EINA_LIST_FOREACH_SAFE(e_comp_screen->outputs, l, ll, output)
601 if (output->toutput == toutput)
607 EINA_SAFETY_ON_FALSE_RETURN(find == EINA_TRUE);
609 current_emode = e_output_current_mode_get(output);
610 EINA_SAFETY_ON_NULL_RETURN(current_emode);
612 modelist = e_output_mode_list_get(output);
615 num = eina_list_count(modelist);
616 EINA_SAFETY_ON_FALSE_RETURN(index < num);
619 EINA_LIST_FOREACH(modelist, l, emode)
631 EINA_SAFETY_ON_TRUE_RETURN(current_emode == set_emode);
633 ELOGF("COMP_SCREEN","request mode change(%d) (%dx%d, %lf) -> (%dx%d, %lf)\n",
634 NULL, index, current_emode->w, current_emode->h, current_emode->refresh,
635 set_emode->w, set_emode->h, set_emode->refresh);
637 e_output_external_mode_change(output, set_emode);
643 _e_comp_screen_output_destroy_cb(tdm_output *toutput, void *user_data)
645 E_Comp_Screen *e_comp_screen = user_data;
646 E_Output *output = NULL;
649 EINA_SAFETY_ON_NULL_RETURN(e_comp_screen);
651 tdm_output_remove_destroy_handler(toutput, _e_comp_screen_output_destroy_cb, e_comp_screen);
653 EINA_LIST_FOREACH_SAFE(e_comp_screen->outputs, l, ll, output)
655 if (output->toutput == toutput)
657 e_comp_screen->num_outputs--;
658 e_comp_screen->outputs = eina_list_remove_list(e_comp_screen->outputs, l);
659 e_output_del(output);
665 _e_comp_screen_output_create_cb(tdm_display *dpy, tdm_output *toutput, void *user_data)
667 E_Comp_Screen *e_comp_screen = user_data;
668 E_Output *output = NULL;
669 tdm_error ret = TDM_ERROR_NONE;
671 EINA_SAFETY_ON_NULL_RETURN(e_comp_screen);
673 TRACE_DS_BEGIN(OUTPUT:NEW);
674 output = e_output_new(e_comp_screen, e_comp_screen->num_outputs);
675 EINA_SAFETY_ON_NULL_GOTO(output, fail);
676 if (output->toutput != toutput) goto fail;
679 TRACE_DS_BEGIN(OUTPUT:UPDATE);
680 if (!e_output_update(output))
682 ERR("fail to e_output_update.");
683 e_output_del(output);
688 /* todo : add tdm_output_add_mode_change_request_handler()*/
689 ret = tdm_output_add_mode_change_request_handler(toutput, _e_comp_screen_output_mode_change_cb, e_comp_screen);
690 if (ret != TDM_ERROR_NONE)
692 ERR("fail to add output mode change handler.");
693 e_output_del(output);
697 ret = tdm_output_add_destroy_handler(toutput, _e_comp_screen_output_destroy_cb, e_comp_screen);
698 if (ret != TDM_ERROR_NONE)
700 ERR("fail to add output destroy handler.");
701 e_output_del(output);
705 e_comp_screen->outputs = eina_list_append(e_comp_screen->outputs, output);
706 e_comp_screen->num_outputs++;
715 _e_comp_screen_deinit_outputs(E_Comp_Screen *e_comp_screen)
720 tdm_display_remove_output_create_handler(e_comp_screen->tdisplay, _e_comp_screen_output_create_cb, e_comp_screen);
722 e_hwc_ecore_evas_deinit();
725 EINA_LIST_FOREACH_SAFE(e_comp_screen->outputs, l, ll, output)
727 e_comp_screen->outputs = eina_list_remove_list(e_comp_screen->outputs, l);
728 e_output_del(output);
731 e_explicit_sync_deinit();
734 e_hwc_windows_deinit();
735 e_hwc_planes_deinit();
740 _e_comp_screen_fake_output_set(E_Comp_Screen *e_comp_screen)
742 E_Output *primary_output = NULL;
744 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
746 primary_output = e_comp_screen_primary_output_get(e_comp_screen);
747 EINA_SAFETY_ON_NULL_RETURN_VAL(primary_output, EINA_FALSE);
749 if (!e_output_hwc_setup(primary_output))
751 ERR("fail to e_output_hwc_setup.");
755 if (!e_output_fake_config_set(primary_output, 2, 1))
757 e_error_message_show(_("Fail to set the fake output config!\n"));
758 e_hwc_ecore_evas_deinit();
766 _e_comp_screen_init_outputs(E_Comp_Screen *e_comp_screen)
768 E_Output *output = NULL;
769 E_Output_Mode *mode = NULL;
770 tdm_display *tdisplay = e_comp_screen->tdisplay;
773 Eina_Bool scale_updated = EINA_FALSE;
774 Eina_Bool connection_check = EINA_FALSE;
775 tdm_error err = TDM_ERROR_NONE;
780 if (!e_output_init())
782 ERR("fail to e_output_init.");
786 /* get the num of outputs */
787 err = tdm_display_get_output_count(tdisplay, &num_outputs);
788 if ((err != TDM_ERROR_NONE) ||
791 ERR("fail to get tdm_display_get_output_count\n");
794 e_comp_screen->num_outputs = num_outputs;
796 ELOGF("COMP_SCREEN","num_outputs = %i", NULL, e_comp_screen->num_outputs);
800 ERR("e_hwc_init failed");
804 if (!e_hwc_planes_init())
806 ERR("e_hwc_planes_init failed");
810 if (!e_hwc_windows_init())
812 ERR("e_hwc_windows_init failed");
816 for (i = 0; i < num_outputs; i++)
818 e_main_ts_begin("\tE_Output New");
819 output = e_output_new(e_comp_screen, i);
822 e_main_ts_end("\tE_Output New Failed");
826 e_main_ts_begin("\tE_Output Update");
827 if (!e_output_update(output))
829 e_main_ts_end("\tE_Output Update Failed");
830 ERR("fail to e_output_update.");
833 e_main_ts_end("\tE_Output Update Done");
835 e_comp_screen->outputs = eina_list_append(e_comp_screen->outputs, output);
837 if (!e_output_connected(output)) continue;
839 connection_check = EINA_TRUE;
841 /* setting with the best mode and enable the output */
842 e_main_ts_begin("\tE_Output Find Best Mode");
843 mode = e_output_best_mode_find(output);
846 e_main_ts_end("\tE_Output Find Best Mode Failed");
847 ERR("fail to get best mode.");
850 e_main_ts_end("\tE_Output Find Best Mode Done");
852 e_main_ts_begin("\tE_Output Mode Apply");
853 if (!e_output_mode_apply(output, mode))
855 e_main_ts_end("\tE_Output Mode Apply Failed");
856 ERR("fail to e_output_mode_apply.");
859 e_main_ts_end("\tE_Output Mode Apply Done");
861 e_main_ts_begin("\tE_Output Set DPMS ON");
862 ret = device_board_get_boot_mode(bootmode, sizeof(bootmode));
863 if (!ret && !e_util_strcmp(bootmode, "silent"))
865 INF("silent reboot. do not set dpms");
869 if (!e_output_dpms_set(output, E_OUTPUT_DPMS_ON))
871 e_main_ts_end("\tE_Output Set DPMS ON Failed");
872 ERR("fail to e_output_dpms.");
877 e_main_ts_end("\tE_Output Set DPMS ON Done");
879 e_main_ts_begin("\tE_Output Hwc Setup");
880 if (!e_output_hwc_setup(output))
882 e_main_ts_end("\tE_Output Hwc Setup Failed");
883 ERR("fail to e_output_hwc_setup.");
886 e_main_ts_end("\tE_Output Hwc Setup Done");
888 /* update e_scale with first available output size */
889 if ((e_config->scale.for_tdm) && (!scale_updated))
894 target_inch = (round((sqrt(output->info.size.w * output->info.size.w + output->info.size.h * output->info.size.h) / 25.4) * 10) / 10);
895 dpi = (round((sqrt(mode->w * mode->w + mode->h * mode->h) / target_inch) * 10) / 10);
897 e_scale_manual_update(dpi);
898 scale_updated = EINA_TRUE;
902 //TODO: if there is no output connected, make the fake output which is connected.
903 if (!connection_check)
905 if (!_e_comp_screen_fake_output_set(e_comp_screen))
909 _e_comp_screen_size_update(e_comp_screen);
911 e_main_ts_begin("\tE_Hwc Ecore_Evas Init");
912 if (!e_hwc_ecore_evas_init())
914 e_main_ts_end("\ttE_Hwc Ecore_Evas Init Failed");
915 ERR("fail to e_hwc_ecore_evas_init");
918 e_main_ts_end("\tE_Hwc Ecore_Evas Init Done");
920 if (tdm_display_add_output_create_handler(tdisplay, _e_comp_screen_output_create_cb, e_comp_screen)) goto fail;
924 _e_comp_screen_deinit_outputs(e_comp_screen);
930 _e_comp_screen_e_screen_free(E_Screen *scr)
937 _e_comp_screen_e_screens_set(E_Comp_Screen *e_comp_screen, Eina_List *screens)
939 E_FREE_LIST(e_comp_screen->e_screens, _e_comp_screen_e_screen_free);
940 e_comp_screen->e_screens = screens;
944 _e_comp_screen_engine_deinit(void)
947 if (!e_comp->e_comp_screen) return;
949 _e_comp_screen_deinit_outputs(e_comp->e_comp_screen);
950 _e_comp_screen_del(e_comp->e_comp_screen);
951 e_comp->e_comp_screen = NULL;
955 _e_comp_screen_engine_init(void)
957 E_Comp_Screen *e_comp_screen = NULL;
960 /* check the screen rotation */
961 screen_rotation = (e_config->screen_rotation_pre + e_config->screen_rotation_setting) % 360;
963 ELOGF("COMP_SCREEN","screen_rotation_pre %d and screen_rotation_setting %d",
964 NULL, e_config->screen_rotation_pre, e_config->screen_rotation_setting);
966 /* e_comp_screen new */
967 e_main_ts_begin("\tE_Comp_Screen New");
968 e_comp_screen = _e_comp_screen_new(e_comp);
971 e_main_ts_end("\tE_Comp_Screen New Failed");
972 e_error_message_show(_("Enlightenment cannot create e_comp_screen!\n"));
975 e_main_ts_end("\tE_Comp_Screen New Done");
977 e_comp->e_comp_screen = e_comp_screen;
978 e_comp_screen->rotation_pre = e_config->screen_rotation_pre;
979 e_comp_screen->rotation_setting = e_config->screen_rotation_setting;
980 e_comp_screen->rotation = screen_rotation;
982 e_main_ts_begin("\tE_Comp_Screen Outputs Init");
983 if (!_e_comp_screen_init_outputs(e_comp_screen))
985 e_main_ts_end("\tE_Comp_Screen Outputs Init Failed");
986 e_error_message_show(_("Enlightenment cannot initialize outputs!\n"));
987 _e_comp_screen_engine_deinit();
990 e_main_ts_end("\tE_Comp_Screen Outputs Init Done");
992 if (!E_EVENT_SCREEN_CHANGE) E_EVENT_SCREEN_CHANGE = ecore_event_type_new();
994 ecore_event_add(E_EVENT_SCREEN_CHANGE, NULL, NULL, NULL);
996 e_comp_screen_e_screens_setup(e_comp_screen, -1, -1);
998 /* update the screen, outputs and planes at the idle enterer of the ecore_loop */
999 ecore_idle_enterer_add(_e_comp_screen_commit_idle_cb, e_comp);
1005 _e_comp_screen_cb_dbus_init_done(void *data, int type, void *event)
1007 E_DBus_Conn_Init_Done_Event *e = event;
1009 if (e->status == E_DBUS_CONN_INIT_SUCCESS && e->conn_type == edbus_conn_type)
1011 edbus_conn = e_dbus_conn_connection_ref(edbus_conn_type);
1014 _e_comp_screen_dbus_init();
1017 ecore_event_handler_del(dbus_init_done_handler);
1018 dbus_init_done_handler = NULL;
1020 return ECORE_CALLBACK_PASS_ON;
1024 e_comp_screen_e_screens_setup(E_Comp_Screen *e_comp_screen, int rw, int rh)
1028 Eina_List *e_screens = NULL;
1030 int i = 0, right_x = 0;
1032 output = e_comp_screen_primary_output_get(e_comp_screen);
1033 /* No pirmary output means that there is no output at the system */
1034 if (!output) goto out;
1036 EINA_LIST_FOREACH(e_comp_screen->outputs, l, output)
1038 screen = E_NEW(E_Screen, 1);
1039 if (!screen) return;
1041 screen->escreen = screen->screen = i;
1043 if (output->config.rotation % 180)
1045 screen->w = output->config.geom.h;
1046 screen->h = output->config.geom.w;
1050 screen->w = output->config.geom.w;
1051 screen->h = output->config.geom.h;
1054 if (e_output_connected(output))
1056 output->config.geom.x = right_x;
1057 right_x += output->config.geom.w;
1061 output->config.geom.x = 0;
1064 screen->x = output->config.geom.x;
1065 screen->y = output->config.geom.y;
1067 if (output->id) screen->id = strdup(output->id);
1069 e_screens = eina_list_append(e_screens, screen);
1070 ELOGF("COMP_SCREEN","E INIT: SCREEN: [%i][%i], %ix%i+%i+%i",
1071 NULL, i, i, screen->w, screen->h, screen->x, screen->y);
1075 ELOGF("COMP_SCREEN","e_comp_screen_e_screens_setup............... %i %p\n", NULL, i, e_comp_screen->e_screens);
1077 ecore_event_add(E_EVENT_SCREEN_CHANGE, NULL, NULL, NULL);
1079 _e_comp_screen_e_screens_set(e_comp_screen, e_screens);
1083 screen = E_NEW(E_Screen, 1);
1084 if (!screen) return;
1085 screen->escreen = screen->screen = 0;
1088 if ((rw > 0) && (rh > 0))
1089 screen->w = rw, screen->h = rh;
1092 if (e_comp_screen->rotation % 180)
1093 ecore_evas_geometry_get(e_comp->ee, NULL, NULL, &screen->h, &screen->w);
1095 ecore_evas_geometry_get(e_comp->ee, NULL, NULL, &screen->w, &screen->h);
1097 e_screens = eina_list_append(e_screens, screen);
1099 ELOGF("COMP_SCREEN","E INIT: SCREEN: No Physical Screen : [%i][%i], %ix%i+%i+%i",
1100 NULL, i, i, screen->w, screen->h, screen->x, screen->y);
1102 _e_comp_screen_e_screens_set(e_comp_screen, e_screens);
1105 EINTERN const Eina_List *
1106 e_comp_screen_e_screens_get(E_Comp_Screen *e_comp_screen)
1108 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, NULL);
1110 return e_comp_screen->e_screens;
1114 _e_comp_screen_cb_output_connect_status_change(void *data, E_Output *output)
1116 _e_comp_screen_size_update(e_comp->e_comp_screen);
1120 _e_comp_screen_cb_output_mode_change(void *data, E_Output *output)
1122 _e_comp_screen_size_update(e_comp->e_comp_screen);
1126 e_comp_screen_init()
1129 int w, h, ptr_x = 0, ptr_y = 0;
1131 if (!(comp = e_comp))
1132 EINA_SAFETY_ON_NULL_RETURN_VAL(comp, EINA_FALSE);
1134 e_main_ts_begin("\tE_Comp_Screen_Engine Init");
1135 if (!_e_comp_screen_engine_init())
1137 e_main_ts_end("\tE_Comp_Screen_Engine Init Failed");
1138 ERR("Could not initialize the ecore_evas engine.");
1139 goto failed_comp_screen;
1141 e_main_ts_end("\tE_Comp_Screen_Engine Init Done");
1143 e_main_ts_begin("\tE_Input Init");
1144 if (!e_input_init(e_comp->ee))
1146 e_main_ts_end("\tE_Input Init Failed");
1147 ERR("Could not initialize the e_input.");
1148 goto failed_comp_screen;
1150 e_main_ts_end("\tE_Input Init Done");
1152 e_main_ts_begin("\tE_Comp_Wl Init");
1153 if (!e_comp_wl_init())
1155 e_main_ts_begin("\tE_Comp_Wl Init Failed");
1156 goto failed_comp_screen;
1158 e_main_ts_end("\tE_Comp_Wl Init Done");
1160 /* get the current screen geometry */
1161 ecore_evas_geometry_get(e_comp->ee, NULL, NULL, &w, &h);
1164 e_main_ts_begin("\tE_Comp_Canvas Init");
1165 if (!e_comp_canvas_init(w, h))
1167 e_main_ts_end("\tE_Comp_Canvas Init Failed");
1168 e_error_message_show(_("Enlightenment cannot initialize outputs!\n"));
1169 goto failed_comp_screen;
1171 e_main_ts_end("\tE_Comp_Canvas Init Done");
1173 e_main_ts_begin("\tE_Egl_Sync Init");
1174 if (e_egl_sync_init())
1175 ELOGF("E_EGL_SYNC", "Enabled the E_Egl_Sync", NULL);
1176 e_main_ts_end("\tE_Egl_Sync Init Done");
1178 e_main_ts_begin("\tE_Explicit_Sync Init");
1179 if (e_explicit_sync_init())
1180 ELOGF("EX-SYNC", "Enabled the E_Explicit_Sync", NULL);
1181 e_main_ts_end("\tE_Explicit_Sync Init Done");
1184 e_input_device_pointer_xy_get(NULL, &ptr_x, &ptr_y);
1185 e_comp_wl->ptr.x = wl_fixed_from_int(ptr_x);
1186 e_comp_wl->ptr.y = wl_fixed_from_int(ptr_y);
1188 evas_event_feed_mouse_in(e_comp->evas, 0, NULL);
1190 e_main_ts_begin("\tE_Pointer New");
1191 if ((comp->pointer = e_pointer_canvas_new(comp->ee, EINA_TRUE)))
1193 e_pointer_hide(comp->pointer);
1195 e_main_ts_end("\tE_Pointer New Done");
1197 /* FIXME: We need a way to trap for user changing the keymap inside of E
1198 * without the event coming from X11 */
1200 /* FIXME: We should make a decision here ...
1202 * Fetch the keymap from drm, OR set this to what the E config is....
1205 /* FIXME: This is just for testing at the moment....
1206 * happens to jive with what drm does */
1208 if (!e_input_thread_mode_get())
1210 e_main_ts_begin("\tE_Comp_WL Keymap Init");
1211 e_comp_wl_input_keymap_init();
1212 e_main_ts_begin("\tE_Comp_WL Keymap Init Done");
1215 /* try to add tizen_video to wayland globals */
1216 if (!wl_global_create(e_comp_wl->wl.disp, &tizen_screen_rotation_interface, 1,
1217 NULL, _tz_screen_rotation_cb_bind))
1219 ERR("Could not add tizen_screen_rotation to wayland globals");
1220 goto failed_comp_screen;
1223 if (!e_comp_wl_tizen_hwc_init())
1225 e_main_ts_end("\e_comp_wl_tizen_hwc_init Init Failed");
1226 e_error_message_show(_("Enlightenment cannot initialize tizen_hwc!\n"));
1227 goto failed_comp_screen;
1230 e_main_ts_begin("\tDBUS Init");
1231 dbus_init_done_handler = NULL;
1232 if (e_dbus_conn_init() > 0)
1234 dbus_init_done_handler = ecore_event_handler_add(E_EVENT_DBUS_CONN_INIT_DONE, _e_comp_screen_cb_dbus_init_done, NULL);
1235 e_dbus_conn_dbus_init(edbus_conn_type);
1237 e_main_ts_end("\tDBUS Init Done");
1239 E_LIST_HANDLER_APPEND(event_handlers, ECORE_EVENT_DEVICE_ADD, _e_comp_screen_cb_input_device_add, comp);
1240 E_LIST_HANDLER_PREPEND(event_handlers, ECORE_EVENT_DEVICE_DEL, _e_comp_screen_cb_input_device_del, comp);
1242 E_OUTPUT_HOOK_APPEND(output_hooks, E_OUTPUT_HOOK_CONNECT_STATUS_CHANGE, _e_comp_screen_cb_output_connect_status_change, comp);
1243 E_OUTPUT_HOOK_APPEND(output_hooks, E_OUTPUT_HOOK_MODE_CHANGE, _e_comp_screen_cb_output_mode_change, comp);
1245 _e_comp_screen_input_rotation_set(e_comp->e_comp_screen->rotation);
1251 e_comp_wl_tizen_hwc_shutdown();
1253 _e_comp_screen_engine_deinit();
1259 e_comp_screen_shutdown()
1261 if (!e_comp) return;
1262 if (!e_comp->e_comp_screen) return;
1264 e_comp_wl_tizen_hwc_shutdown();
1266 if (e_comp_screen_iface)
1268 eldbus_service_interface_unregister(e_comp_screen_iface);
1269 e_comp_screen_iface = NULL;
1274 e_dbus_conn_connection_unref(edbus_conn);
1278 e_dbus_conn_shutdown();
1280 _e_comp_screen_deinit_outputs(e_comp->e_comp_screen);
1282 E_FREE_LIST(output_hooks, e_output_hook_del);
1284 e_client_hook_del(tzsr_client_hook_del);
1285 tzsr_client_hook_del = NULL;
1287 E_FREE_LIST(event_handlers, ecore_event_handler_del);
1289 /* delete e_comp_sreen */
1290 _e_comp_screen_del(e_comp->e_comp_screen);
1291 e_comp->e_comp_screen = NULL;
1295 _e_comp_screen_output_find_primary(E_Comp_Screen *e_comp_screen)
1297 E_Output *output = NULL, *o;
1300 EINA_LIST_FOREACH(e_comp_screen->outputs, l, o)
1302 unsigned int pipe = 0;
1305 error = tdm_output_get_pipe(o->toutput, &pipe);
1306 if (error != TDM_ERROR_NONE || pipe != 0)
1315 ERR("couldn't find the primary output");
1323 _e_comp_screen_rotation_set(E_Comp_Screen *e_comp_screen, int screen_rotation,
1324 void (*setter)(E_Comp_Screen *e_comp_screen, int data), int data)
1326 E_Output *output = NULL;
1327 E_Input_Device *dev;
1331 output = _e_comp_screen_output_find_primary(e_comp_screen);
1335 if (!e_output_rotate(output, screen_rotation))
1338 e_comp_screen->rotation = screen_rotation;
1340 setter(e_comp_screen, data);
1342 ecore_evas_rotation_with_resize_set(e_comp->ee, e_comp_screen->rotation);
1343 ecore_evas_geometry_get(e_comp->ee, NULL, NULL, &w, &h);
1345 /* rendering forcely to prepare HWC */
1346 e_comp_render_queue();
1347 e_comp_hwc_end(__FUNCTION__);
1349 EINA_LIST_FOREACH(e_input_devices_get(), l, dev)
1351 e_input_device_touch_rotation_set(dev, e_comp_screen->rotation);
1352 e_input_device_rotation_set(dev, e_comp_screen->rotation);
1354 ELOGF("COMP_SCREEN","EE Input Device Rotate: %d", NULL, e_comp_screen->rotation);
1357 if (e_comp_screen_iface)
1359 eldbus_service_signal_emit(e_comp_screen_iface, E_COMP_SCREEN_SIGNAL_ROTATION_CHANGED, e_comp_screen->rotation);
1360 ELOGF("COMP_SCREEN", "screen-rotation sends signal: %d", NULL, e_comp_screen->rotation);
1363 ELOGF("COMP_SCREEN","EE Rotated and Resized: %d, %dx%d", NULL, e_comp_screen->rotation, w, h);
1369 _e_comp_screen_rotation_pre_setter(E_Comp_Screen *e_comp_screen, int rotation_pre)
1371 e_comp_screen->rotation_pre = rotation_pre;
1372 ELOGF("COMP_SCREEN","EE RotationPre: %d", NULL, rotation_pre);
1376 e_comp_screen_rotation_pre_set(E_Comp_Screen *e_comp_screen, int rotation_pre)
1378 int screen_rotation;
1380 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
1381 EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation_pre % 90, EINA_FALSE);
1382 EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation_pre < 0, EINA_FALSE);
1383 EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation_pre > 270, EINA_FALSE);
1385 if (e_comp_screen->rotation_pre == rotation_pre) return EINA_TRUE;
1387 screen_rotation = (rotation_pre + e_comp_screen->rotation_setting) % 360;
1389 return _e_comp_screen_rotation_set(e_comp_screen, screen_rotation,
1390 _e_comp_screen_rotation_pre_setter, rotation_pre);
1394 _e_comp_screen_rotation_setting_setter(E_Comp_Screen *e_comp_screen, int rotation)
1396 e_comp_screen->rotation_setting = rotation;
1397 ELOGF("COMP_SCREEN","EE RotationSetting: %d", NULL, rotation);
1401 e_comp_screen_rotation_setting_set(E_Comp_Screen *e_comp_screen, int rotation)
1403 int screen_rotation;
1405 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
1406 EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation % 90, EINA_FALSE);
1407 EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation < 0, EINA_FALSE);
1408 EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation > 270, EINA_FALSE);
1410 if (e_comp_screen->rotation_setting == rotation) return EINA_TRUE;
1412 screen_rotation = (e_comp_screen->rotation_pre + rotation) % 360;
1414 return _e_comp_screen_rotation_set(e_comp_screen, screen_rotation,
1415 _e_comp_screen_rotation_setting_setter, rotation);
1419 e_comp_screen_rotation_ignore_output_transform_send(E_Client *ec, Eina_Bool ignore)
1421 E_Comp_Screen_Tzsr *tzsr = _tz_surface_rotation_find(ec);
1422 E_Comp_Wl_Client_Data *cdata;
1426 /* if client have to considers the output transform */
1430 if (e_config->screen_rotation_client_ignore)
1432 ELOGF("TRANSFORM", "|tzsr(%p) ignore_output_transform: client_ignore", ec, tzsr);
1436 if (e_policy_client_is_quickpanel(ec))
1438 ELOGF("TRANSFORM", "|tzsr(%p) ignore_output_transform: quickpanel", ec, tzsr);
1443 ELOGF("TRANSFORM", "|tzsr(%p) ignore_output_transform(%d)", ec, tzsr, ignore);
1445 cdata = e_client_cdata_get(ec);
1446 tizen_screen_rotation_send_ignore_output_transform(tzsr->resource, cdata->surface, ignore);
1450 e_comp_screen_rotation_ignore_output_transform_watch(E_Client *ec)
1452 return (_tz_surface_rotation_find(ec)) ? EINA_TRUE : EINA_FALSE;
1456 e_comp_screen_primary_output_get(E_Comp_Screen *e_comp_screen)
1458 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, NULL);
1460 E_Output *output = NULL, *o = NULL;
1461 Eina_List *l = NULL;
1462 int highest_priority = 0;
1464 /* find the highest priority of the e_output */
1465 EINA_LIST_FOREACH(e_comp_screen->outputs, l, o)
1467 if (highest_priority < o->config.priority)
1469 highest_priority = o->config.priority;
1478 e_comp_screen_pp_support(void)
1480 E_Comp_Screen *e_comp_screen = NULL;
1481 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp, EINA_FALSE);
1483 e_comp_screen = e_comp->e_comp_screen;
1484 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
1485 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen->tdisplay, EINA_FALSE);
1487 return e_comp_screen->pp_enabled;
1492 e_comp_screen_pp_available_formats_get(void)
1494 E_Comp_Screen *e_comp_screen = NULL;
1495 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp, EINA_FALSE);
1497 e_comp_screen = e_comp->e_comp_screen;
1498 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
1499 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen->tdisplay, EINA_FALSE);
1501 if (!e_comp_screen->pp_enabled)
1503 ERR("pp does not support.");
1507 return e_comp_screen->available_pp_formats;
1511 e_comp_screen_hwc_info_debug(void)
1513 EINA_SAFETY_ON_NULL_RETURN(e_comp);
1514 EINA_SAFETY_ON_NULL_RETURN(e_comp->e_comp_screen);
1516 E_Comp_Screen *e_comp_screen = e_comp->e_comp_screen;
1517 E_Output *output = NULL;
1518 E_Plane *plane = NULL;
1519 Eina_List *l_o, *ll_o;
1520 Eina_List *l_l, *ll_l;
1521 tdm_output_conn_status conn_status;
1523 tdm_layer_capability layer_capabilities;
1524 char layer_cap[4096] = {0, };
1526 const tdm_prop *tprops;
1529 INF("HWC: HWC Information ==========================================================");
1530 EINA_LIST_FOREACH_SAFE(e_comp_screen->outputs, l_o, ll_o, output)
1532 tdm_error err = TDM_ERROR_NONE;
1534 if (!output) continue;
1536 if (e_hwc_policy_get(output->hwc) == E_HWC_POLICY_PLANES)
1538 err = tdm_output_get_conn_status(output->toutput, &conn_status);
1539 if (err != TDM_ERROR_NONE) continue;
1540 if (conn_status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED) continue;
1542 INF("HWC: HWC Output(%d):(x, y, w, h)=(%d, %d, %d, %d) Information.",
1544 output->config.geom.x, output->config.geom.y, output->config.geom.w, output->config.geom.h);
1545 INF("HWC: num_layers=%d", output->plane_count);
1546 EINA_LIST_FOREACH_SAFE(output->planes, l_l, ll_l, plane)
1548 if (!plane) continue;
1549 /* FIXME: hwc extension doesn't provide thing like layer */
1550 tdm_layer_get_capabilities(plane->tlayer, &layer_capabilities);
1551 snprintf(layer_cap, sizeof(layer_cap), "%s%s%s%s%s%s%s%s",
1552 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_CURSOR),
1553 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_PRIMARY),
1554 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_OVERLAY),
1555 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_GRAPHIC),
1556 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_VIDEO),
1557 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_TRANSFORM),
1558 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_RESEVED_MEMORY),
1559 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_NO_CROP));
1560 INF("HWC: index=%d zpos=%d ec=%p %s",
1561 plane->index, plane->zpos,
1562 plane->ec?plane->ec:NULL,
1568 /* TODO: construct debug info for outputs managed by the hwc-wins */
1569 INF("HWC: HWC Output(%d) managed by hwc-wins.", ++output_idx);
1571 if (!e_hwc_windows_get_available_properties(output->hwc, &tprops, &count))
1573 ERR("e_hwc_windows_get_video_available_properties failed");
1576 INF(">>>>>>>> Available UI props : count = %d", count);
1577 for (i = 0; i < count; i++)
1578 INF(" [%d] %s, %u", i, tprops[i].name, tprops[i].id);
1580 if (!e_hwc_windows_get_video_available_properties(output->hwc, &tprops, &count))
1582 ERR("e_hwc_windows_get_video_available_properties failed");
1585 INF(">>>>>>>> Available VIDEO props : count = %d", count);
1586 for (i = 0; i < count; i++)
1587 INF(" [%d] %s, %u", i, tprops[i].name, tprops[i].id);
1590 INF("HWC: =========================================================================");
1593 #define NUM_SW_FORMAT (sizeof(sw_formats) / sizeof(sw_formats[0]))
1595 static tbm_format sw_formats[] = {
1596 TBM_FORMAT_ARGB8888,
1597 TBM_FORMAT_XRGB8888,
1603 _e_comp_screen_video_tdm_layer_get(tdm_output *output)
1606 #ifdef CHECKING_PRIMARY_ZPOS
1607 int primary_idx = 0, primary_zpos = 0;
1608 tdm_layer *primary_layer;
1611 EINA_SAFETY_ON_NULL_RETURN_VAL(output, NULL);
1613 tdm_output_get_layer_count(output, &count);
1614 for (i = 0; i < count; i++)
1616 tdm_layer *layer = tdm_output_get_layer(output, i, NULL);
1617 tdm_layer_capability capabilities = 0;
1618 EINA_SAFETY_ON_NULL_RETURN_VAL(layer, NULL);
1620 tdm_layer_get_capabilities(layer, &capabilities);
1621 if (capabilities & TDM_LAYER_CAPABILITY_VIDEO)
1625 #ifdef CHECKING_PRIMARY_ZPOS
1626 tdm_output_get_primary_index(output, &primary_idx);
1627 primary_layer = tdm_output_get_layer(output, primary_idx, NULL);
1628 EINA_SAFETY_ON_NULL_RETURN_VAL(primary_layer, NULL);
1629 tdm_layer_get_zpos(primary_layer, &primary_zpos);
1632 for (i = 0; i < count; i++)
1634 tdm_layer *layer = tdm_output_get_layer(output, i, NULL);
1635 tdm_layer_capability capabilities = 0;
1636 EINA_SAFETY_ON_NULL_RETURN_VAL(layer, NULL);
1638 tdm_layer_get_capabilities(layer, &capabilities);
1639 if (capabilities & TDM_LAYER_CAPABILITY_OVERLAY)
1641 #ifdef CHECKING_PRIMARY_ZPOS
1643 tdm_layer_get_zpos(layer, &zpos);
1644 if (zpos >= primary_zpos) continue;
1654 _e_comp_screen_eoutput_get_by_toutput(tdm_output *output)
1659 EINA_LIST_FOREACH(e_comp->e_comp_screen->outputs, l, eo)
1660 if (eo->toutput == output)
1667 e_comp_screen_available_video_formats_get(const tbm_format **formats, int *count)
1670 tdm_output *toutput;
1676 if (e_comp_screen_pp_support())
1678 error = tdm_display_get_pp_available_formats(e_comp->e_comp_screen->tdisplay, formats, count);
1679 if (error == TDM_ERROR_NONE)
1683 /* get the first output */
1684 toutput = tdm_display_get_output(e_comp->e_comp_screen->tdisplay, 0, NULL);
1688 output = _e_comp_screen_eoutput_get_by_toutput(toutput);
1692 if (e_hwc_policy_get(output->hwc) != E_HWC_POLICY_WINDOWS)
1694 /* get the first suitable layer */
1695 layer = _e_comp_screen_video_tdm_layer_get(toutput);
1698 tdm_layer_get_available_formats(layer, formats, count);
1702 *formats = sw_formats;
1703 *count = NUM_SW_FORMAT;
1708 error = tdm_hwc_get_video_supported_formats(output->hwc->thwc, formats, count);
1709 if (error != TDM_ERROR_NONE)
1711 *formats = sw_formats;
1712 *count = NUM_SW_FORMAT;
1720 e_comp_screen_gbm_device_get(E_Comp_Screen *e_comp_screen)
1724 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, NULL);
1726 if (e_comp_screen->gdevice) return e_comp_screen->gdevice;
1728 fd = tbm_drm_helper_get_master_fd();
1729 EINA_SAFETY_ON_FALSE_RETURN_VAL(fd >= 0, NULL);
1731 e_comp_screen->gdevice = gbm_create_device(fd);
1732 if (!e_comp_screen->gdevice)
1734 ERR("fail to create gbm device");
1739 e_comp_screen->gdevice_fd = fd;
1741 return e_comp_screen->gdevice;
1745 e_comp_screen_size_get(E_Comp_Screen *e_comp_screen, int *w, int *h)
1747 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
1749 if (w) *w = e_comp_screen->w;
1750 if (h) *h = e_comp_screen->h;
1755 _e_comp_screen_dpms_to_string(E_OUTPUT_DPMS dpms)
1759 case E_OUTPUT_DPMS_ON:
1762 case E_OUTPUT_DPMS_STANDBY:
1763 return "DPMS_STANDBY";
1765 case E_OUTPUT_DPMS_SUSPEND:
1766 return "DPMS_SUSPEND";
1768 case E_OUTPUT_DPMS_OFF:
1777 e_comp_screen_debug_info_get(Eldbus_Message_Iter *iter)
1779 Eldbus_Message_Iter *line_array;
1780 E_Comp_Screen *e_comp_screen = NULL;
1781 E_Output *output = NULL;
1784 char info_str[1024];
1786 e_comp_screen = e_comp->e_comp_screen;
1788 eldbus_message_iter_arguments_append(iter, "as", &line_array);
1791 eldbus_message_iter_basic_append(line_array,
1793 "e_comp_screen not initialized..");
1794 eldbus_message_iter_container_close(iter, line_array);
1798 eldbus_message_iter_basic_append(line_array, 's',
1799 "===========================================================================================");
1800 eldbus_message_iter_basic_append(line_array, 's',
1801 " idx id status dpms ( x , y ) ( w x h ) ");
1802 eldbus_message_iter_basic_append(line_array, 's',
1803 "===========================================================================================");
1805 EINA_LIST_FOREACH(e_comp_screen->outputs, l, output)
1807 if (!output) continue;
1809 if (!output->hwc) continue;
1810 if (e_hwc_policy_get(hwc) == E_HWC_POLICY_NONE) continue;
1812 snprintf(info_str, sizeof(info_str), "%2d %12s %15s %10s (%5d , %5d) (%5d x %5d)",
1813 output->index, output->id,
1814 output->info.connected ? "connected" : "disconnected",
1815 _e_comp_screen_dpms_to_string(output->dpms),
1816 output->config.geom.x, output->config.geom.y,
1817 output->config.geom.w, output->config.geom.h);
1819 eldbus_message_iter_basic_append(line_array, 's', info_str);
1822 eldbus_message_iter_basic_append(line_array, 's',
1823 "===========================================================================================");
1825 eldbus_message_iter_container_close(iter, line_array);
1829 e_comp_screen_outputs_get(E_Comp_Screen *e_comp_screen)
1831 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, NULL);
1833 return e_comp_screen->outputs;