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"
23 #include "e_linux_dmabuf_intern.h"
25 #include <tizen-extension-server-protocol.h>
26 #include <device/board-internal.h>
27 #include <tbm_drm_helper.h>
30 #define PATH "/org/enlightenment/wm"
31 #define IFACE "org.enlightenment.wm.screen_rotation"
33 static Ecore_Event_Handler *dbus_init_done_handler;
34 static Eldbus_Connection *edbus_conn = NULL;
35 static Eldbus_Connection_Type edbus_conn_type = ELDBUS_CONNECTION_TYPE_SYSTEM;
36 static Eldbus_Service_Interface *e_comp_screen_iface;
38 static Eina_List *event_handlers = NULL;
39 static Eina_List *output_hooks = NULL;
41 EINTERN int E_EVENT_SCREEN_CHANGE = 0;
45 E_COMP_SCREEN_SIGNAL_ROTATION_CHANGED = 0
48 typedef struct _E_Comp_Screen_Tzsr
50 struct wl_resource *resource; /* tizen_screen_rotation */
52 struct wl_listener ec_destroy;
55 static Eina_List *tzsr_list;
56 static E_Client_Hook *tzsr_client_hook_del;
58 static void _tz_screen_rotation_cb_ec_destroy(struct wl_listener *listener, void *data);
60 static E_Comp_Screen_Tzsr*
61 _tz_surface_rotation_find(E_Client *ec)
63 E_Comp_Screen_Tzsr *tzsr = NULL;
64 struct wl_listener *listener;
66 listener = e_client_destroy_listener_get(ec, _tz_screen_rotation_cb_ec_destroy);
68 return wl_container_of(listener, tzsr, ec_destroy);
74 _tz_surface_rotation_free(E_Comp_Screen_Tzsr *tzsr)
76 ELOGF("TRANSFORM", "|tzsr(%p) freed", tzsr->ec, tzsr);
77 tzsr_list = eina_list_remove(tzsr_list, tzsr);
78 wl_list_remove(&tzsr->ec_destroy.link);
83 _tz_screen_rotation_cb_ec_destroy(struct wl_listener *listener, void *data)
85 E_Comp_Screen_Tzsr *tzsr;
87 tzsr = wl_container_of(listener, tzsr, ec_destroy);
88 _tz_surface_rotation_free(tzsr);
92 _tz_screen_rotation_get_ignore_output_transform(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface)
94 E_Comp_Screen_Tzsr *tzsr;
96 E_Hwc_Policy hwc_policy;
99 Eina_Bool ignore = EINA_TRUE;
101 ec = e_client_from_surface_resource(surface);
102 EINA_SAFETY_ON_NULL_RETURN(ec);
104 tzsr = _tz_surface_rotation_find(ec);
107 tzsr = E_NEW(E_Comp_Screen_Tzsr, 1);
110 wl_client_post_no_memory(client);
114 tzsr->resource = resource;
117 tzsr->ec_destroy.notify = _tz_screen_rotation_cb_ec_destroy;
118 e_client_destroy_listener_add(ec, &tzsr->ec_destroy);
120 tzsr_list = eina_list_append(tzsr_list, tzsr);
122 zone = e_comp_zone_find_by_ec(ec);
125 output = e_output_find(zone->output_id);
128 hwc_policy = e_hwc_policy_get(output->hwc);
129 if (hwc_policy == E_HWC_POLICY_WINDOWS)
134 ELOGF("TRANSFORM", "|tzsr(%p) client_ignore(%d) ignore(%d)",
135 ec, tzsr, e_config->screen_rotation_client_ignore, ignore);
137 e_comp_screen_rotation_ignore_output_transform_send(ec, ignore);
141 _tz_screen_rotation_iface_cb_destroy(struct wl_client *client, struct wl_resource *resource)
143 wl_resource_destroy(resource);
146 static const struct tizen_screen_rotation_interface _tz_screen_rotation_interface =
148 _tz_screen_rotation_get_ignore_output_transform,
149 _tz_screen_rotation_iface_cb_destroy,
152 static void _tz_screen_rotation_cb_destroy(struct wl_resource *resource)
154 E_Comp_Screen_Tzsr *tzsr;
157 EINA_LIST_FOREACH_SAFE(tzsr_list, l, ll, tzsr)
159 if (tzsr->resource == resource)
160 _tz_surface_rotation_free(tzsr);
165 _tz_screen_rotation_cb_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
167 struct wl_resource *res;
169 if (!(res = wl_resource_create(client, &tizen_screen_rotation_interface, version, id)))
171 ERR("Could not create tizen_screen_rotation resource: %m");
172 wl_client_post_no_memory(client);
176 wl_resource_set_implementation(res, &_tz_screen_rotation_interface, NULL, _tz_screen_rotation_cb_destroy);
179 static Eldbus_Message *
180 _e_comp_screen_dbus_get_cb(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
182 Eldbus_Message *reply = eldbus_message_method_return_new(msg);
185 if (e_comp && e_comp->e_comp_screen)
186 rotation = e_comp->e_comp_screen->rotation;
188 ELOGF("COMP_SCREEN","got screen-rotation 'get' request: %d", NULL, rotation);
190 eldbus_message_arguments_append(reply, "i", rotation);
195 static const Eldbus_Method methods[] =
197 {"get", NULL, ELDBUS_ARGS({"i", "int32"}), _e_comp_screen_dbus_get_cb, 0},
201 static const Eldbus_Signal signals[] = {
202 [E_COMP_SCREEN_SIGNAL_ROTATION_CHANGED] = {"changed", ELDBUS_ARGS({ "i", "rotation" }), 0},
206 static const Eldbus_Service_Interface_Desc iface_desc = {
207 IFACE, methods, signals, NULL, NULL, NULL
211 _e_comp_screen_dbus_init()
213 E_Comp_Screen *e_comp_screen = e_comp->e_comp_screen;
215 e_comp_screen_iface = eldbus_service_interface_register(edbus_conn,
218 EINA_SAFETY_ON_NULL_GOTO(e_comp_screen_iface, err);
220 if (e_comp_screen->rotation)
222 eldbus_service_signal_emit(e_comp_screen_iface, E_COMP_SCREEN_SIGNAL_ROTATION_CHANGED, e_comp_screen->rotation);
223 ELOGF("TRANSFORM", "screen-rotation sends signal: %d", NULL, e_comp_screen->rotation);
231 e_dbus_conn_connection_unref(edbus_conn);
239 _layer_cap_to_str(tdm_layer_capability caps, tdm_layer_capability cap)
243 if (cap == TDM_LAYER_CAPABILITY_CURSOR) return "cursor ";
244 else if (cap == TDM_LAYER_CAPABILITY_PRIMARY) return "primary ";
245 else if (cap == TDM_LAYER_CAPABILITY_OVERLAY) return "overlay ";
246 else if (cap == TDM_LAYER_CAPABILITY_GRAPHIC) return "graphics ";
247 else if (cap == TDM_LAYER_CAPABILITY_VIDEO) return "video ";
248 else if (cap == TDM_LAYER_CAPABILITY_TRANSFORM) return "transform ";
249 else if (cap == TDM_LAYER_CAPABILITY_RESEVED_MEMORY) return "reserved_memory ";
250 else if (cap == TDM_LAYER_CAPABILITY_NO_CROP) return "no_crop ";
251 else return "unkown";
257 _e_comp_screen_commit_idle_cb(void *data EINA_UNUSED)
260 E_Comp_Screen *e_comp_screen = NULL;
261 E_Output *output = NULL;
263 if (!e_comp->e_comp_screen) goto end;
265 if (e_config->comp_canvas_norender.use)
266 evas_norender(e_comp->evas);
268 if (e_comp->canvas_render_delayed) goto end;
270 e_comp_screen = e_comp->e_comp_screen;
272 EINA_LIST_FOREACH_SAFE(e_comp_screen->outputs, l, ll, output)
274 if (!output) continue;
275 if (!output->config.enabled) continue;
277 if (!e_output_commit(output))
278 ERR("fail to commit e_comp_screen->outputs.");
280 if (!e_output_render(output))
281 ERR("fail to render e_comp_screen->outputs.");
284 return ECORE_CALLBACK_RENEW;
288 _e_comp_screen_input_rotation_set(int rotation)
295 EINA_LIST_FOREACH(e_input_devices_get(), l, dev)
297 e_input_device_touch_rotation_set(dev, rotation);
298 e_input_device_rotation_set(dev, rotation);
300 ELOGF("COMP_SCREEN","EE Input Device Rotate: %d", NULL, rotation);
306 _e_comp_screen_cb_input_device_add(void *data, int type, void *event)
308 Ecore_Event_Device_Info *e;
311 if (!(e = event)) goto end;
313 if (e->clas == ECORE_DEVICE_CLASS_MOUSE)
315 if (comp->wl_comp_data->ptr.num_devices == 0)
317 e_pointer_object_set(comp->pointer, NULL, 0, 0);
318 e_comp_wl_input_pointer_enabled_set(EINA_TRUE);
320 comp->wl_comp_data->ptr.num_devices++;
322 else if (e->clas == ECORE_DEVICE_CLASS_KEYBOARD)
324 comp->wl_comp_data->kbd.num_devices++;
325 e_comp_wl_input_keyboard_enabled_set(EINA_TRUE);
327 else if (e->clas == ECORE_DEVICE_CLASS_TOUCH)
329 e_comp_wl_input_touch_enabled_set(EINA_TRUE);
330 _e_comp_screen_input_rotation_set(e_comp->e_comp_screen->rotation);
331 comp->wl_comp_data->touch.num_devices++;
335 return ECORE_CALLBACK_PASS_ON;
339 _e_comp_screen_pointer_renew(void)
341 if ((e_comp_wl->ptr.num_devices == 0) && e_comp_wl->ptr.ec && e_comp_wl->ptr.ec->pointer_enter_sent)
343 if (e_devicemgr->last_device_ptr)
345 Evas_Device *last_ptr = NULL, *dev;
348 const char *description;
350 list = (Eina_List *)evas_device_list(evas_object_evas_get(e_comp_wl->ptr.ec->frame), NULL);
351 EINA_LIST_FOREACH(list, l, dev)
353 name = evas_device_name_get(dev);
354 description = evas_device_description_get(dev);
356 if (!name || !description) continue;
357 if ((!strncmp(name, e_devicemgr->last_device_ptr->name, strlen(e_devicemgr->last_device_ptr->name))) &&
358 (!strncmp(description, e_devicemgr->last_device_ptr->identifier, strlen(e_devicemgr->last_device_ptr->identifier))) &&
359 (evas_device_class_get(dev) == (Evas_Device_Class)e_devicemgr->last_device_ptr->clas))
366 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);
372 _e_comp_screen_cb_input_device_del(void *data, int type, void *event)
374 Ecore_Event_Device_Info *e;
377 if (!(e = event)) goto end;
379 if (e->clas == ECORE_DEVICE_CLASS_MOUSE)
381 comp->wl_comp_data->ptr.num_devices--;
382 if (comp->wl_comp_data->ptr.num_devices == 0)
384 e_comp_wl_input_pointer_enabled_set(EINA_FALSE);
385 e_pointer_object_set(comp->pointer, NULL, 0, 0);
386 e_pointer_hide(e_comp->pointer);
388 _e_comp_screen_pointer_renew();
391 else if (e->clas == ECORE_DEVICE_CLASS_KEYBOARD)
393 comp->wl_comp_data->kbd.num_devices--;
394 if (comp->wl_comp_data->kbd.num_devices == 0)
396 e_comp_wl_input_keyboard_enabled_set(EINA_FALSE);
399 else if (e->clas == ECORE_DEVICE_CLASS_TOUCH)
401 comp->wl_comp_data->touch.num_devices--;
402 if (comp->wl_comp_data->touch.num_devices == 0)
404 e_comp_wl_input_touch_enabled_set(EINA_FALSE);
410 return ECORE_CALLBACK_PASS_ON;
414 _e_comp_screen_size_update(E_Comp_Screen *e_comp_screen)
417 int sum_w = 0, max_h = 0, output_w, output_h;
420 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
422 /* we place external output to the right of primary output */
423 EINA_LIST_FOREACH(e_comp_screen->outputs, l, output)
425 if (!e_output_connected(output)) continue;
427 e_output_size_get(output, &output_w, &output_h);
430 if (max_h < output_h)
434 e_comp_screen->w = sum_w;
435 e_comp_screen->h = max_h;
439 /* rotation should be reset because tbm_surface_queue or gbm_surface of
440 * ecore_evas is created without rotation
441 * and rotation of ecore_evas is reset after it is resized
443 if (e_comp_screen->rotation)
444 ecore_evas_rotation_with_resize_set(e_comp->ee, 0);
446 ecore_evas_resize(e_comp->ee, e_comp_screen->w, e_comp_screen->h);
448 if (e_comp_screen->rotation)
449 ecore_evas_rotation_with_resize_set(e_comp->ee, e_comp_screen->rotation);
456 _e_comp_screen_cb_event(void *data, Ecore_Fd_Handler *hdlr EINA_UNUSED)
458 E_Comp_Screen *e_comp_screen;
461 if (!(e_comp_screen = data)) return ECORE_CALLBACK_RENEW;
463 ret = tdm_display_handle_events(e_comp_screen->tdisplay);
464 if (ret != TDM_ERROR_NONE)
465 ERR("tdm_display_handle_events failed");
467 return ECORE_CALLBACK_RENEW;
470 static E_Comp_Screen *
471 _e_comp_screen_new(E_Comp *comp)
473 E_Comp_Screen *e_comp_screen = NULL;
474 tdm_error error = TDM_ERROR_NONE;
475 tdm_display_capability capabilities;
476 const tbm_format *pp_formats;
480 e_comp_screen = E_NEW(E_Comp_Screen, 1);
481 if (!e_comp_screen) return NULL;
483 /* tdm display init */
484 e_main_ts_begin("\tTDM Display Init");
485 e_comp_screen->tdisplay = tdm_display_init(&error);
486 if (!e_comp_screen->tdisplay)
488 e_main_ts_end("\tTDM Display Init Failed");
489 ERR("fail to get tdm_display\n");
493 e_main_ts_end("\tTDM Display Init Done");
495 e_comp_screen->gdevice_fd = -1;
496 e_comp_screen->fd = -1;
497 tdm_display_get_fd(e_comp_screen->tdisplay, &fd);
500 ERR("fail to get tdm_display fd\n");
504 e_comp_screen->fd = dup(fd);
506 e_comp_screen->hdlr =
507 ecore_main_fd_handler_add(e_comp_screen->fd, ECORE_FD_READ,
508 _e_comp_screen_cb_event, e_comp_screen, NULL, NULL);
509 /* tdm display init */
510 e_main_ts_begin("\tTBM Bufmgr Server Init");
511 e_comp_screen->bufmgr = tbm_bufmgr_server_init();
512 if (!e_comp_screen->bufmgr)
514 e_main_ts_end("\tTBM Bufmgr Server Init Failed");
515 ERR("tbm_bufmgr_init failed\n");
518 e_main_ts_end("\tTBM Bufmgr Server Init Done");
520 error = tdm_display_get_capabilities(e_comp_screen->tdisplay, &capabilities);
521 if (error != TDM_ERROR_NONE)
523 ERR("tdm get_capabilities failed");
527 /* check the pp_support */
528 if (capabilities & TDM_DISPLAY_CAPABILITY_PP)
530 error = tdm_display_get_pp_available_formats(e_comp_screen->tdisplay, &pp_formats, &count);
531 if (error != TDM_ERROR_NONE)
532 ERR("fail to get available pp formats");
535 e_comp_screen->pp_enabled = EINA_TRUE;
536 for (i = 0 ; i < count ; i++)
537 e_comp_screen->available_pp_formats = eina_list_append(e_comp_screen->available_pp_formats, &pp_formats[i]);
541 e_main_ts_begin("\ttdm-socket Init");
542 if (e_comp_socket_init("tdm-socket"))
543 PRCTL("[Winsys] change permission and create sym link for %s", "tdm-socket");
544 e_main_ts_end("\ttdm-socket Init Done");
546 return e_comp_screen;
549 if (e_comp_screen->bufmgr) tbm_bufmgr_deinit(e_comp_screen->bufmgr);
550 if (e_comp_screen->fd >= 0) close(e_comp_screen->fd);
551 if (e_comp_screen->hdlr) ecore_main_fd_handler_del(e_comp_screen->hdlr);
552 if (e_comp_screen->tdisplay) tdm_display_deinit(e_comp_screen->tdisplay);
561 _e_comp_screen_del(E_Comp_Screen *e_comp_screen)
563 Eina_List *l = NULL, *ll = NULL;
566 if (!e_comp_screen) return;
568 if (e_comp_screen->pp_enabled)
570 EINA_LIST_FOREACH_SAFE(e_comp_screen->available_pp_formats, l, ll, formats)
572 if (!formats) continue;
573 e_comp_screen->available_pp_formats = eina_list_remove(e_comp_screen->available_pp_formats, l);
577 if (e_comp_screen->gdevice) gbm_device_destroy(e_comp_screen->gdevice);
578 if (e_comp_screen->gdevice_fd >= 0) close(e_comp_screen->gdevice_fd);
579 if (e_comp_screen->bufmgr) tbm_bufmgr_deinit(e_comp_screen->bufmgr);
580 if (e_comp_screen->fd >= 0) close(e_comp_screen->fd);
581 if (e_comp_screen->hdlr) ecore_main_fd_handler_del(e_comp_screen->hdlr);
582 if (e_comp_screen->tdisplay) tdm_display_deinit(e_comp_screen->tdisplay);
588 _e_comp_screen_output_mode_change_cb(tdm_output *toutput, unsigned int index, void *user_data)
590 E_Comp_Screen *e_comp_screen = user_data;
591 E_Output *output = NULL;
592 Eina_Bool find = EINA_FALSE;
594 E_Output_Mode *set_emode = NULL, *current_emode = NULL;
595 E_Output_Mode *emode = NULL;
596 Eina_List *modelist = NULL, *l, *ll;
598 EINA_SAFETY_ON_NULL_RETURN(e_comp_screen);
600 EINA_LIST_FOREACH_SAFE(e_comp_screen->outputs, l, ll, output)
602 if (output->toutput == toutput)
608 EINA_SAFETY_ON_FALSE_RETURN(find == EINA_TRUE);
610 current_emode = e_output_current_mode_get(output);
611 EINA_SAFETY_ON_NULL_RETURN(current_emode);
613 modelist = e_output_mode_list_get(output);
616 num = eina_list_count(modelist);
617 EINA_SAFETY_ON_FALSE_RETURN(index < num);
620 EINA_LIST_FOREACH(modelist, l, emode)
632 EINA_SAFETY_ON_TRUE_RETURN(current_emode == set_emode);
634 ELOGF("COMP_SCREEN","request mode change(%d) (%dx%d, %lf) -> (%dx%d, %lf)\n",
635 NULL, index, current_emode->w, current_emode->h, current_emode->refresh,
636 set_emode->w, set_emode->h, set_emode->refresh);
638 e_output_external_mode_change(output, set_emode);
644 _e_comp_screen_output_destroy_cb(tdm_output *toutput, void *user_data)
646 E_Comp_Screen *e_comp_screen = user_data;
647 E_Output *output = NULL;
650 EINA_SAFETY_ON_NULL_RETURN(e_comp_screen);
652 tdm_output_remove_destroy_handler(toutput, _e_comp_screen_output_destroy_cb, e_comp_screen);
654 EINA_LIST_FOREACH_SAFE(e_comp_screen->outputs, l, ll, output)
656 if (output->toutput == toutput)
658 e_comp_screen->num_outputs--;
659 e_comp_screen->outputs = eina_list_remove_list(e_comp_screen->outputs, l);
660 e_output_del(output);
666 _e_comp_screen_output_create_cb(tdm_display *dpy, tdm_output *toutput, void *user_data)
668 E_Comp_Screen *e_comp_screen = user_data;
669 E_Output *output = NULL;
670 tdm_error ret = TDM_ERROR_NONE;
672 EINA_SAFETY_ON_NULL_RETURN(e_comp_screen);
674 TRACE_DS_BEGIN(OUTPUT:NEW);
675 output = e_output_new(e_comp_screen, e_comp_screen->num_outputs);
676 EINA_SAFETY_ON_NULL_GOTO(output, fail);
677 if (output->toutput != toutput) goto fail;
680 TRACE_DS_BEGIN(OUTPUT:UPDATE);
681 if (!e_output_update(output))
683 ERR("fail to e_output_update.");
684 e_output_del(output);
689 /* todo : add tdm_output_add_mode_change_request_handler()*/
690 ret = tdm_output_add_mode_change_request_handler(toutput, _e_comp_screen_output_mode_change_cb, e_comp_screen);
691 if (ret != TDM_ERROR_NONE)
693 ERR("fail to add output mode change handler.");
694 e_output_del(output);
698 ret = tdm_output_add_destroy_handler(toutput, _e_comp_screen_output_destroy_cb, e_comp_screen);
699 if (ret != TDM_ERROR_NONE)
701 ERR("fail to add output destroy handler.");
702 e_output_del(output);
706 e_comp_screen->outputs = eina_list_append(e_comp_screen->outputs, output);
707 e_comp_screen->num_outputs++;
716 _e_comp_screen_deinit_outputs(E_Comp_Screen *e_comp_screen)
721 tdm_display_remove_output_create_handler(e_comp_screen->tdisplay, _e_comp_screen_output_create_cb, e_comp_screen);
723 e_hwc_ecore_evas_deinit();
726 EINA_LIST_FOREACH_SAFE(e_comp_screen->outputs, l, ll, output)
728 e_comp_screen->outputs = eina_list_remove_list(e_comp_screen->outputs, l);
729 e_output_del(output);
732 e_explicit_sync_deinit();
735 e_hwc_windows_deinit();
736 e_hwc_planes_deinit();
741 _e_comp_screen_fake_output_set(E_Comp_Screen *e_comp_screen)
743 E_Output *primary_output = NULL;
745 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
747 primary_output = e_comp_screen_primary_output_get(e_comp_screen);
748 EINA_SAFETY_ON_NULL_RETURN_VAL(primary_output, EINA_FALSE);
750 if (!e_output_hwc_setup(primary_output))
752 ERR("fail to e_output_hwc_setup.");
756 if (!e_output_fake_config_set(primary_output, 2, 1))
758 e_error_message_show(_("Fail to set the fake output config!\n"));
759 e_hwc_ecore_evas_deinit();
767 _e_comp_screen_init_outputs(E_Comp_Screen *e_comp_screen)
769 E_Output *output = NULL;
770 E_Output_Mode *mode = NULL;
771 tdm_display *tdisplay = e_comp_screen->tdisplay;
774 Eina_Bool scale_updated = EINA_FALSE;
775 Eina_Bool connection_check = EINA_FALSE;
776 tdm_error err = TDM_ERROR_NONE;
781 if (!e_output_init())
783 ERR("fail to e_output_init.");
787 /* get the num of outputs */
788 err = tdm_display_get_output_count(tdisplay, &num_outputs);
789 if ((err != TDM_ERROR_NONE) ||
792 ERR("fail to get tdm_display_get_output_count\n");
795 e_comp_screen->num_outputs = num_outputs;
797 ELOGF("COMP_SCREEN","num_outputs = %i", NULL, e_comp_screen->num_outputs);
801 ERR("e_hwc_init failed");
805 if (!e_hwc_planes_init())
807 ERR("e_hwc_planes_init failed");
811 if (!e_hwc_windows_init())
813 ERR("e_hwc_windows_init failed");
817 for (i = 0; i < num_outputs; i++)
819 e_main_ts_begin("\tE_Output New");
820 output = e_output_new(e_comp_screen, i);
823 e_main_ts_end("\tE_Output New Failed");
827 e_main_ts_begin("\tE_Output Update");
828 if (!e_output_update(output))
830 e_main_ts_end("\tE_Output Update Failed");
831 ERR("fail to e_output_update.");
834 e_main_ts_end("\tE_Output Update Done");
836 e_comp_screen->outputs = eina_list_append(e_comp_screen->outputs, output);
838 if (!e_output_connected(output)) continue;
840 connection_check = EINA_TRUE;
842 /* setting with the best mode and enable the output */
843 e_main_ts_begin("\tE_Output Find Best Mode");
844 mode = e_output_best_mode_find(output);
847 e_main_ts_end("\tE_Output Find Best Mode Failed");
848 ERR("fail to get best mode.");
851 e_main_ts_end("\tE_Output Find Best Mode Done");
853 e_main_ts_begin("\tE_Output Mode Apply");
854 if (!e_output_mode_apply(output, mode))
856 e_main_ts_end("\tE_Output Mode Apply Failed");
857 ERR("fail to e_output_mode_apply.");
860 e_main_ts_end("\tE_Output Mode Apply Done");
862 e_main_ts_begin("\tE_Output Set DPMS ON");
863 ret = device_board_get_boot_mode(bootmode, sizeof(bootmode));
864 if (!ret && !e_util_strcmp(bootmode, "silent"))
866 INF("silent reboot. do not set dpms");
870 if (!e_output_dpms_set(output, E_OUTPUT_DPMS_ON))
872 e_main_ts_end("\tE_Output Set DPMS ON Failed");
873 ERR("fail to e_output_dpms.");
878 e_main_ts_end("\tE_Output Set DPMS ON Done");
880 e_main_ts_begin("\tE_Output Hwc Setup");
881 if (!e_output_hwc_setup(output))
883 e_main_ts_end("\tE_Output Hwc Setup Failed");
884 ERR("fail to e_output_hwc_setup.");
887 e_main_ts_end("\tE_Output Hwc Setup Done");
889 /* update e_scale with first available output size */
890 if ((e_config->scale.for_tdm) && (!scale_updated))
895 target_inch = (round((sqrt(output->info.size.w * output->info.size.w + output->info.size.h * output->info.size.h) / 25.4) * 10) / 10);
896 dpi = (round((sqrt(mode->w * mode->w + mode->h * mode->h) / target_inch) * 10) / 10);
898 e_scale_manual_update(dpi);
899 scale_updated = EINA_TRUE;
903 //TODO: if there is no output connected, make the fake output which is connected.
904 if (!connection_check)
906 if (!_e_comp_screen_fake_output_set(e_comp_screen))
910 _e_comp_screen_size_update(e_comp_screen);
912 e_main_ts_begin("\tE_Hwc Ecore_Evas Init");
913 if (!e_hwc_ecore_evas_init())
915 e_main_ts_end("\ttE_Hwc Ecore_Evas Init Failed");
916 ERR("fail to e_hwc_ecore_evas_init");
919 e_main_ts_end("\tE_Hwc Ecore_Evas Init Done");
921 if (tdm_display_add_output_create_handler(tdisplay, _e_comp_screen_output_create_cb, e_comp_screen)) goto fail;
925 _e_comp_screen_deinit_outputs(e_comp_screen);
931 _e_comp_screen_e_screen_free(E_Screen *scr)
938 _e_comp_screen_e_screens_set(E_Comp_Screen *e_comp_screen, Eina_List *screens)
940 E_FREE_LIST(e_comp_screen->e_screens, _e_comp_screen_e_screen_free);
941 e_comp_screen->e_screens = screens;
945 _e_comp_screen_engine_deinit(void)
948 if (!e_comp->e_comp_screen) return;
950 _e_comp_screen_deinit_outputs(e_comp->e_comp_screen);
951 _e_comp_screen_del(e_comp->e_comp_screen);
952 e_comp->e_comp_screen = NULL;
956 _e_comp_screen_engine_init(void)
958 E_Comp_Screen *e_comp_screen = NULL;
961 /* check the screen rotation */
962 screen_rotation = (e_config->screen_rotation_pre + e_config->screen_rotation_setting) % 360;
964 ELOGF("COMP_SCREEN","screen_rotation_pre %d and screen_rotation_setting %d",
965 NULL, e_config->screen_rotation_pre, e_config->screen_rotation_setting);
967 /* e_comp_screen new */
968 e_main_ts_begin("\tE_Comp_Screen New");
969 e_comp_screen = _e_comp_screen_new(e_comp);
972 e_main_ts_end("\tE_Comp_Screen New Failed");
973 e_error_message_show(_("Enlightenment cannot create e_comp_screen!\n"));
976 e_main_ts_end("\tE_Comp_Screen New Done");
978 e_comp->e_comp_screen = e_comp_screen;
979 e_comp_screen->rotation_pre = e_config->screen_rotation_pre;
980 e_comp_screen->rotation_setting = e_config->screen_rotation_setting;
981 e_comp_screen->rotation = screen_rotation;
983 e_main_ts_begin("\tE_Comp_Screen Outputs Init");
984 if (!_e_comp_screen_init_outputs(e_comp_screen))
986 e_main_ts_end("\tE_Comp_Screen Outputs Init Failed");
987 e_error_message_show(_("Enlightenment cannot initialize outputs!\n"));
988 _e_comp_screen_engine_deinit();
991 e_main_ts_end("\tE_Comp_Screen Outputs Init Done");
993 if (!E_EVENT_SCREEN_CHANGE) E_EVENT_SCREEN_CHANGE = ecore_event_type_new();
995 ecore_event_add(E_EVENT_SCREEN_CHANGE, NULL, NULL, NULL);
997 e_comp_screen_e_screens_setup(e_comp_screen, -1, -1);
999 /* update the screen, outputs and planes at the idle enterer of the ecore_loop */
1000 ecore_idle_enterer_add(_e_comp_screen_commit_idle_cb, e_comp);
1006 _e_comp_screen_cb_dbus_init_done(void *data, int type, void *event)
1008 E_DBus_Conn_Init_Done_Event *e = event;
1010 if (e->status == E_DBUS_CONN_INIT_SUCCESS && e->conn_type == edbus_conn_type)
1012 edbus_conn = e_dbus_conn_connection_ref(edbus_conn_type);
1015 _e_comp_screen_dbus_init();
1018 ecore_event_handler_del(dbus_init_done_handler);
1019 dbus_init_done_handler = NULL;
1021 return ECORE_CALLBACK_PASS_ON;
1025 e_comp_screen_e_screens_setup(E_Comp_Screen *e_comp_screen, int rw, int rh)
1029 Eina_List *e_screens = NULL;
1031 int i = 0, right_x = 0;
1033 output = e_comp_screen_primary_output_get(e_comp_screen);
1034 /* No pirmary output means that there is no output at the system */
1035 if (!output) goto out;
1037 EINA_LIST_FOREACH(e_comp_screen->outputs, l, output)
1039 screen = E_NEW(E_Screen, 1);
1040 if (!screen) return;
1042 screen->escreen = screen->screen = i;
1044 if (output->config.rotation % 180)
1046 screen->w = output->config.geom.h;
1047 screen->h = output->config.geom.w;
1051 screen->w = output->config.geom.w;
1052 screen->h = output->config.geom.h;
1055 if (e_output_connected(output))
1057 output->config.geom.x = right_x;
1058 right_x += output->config.geom.w;
1062 output->config.geom.x = 0;
1065 screen->x = output->config.geom.x;
1066 screen->y = output->config.geom.y;
1068 if (output->id) screen->id = strdup(output->id);
1070 e_screens = eina_list_append(e_screens, screen);
1071 ELOGF("COMP_SCREEN","E INIT: SCREEN: [%i][%i], %ix%i+%i+%i",
1072 NULL, i, i, screen->w, screen->h, screen->x, screen->y);
1076 ELOGF("COMP_SCREEN","e_comp_screen_e_screens_setup............... %i %p\n", NULL, i, e_comp_screen->e_screens);
1078 ecore_event_add(E_EVENT_SCREEN_CHANGE, NULL, NULL, NULL);
1080 _e_comp_screen_e_screens_set(e_comp_screen, e_screens);
1084 screen = E_NEW(E_Screen, 1);
1085 if (!screen) return;
1086 screen->escreen = screen->screen = 0;
1089 if ((rw > 0) && (rh > 0))
1090 screen->w = rw, screen->h = rh;
1093 if (e_comp_screen->rotation % 180)
1094 ecore_evas_geometry_get(e_comp->ee, NULL, NULL, &screen->h, &screen->w);
1096 ecore_evas_geometry_get(e_comp->ee, NULL, NULL, &screen->w, &screen->h);
1098 e_screens = eina_list_append(e_screens, screen);
1100 ELOGF("COMP_SCREEN","E INIT: SCREEN: No Physical Screen : [%i][%i], %ix%i+%i+%i",
1101 NULL, i, i, screen->w, screen->h, screen->x, screen->y);
1103 _e_comp_screen_e_screens_set(e_comp_screen, e_screens);
1106 EINTERN const Eina_List *
1107 e_comp_screen_e_screens_get(E_Comp_Screen *e_comp_screen)
1109 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, NULL);
1111 return e_comp_screen->e_screens;
1115 _e_comp_screen_cb_output_connect_status_change(void *data, E_Output *output)
1117 _e_comp_screen_size_update(e_comp->e_comp_screen);
1121 _e_comp_screen_cb_output_mode_change(void *data, E_Output *output)
1123 _e_comp_screen_size_update(e_comp->e_comp_screen);
1127 e_comp_screen_init()
1130 int w, h, ptr_x = 0, ptr_y = 0;
1132 if (!(comp = e_comp))
1133 EINA_SAFETY_ON_NULL_RETURN_VAL(comp, EINA_FALSE);
1135 e_main_ts_begin("\tE_Comp_Screen_Engine Init");
1136 if (!_e_comp_screen_engine_init())
1138 e_main_ts_end("\tE_Comp_Screen_Engine Init Failed");
1139 ERR("Could not initialize the ecore_evas engine.");
1140 goto failed_comp_screen;
1142 e_main_ts_end("\tE_Comp_Screen_Engine Init Done");
1144 e_main_ts_begin("\tE_Input Init");
1145 if (!e_input_init(e_comp->ee))
1147 e_main_ts_end("\tE_Input Init Failed");
1148 ERR("Could not initialize the e_input.");
1149 goto failed_comp_screen;
1151 e_main_ts_end("\tE_Input Init Done");
1153 e_main_ts_begin("\tE_Comp_Wl Init");
1154 if (!e_comp_wl_init())
1156 e_main_ts_begin("\tE_Comp_Wl Init Failed");
1157 goto failed_comp_screen;
1159 e_main_ts_end("\tE_Comp_Wl Init Done");
1161 /* get the current screen geometry */
1162 ecore_evas_geometry_get(e_comp->ee, NULL, NULL, &w, &h);
1165 e_main_ts_begin("\tE_Comp_Canvas Init");
1166 if (!e_comp_canvas_init(w, h))
1168 e_main_ts_end("\tE_Comp_Canvas Init Failed");
1169 e_error_message_show(_("Enlightenment cannot initialize outputs!\n"));
1170 goto failed_comp_screen;
1172 e_main_ts_end("\tE_Comp_Canvas Init Done");
1174 e_main_ts_begin("\tE_Egl_Sync Init");
1175 if (e_egl_sync_init())
1176 ELOGF("E_EGL_SYNC", "Enabled the E_Egl_Sync", NULL);
1177 e_main_ts_end("\tE_Egl_Sync Init Done");
1179 e_main_ts_begin("\tE_Explicit_Sync Init");
1180 if (e_explicit_sync_init())
1181 ELOGF("EX-SYNC", "Enabled the E_Explicit_Sync", NULL);
1182 e_main_ts_end("\tE_Explicit_Sync Init Done");
1184 e_main_ts_begin("\tE_Linux_Dmabuf Init");
1185 e_linux_dmabuf_init(e_comp_wl->wl.disp);
1186 e_main_ts_end("\tE_Linux_Dmabuf Init Done");
1189 e_input_device_pointer_xy_get(NULL, &ptr_x, &ptr_y);
1190 e_comp_wl->ptr.x = wl_fixed_from_int(ptr_x);
1191 e_comp_wl->ptr.y = wl_fixed_from_int(ptr_y);
1193 evas_event_feed_mouse_in(e_comp->evas, 0, NULL);
1195 e_main_ts_begin("\tE_Pointer New");
1196 if ((comp->pointer = e_pointer_canvas_new(comp->ee, EINA_TRUE)))
1198 e_pointer_hide(comp->pointer);
1200 e_main_ts_end("\tE_Pointer New Done");
1202 /* FIXME: We need a way to trap for user changing the keymap inside of E
1203 * without the event coming from X11 */
1205 /* FIXME: We should make a decision here ...
1207 * Fetch the keymap from drm, OR set this to what the E config is....
1210 /* FIXME: This is just for testing at the moment....
1211 * happens to jive with what drm does */
1213 if (!e_input_thread_mode_get())
1215 e_main_ts_begin("\tE_Comp_WL Keymap Init");
1216 e_comp_wl_input_keymap_init();
1217 e_main_ts_begin("\tE_Comp_WL Keymap Init Done");
1220 /* try to add tizen_video to wayland globals */
1221 if (!wl_global_create(e_comp_wl->wl.disp, &tizen_screen_rotation_interface, 1,
1222 NULL, _tz_screen_rotation_cb_bind))
1224 ERR("Could not add tizen_screen_rotation to wayland globals");
1225 goto failed_comp_screen;
1228 if (!e_comp_wl_tizen_hwc_init())
1230 e_main_ts_end("\e_comp_wl_tizen_hwc_init Init Failed");
1231 e_error_message_show(_("Enlightenment cannot initialize tizen_hwc!\n"));
1232 goto failed_comp_screen;
1235 e_main_ts_begin("\tDBUS Init");
1236 dbus_init_done_handler = NULL;
1237 if (e_dbus_conn_init() > 0)
1239 dbus_init_done_handler = ecore_event_handler_add(E_EVENT_DBUS_CONN_INIT_DONE, _e_comp_screen_cb_dbus_init_done, NULL);
1240 e_dbus_conn_dbus_init(edbus_conn_type);
1242 e_main_ts_end("\tDBUS Init Done");
1244 E_LIST_HANDLER_APPEND(event_handlers, ECORE_EVENT_DEVICE_ADD, _e_comp_screen_cb_input_device_add, comp);
1245 E_LIST_HANDLER_PREPEND(event_handlers, ECORE_EVENT_DEVICE_DEL, _e_comp_screen_cb_input_device_del, comp);
1247 E_OUTPUT_HOOK_APPEND(output_hooks, E_OUTPUT_HOOK_CONNECT_STATUS_CHANGE, _e_comp_screen_cb_output_connect_status_change, comp);
1248 E_OUTPUT_HOOK_APPEND(output_hooks, E_OUTPUT_HOOK_MODE_CHANGE, _e_comp_screen_cb_output_mode_change, comp);
1250 _e_comp_screen_input_rotation_set(e_comp->e_comp_screen->rotation);
1256 e_comp_wl_tizen_hwc_shutdown();
1258 _e_comp_screen_engine_deinit();
1264 e_comp_screen_shutdown()
1266 if (!e_comp) return;
1267 if (!e_comp->e_comp_screen) return;
1269 e_comp_wl_tizen_hwc_shutdown();
1271 if (e_comp_screen_iface)
1273 eldbus_service_interface_unregister(e_comp_screen_iface);
1274 e_comp_screen_iface = NULL;
1279 e_dbus_conn_connection_unref(edbus_conn);
1283 e_dbus_conn_shutdown();
1285 _e_comp_screen_deinit_outputs(e_comp->e_comp_screen);
1287 E_FREE_LIST(output_hooks, e_output_hook_del);
1289 e_client_hook_del(tzsr_client_hook_del);
1290 tzsr_client_hook_del = NULL;
1292 E_FREE_LIST(event_handlers, ecore_event_handler_del);
1294 /* delete e_comp_sreen */
1295 _e_comp_screen_del(e_comp->e_comp_screen);
1296 e_comp->e_comp_screen = NULL;
1300 _e_comp_screen_output_find_primary(E_Comp_Screen *e_comp_screen)
1302 E_Output *output = NULL, *o;
1305 EINA_LIST_FOREACH(e_comp_screen->outputs, l, o)
1307 unsigned int pipe = 0;
1310 error = tdm_output_get_pipe(o->toutput, &pipe);
1311 if (error != TDM_ERROR_NONE || pipe != 0)
1320 ERR("couldn't find the primary output");
1328 _e_comp_screen_rotation_set(E_Comp_Screen *e_comp_screen, int screen_rotation,
1329 void (*setter)(E_Comp_Screen *e_comp_screen, int data), int data)
1331 E_Output *output = NULL;
1332 E_Input_Device *dev;
1336 output = _e_comp_screen_output_find_primary(e_comp_screen);
1340 if (!e_output_rotate(output, screen_rotation))
1343 e_comp_screen->rotation = screen_rotation;
1345 setter(e_comp_screen, data);
1347 ecore_evas_rotation_with_resize_set(e_comp->ee, e_comp_screen->rotation);
1348 ecore_evas_geometry_get(e_comp->ee, NULL, NULL, &w, &h);
1350 /* rendering forcely to prepare HWC */
1351 e_comp_render_queue();
1352 e_comp_hwc_end(__FUNCTION__);
1354 EINA_LIST_FOREACH(e_input_devices_get(), l, dev)
1356 e_input_device_touch_rotation_set(dev, e_comp_screen->rotation);
1357 e_input_device_rotation_set(dev, e_comp_screen->rotation);
1359 ELOGF("COMP_SCREEN","EE Input Device Rotate: %d", NULL, e_comp_screen->rotation);
1362 if (e_comp_screen_iface)
1364 eldbus_service_signal_emit(e_comp_screen_iface, E_COMP_SCREEN_SIGNAL_ROTATION_CHANGED, e_comp_screen->rotation);
1365 ELOGF("COMP_SCREEN", "screen-rotation sends signal: %d", NULL, e_comp_screen->rotation);
1368 ELOGF("COMP_SCREEN","EE Rotated and Resized: %d, %dx%d", NULL, e_comp_screen->rotation, w, h);
1374 _e_comp_screen_rotation_pre_setter(E_Comp_Screen *e_comp_screen, int rotation_pre)
1376 e_comp_screen->rotation_pre = rotation_pre;
1377 ELOGF("COMP_SCREEN","EE RotationPre: %d", NULL, rotation_pre);
1381 e_comp_screen_rotation_pre_set(E_Comp_Screen *e_comp_screen, int rotation_pre)
1383 int screen_rotation;
1385 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
1386 EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation_pre % 90, EINA_FALSE);
1387 EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation_pre < 0, EINA_FALSE);
1388 EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation_pre > 270, EINA_FALSE);
1390 if (e_comp_screen->rotation_pre == rotation_pre) return EINA_TRUE;
1392 screen_rotation = (rotation_pre + e_comp_screen->rotation_setting) % 360;
1394 return _e_comp_screen_rotation_set(e_comp_screen, screen_rotation,
1395 _e_comp_screen_rotation_pre_setter, rotation_pre);
1399 _e_comp_screen_rotation_setting_setter(E_Comp_Screen *e_comp_screen, int rotation)
1401 e_comp_screen->rotation_setting = rotation;
1402 ELOGF("COMP_SCREEN","EE RotationSetting: %d", NULL, rotation);
1406 e_comp_screen_rotation_setting_set(E_Comp_Screen *e_comp_screen, int rotation)
1408 int screen_rotation;
1410 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
1411 EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation % 90, EINA_FALSE);
1412 EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation < 0, EINA_FALSE);
1413 EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation > 270, EINA_FALSE);
1415 if (e_comp_screen->rotation_setting == rotation) return EINA_TRUE;
1417 screen_rotation = (e_comp_screen->rotation_pre + rotation) % 360;
1419 return _e_comp_screen_rotation_set(e_comp_screen, screen_rotation,
1420 _e_comp_screen_rotation_setting_setter, rotation);
1424 e_comp_screen_rotation_ignore_output_transform_send(E_Client *ec, Eina_Bool ignore)
1426 E_Comp_Screen_Tzsr *tzsr = _tz_surface_rotation_find(ec);
1427 E_Comp_Wl_Client_Data *cdata;
1431 /* if client have to considers the output transform */
1435 if (e_config->screen_rotation_client_ignore)
1437 ELOGF("TRANSFORM", "|tzsr(%p) ignore_output_transform: client_ignore", ec, tzsr);
1441 if (e_policy_client_is_quickpanel(ec))
1443 ELOGF("TRANSFORM", "|tzsr(%p) ignore_output_transform: quickpanel", ec, tzsr);
1448 ELOGF("TRANSFORM", "|tzsr(%p) ignore_output_transform(%d)", ec, tzsr, ignore);
1450 cdata = e_client_cdata_get(ec);
1451 tizen_screen_rotation_send_ignore_output_transform(tzsr->resource, cdata->surface, ignore);
1455 e_comp_screen_rotation_ignore_output_transform_watch(E_Client *ec)
1457 return (_tz_surface_rotation_find(ec)) ? EINA_TRUE : EINA_FALSE;
1461 e_comp_screen_primary_output_get(E_Comp_Screen *e_comp_screen)
1463 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, NULL);
1465 E_Output *output = NULL, *o = NULL;
1466 Eina_List *l = NULL;
1467 int highest_priority = 0;
1469 /* find the highest priority of the e_output */
1470 EINA_LIST_FOREACH(e_comp_screen->outputs, l, o)
1472 if (highest_priority < o->config.priority)
1474 highest_priority = o->config.priority;
1483 e_comp_screen_pp_support(void)
1485 E_Comp_Screen *e_comp_screen = NULL;
1486 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp, EINA_FALSE);
1488 e_comp_screen = e_comp->e_comp_screen;
1489 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
1490 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen->tdisplay, EINA_FALSE);
1492 return e_comp_screen->pp_enabled;
1497 e_comp_screen_pp_available_formats_get(void)
1499 E_Comp_Screen *e_comp_screen = NULL;
1500 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp, EINA_FALSE);
1502 e_comp_screen = e_comp->e_comp_screen;
1503 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
1504 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen->tdisplay, EINA_FALSE);
1506 if (!e_comp_screen->pp_enabled)
1508 ERR("pp does not support.");
1512 return e_comp_screen->available_pp_formats;
1516 e_comp_screen_hwc_info_debug(void)
1518 EINA_SAFETY_ON_NULL_RETURN(e_comp);
1519 EINA_SAFETY_ON_NULL_RETURN(e_comp->e_comp_screen);
1521 E_Comp_Screen *e_comp_screen = e_comp->e_comp_screen;
1522 E_Output *output = NULL;
1523 E_Plane *plane = NULL;
1524 Eina_List *l_o, *ll_o;
1525 Eina_List *l_l, *ll_l;
1526 tdm_output_conn_status conn_status;
1528 tdm_layer_capability layer_capabilities;
1529 char layer_cap[4096] = {0, };
1531 const tdm_prop *tprops;
1534 INF("HWC: HWC Information ==========================================================");
1535 EINA_LIST_FOREACH_SAFE(e_comp_screen->outputs, l_o, ll_o, output)
1537 tdm_error err = TDM_ERROR_NONE;
1539 if (!output) continue;
1541 if (e_hwc_policy_get(output->hwc) == E_HWC_POLICY_PLANES)
1543 err = tdm_output_get_conn_status(output->toutput, &conn_status);
1544 if (err != TDM_ERROR_NONE) continue;
1545 if (conn_status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED) continue;
1547 INF("HWC: HWC Output(%d):(x, y, w, h)=(%d, %d, %d, %d) Information.",
1549 output->config.geom.x, output->config.geom.y, output->config.geom.w, output->config.geom.h);
1550 INF("HWC: num_layers=%d", output->plane_count);
1551 EINA_LIST_FOREACH_SAFE(output->planes, l_l, ll_l, plane)
1553 if (!plane) continue;
1554 /* FIXME: hwc extension doesn't provide thing like layer */
1555 tdm_layer_get_capabilities(plane->tlayer, &layer_capabilities);
1556 snprintf(layer_cap, sizeof(layer_cap), "%s%s%s%s%s%s%s%s",
1557 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_CURSOR),
1558 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_PRIMARY),
1559 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_OVERLAY),
1560 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_GRAPHIC),
1561 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_VIDEO),
1562 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_TRANSFORM),
1563 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_RESEVED_MEMORY),
1564 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_NO_CROP));
1565 INF("HWC: index=%d zpos=%d ec=%p %s",
1566 plane->index, plane->zpos,
1567 plane->ec?plane->ec:NULL,
1573 /* TODO: construct debug info for outputs managed by the hwc-wins */
1574 INF("HWC: HWC Output(%d) managed by hwc-wins.", ++output_idx);
1576 if (!e_hwc_windows_get_available_properties(output->hwc, &tprops, &count))
1578 ERR("e_hwc_windows_get_video_available_properties failed");
1581 INF(">>>>>>>> Available UI props : count = %d", count);
1582 for (i = 0; i < count; i++)
1583 INF(" [%d] %s, %u", i, tprops[i].name, tprops[i].id);
1585 if (!e_hwc_windows_get_video_available_properties(output->hwc, &tprops, &count))
1587 ERR("e_hwc_windows_get_video_available_properties failed");
1590 INF(">>>>>>>> Available VIDEO props : count = %d", count);
1591 for (i = 0; i < count; i++)
1592 INF(" [%d] %s, %u", i, tprops[i].name, tprops[i].id);
1595 INF("HWC: =========================================================================");
1598 #define NUM_SW_FORMAT (sizeof(sw_formats) / sizeof(sw_formats[0]))
1600 static tbm_format sw_formats[] = {
1601 TBM_FORMAT_ARGB8888,
1602 TBM_FORMAT_XRGB8888,
1608 _e_comp_screen_video_tdm_layer_get(tdm_output *output)
1611 #ifdef CHECKING_PRIMARY_ZPOS
1612 int primary_idx = 0, primary_zpos = 0;
1613 tdm_layer *primary_layer;
1616 EINA_SAFETY_ON_NULL_RETURN_VAL(output, NULL);
1618 tdm_output_get_layer_count(output, &count);
1619 for (i = 0; i < count; i++)
1621 tdm_layer *layer = tdm_output_get_layer(output, i, NULL);
1622 tdm_layer_capability capabilities = 0;
1623 EINA_SAFETY_ON_NULL_RETURN_VAL(layer, NULL);
1625 tdm_layer_get_capabilities(layer, &capabilities);
1626 if (capabilities & TDM_LAYER_CAPABILITY_VIDEO)
1630 #ifdef CHECKING_PRIMARY_ZPOS
1631 tdm_output_get_primary_index(output, &primary_idx);
1632 primary_layer = tdm_output_get_layer(output, primary_idx, NULL);
1633 EINA_SAFETY_ON_NULL_RETURN_VAL(primary_layer, NULL);
1634 tdm_layer_get_zpos(primary_layer, &primary_zpos);
1637 for (i = 0; i < count; i++)
1639 tdm_layer *layer = tdm_output_get_layer(output, i, NULL);
1640 tdm_layer_capability capabilities = 0;
1641 EINA_SAFETY_ON_NULL_RETURN_VAL(layer, NULL);
1643 tdm_layer_get_capabilities(layer, &capabilities);
1644 if (capabilities & TDM_LAYER_CAPABILITY_OVERLAY)
1646 #ifdef CHECKING_PRIMARY_ZPOS
1648 tdm_layer_get_zpos(layer, &zpos);
1649 if (zpos >= primary_zpos) continue;
1659 _e_comp_screen_eoutput_get_by_toutput(tdm_output *output)
1664 EINA_LIST_FOREACH(e_comp->e_comp_screen->outputs, l, eo)
1665 if (eo->toutput == output)
1672 e_comp_screen_available_video_formats_get(const tbm_format **formats, int *count)
1675 tdm_output *toutput;
1681 if (e_comp_screen_pp_support())
1683 error = tdm_display_get_pp_available_formats(e_comp->e_comp_screen->tdisplay, formats, count);
1684 if (error == TDM_ERROR_NONE)
1688 /* get the first output */
1689 toutput = tdm_display_get_output(e_comp->e_comp_screen->tdisplay, 0, NULL);
1693 output = _e_comp_screen_eoutput_get_by_toutput(toutput);
1697 if (e_hwc_policy_get(output->hwc) != E_HWC_POLICY_WINDOWS)
1699 /* get the first suitable layer */
1700 layer = _e_comp_screen_video_tdm_layer_get(toutput);
1703 tdm_layer_get_available_formats(layer, formats, count);
1707 *formats = sw_formats;
1708 *count = NUM_SW_FORMAT;
1713 error = tdm_hwc_get_video_supported_formats(output->hwc->thwc, formats, count);
1714 if (error != TDM_ERROR_NONE)
1716 *formats = sw_formats;
1717 *count = NUM_SW_FORMAT;
1725 e_comp_screen_gbm_device_get(E_Comp_Screen *e_comp_screen)
1729 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, NULL);
1731 if (e_comp_screen->gdevice) return e_comp_screen->gdevice;
1733 fd = tbm_drm_helper_get_master_fd();
1734 EINA_SAFETY_ON_FALSE_RETURN_VAL(fd >= 0, NULL);
1736 e_comp_screen->gdevice = gbm_create_device(fd);
1737 if (!e_comp_screen->gdevice)
1739 ERR("fail to create gbm device");
1744 e_comp_screen->gdevice_fd = fd;
1746 return e_comp_screen->gdevice;
1750 e_comp_screen_size_get(E_Comp_Screen *e_comp_screen, int *w, int *h)
1752 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
1754 if (w) *w = e_comp_screen->w;
1755 if (h) *h = e_comp_screen->h;
1760 _e_comp_screen_dpms_to_string(E_OUTPUT_DPMS dpms)
1764 case E_OUTPUT_DPMS_ON:
1767 case E_OUTPUT_DPMS_STANDBY:
1768 return "DPMS_STANDBY";
1770 case E_OUTPUT_DPMS_SUSPEND:
1771 return "DPMS_SUSPEND";
1773 case E_OUTPUT_DPMS_OFF:
1782 e_comp_screen_debug_info_get(Eldbus_Message_Iter *iter)
1784 Eldbus_Message_Iter *line_array;
1785 E_Comp_Screen *e_comp_screen = NULL;
1786 E_Output *output = NULL;
1789 char info_str[1024];
1791 e_comp_screen = e_comp->e_comp_screen;
1793 eldbus_message_iter_arguments_append(iter, "as", &line_array);
1796 eldbus_message_iter_basic_append(line_array,
1798 "e_comp_screen not initialized..");
1799 eldbus_message_iter_container_close(iter, line_array);
1803 eldbus_message_iter_basic_append(line_array, 's',
1804 "===========================================================================================");
1805 eldbus_message_iter_basic_append(line_array, 's',
1806 " idx id status dpms ( x , y ) ( w x h ) ");
1807 eldbus_message_iter_basic_append(line_array, 's',
1808 "===========================================================================================");
1810 EINA_LIST_FOREACH(e_comp_screen->outputs, l, output)
1812 if (!output) continue;
1814 if (!output->hwc) continue;
1815 if (e_hwc_policy_get(hwc) == E_HWC_POLICY_NONE) continue;
1817 snprintf(info_str, sizeof(info_str), "%2d %12s %15s %10s (%5d , %5d) (%5d x %5d)",
1818 output->index, output->id,
1819 output->info.connected ? "connected" : "disconnected",
1820 _e_comp_screen_dpms_to_string(output->dpms),
1821 output->config.geom.x, output->config.geom.y,
1822 output->config.geom.w, output->config.geom.h);
1824 eldbus_message_iter_basic_append(line_array, 's', info_str);
1827 eldbus_message_iter_basic_append(line_array, 's',
1828 "===========================================================================================");
1830 eldbus_message_iter_container_close(iter, line_array);
1834 e_comp_screen_outputs_get(E_Comp_Screen *e_comp_screen)
1836 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, NULL);
1838 return e_comp_screen->outputs;