4 static Eina_List *event_handlers = NULL;
5 static Eina_Bool session_state = EINA_FALSE;
7 static Eina_Bool dont_set_ecore_drm_keymap = EINA_FALSE;
8 static Eina_Bool dont_use_xkb_cache = EINA_FALSE;
10 E_API int E_EVENT_SCREEN_CHANGE = 0;
12 typedef struct _E_Comp_Screen_Tzsr
14 struct wl_resource *resource; /* tizen_screen_rotation */
18 static Eina_List *tzsr_list;
19 static E_Client_Hook *tzsr_client_hook_del;
21 static E_Comp_Screen_Tzsr*
22 _tz_surface_rotation_find(E_Client *ec)
24 E_Comp_Screen_Tzsr *tzsr;
27 EINA_LIST_FOREACH(tzsr_list, l, tzsr)
37 _tz_surface_rotation_free(E_Comp_Screen_Tzsr *tzsr)
39 ELOGF("COMP", "|tzsr(%p)", NULL, tzsr->ec, tzsr);
40 tzsr_list = eina_list_remove(tzsr_list, tzsr);
45 _tz_screen_rotation_cb_client_del(void *data, E_Client *ec)
47 E_Comp_Screen_Tzsr *tzsr = _tz_surface_rotation_find(ec);
49 _tz_surface_rotation_free(tzsr);
53 _tz_screen_rotation_get_ignore_output_transform(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface)
55 E_Comp_Screen_Tzsr *tzsr;
58 ec = wl_resource_get_user_data(surface);
59 EINA_SAFETY_ON_NULL_RETURN(ec);
61 tzsr = _tz_surface_rotation_find(ec);
64 tzsr = E_NEW(E_Comp_Screen_Tzsr, 1);
67 wl_client_post_no_memory(client);
71 tzsr->resource = resource;
74 ELOGF("COMP", "|tzsr(%p)", NULL, ec, tzsr);
76 tzsr_list = eina_list_append(tzsr_list, tzsr);
79 static const struct tizen_screen_rotation_interface _tz_screen_rotation_interface =
81 _tz_screen_rotation_get_ignore_output_transform,
85 _tz_screen_rotation_cb_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
87 struct wl_resource *res;
89 if (!(res = wl_resource_create(client, &tizen_screen_rotation_interface, version, id)))
91 ERR("Could not create tizen_screen_rotation resource: %m");
92 wl_client_post_no_memory(client);
96 wl_resource_set_implementation(res, &_tz_screen_rotation_interface, NULL, NULL);
100 _layer_cap_to_str(tdm_layer_capability caps, tdm_layer_capability cap)
104 if (cap == TDM_LAYER_CAPABILITY_CURSOR) return "cursor ";
105 else if (cap == TDM_LAYER_CAPABILITY_PRIMARY) return "primary ";
106 else if (cap == TDM_LAYER_CAPABILITY_OVERLAY) return "overlay ";
107 else if (cap == TDM_LAYER_CAPABILITY_GRAPHIC) return "graphics ";
108 else if (cap == TDM_LAYER_CAPABILITY_VIDEO) return "video ";
109 else if (cap == TDM_LAYER_CAPABILITY_TRANSFORM) return "transform ";
110 else if (cap == TDM_LAYER_CAPABILITY_RESEVED_MEMORY) return "reserved_memory ";
111 else if (cap == TDM_LAYER_CAPABILITY_NO_CROP) return "no_crop ";
112 else return "unkown";
118 _e_comp_screen_cb_activate(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
120 Ecore_Drm_Event_Activate *e;
122 if (!(e = event)) goto end;
128 if (session_state) goto end;
129 session_state = EINA_TRUE;
131 ecore_evas_show(e_comp->ee);
134 if (ec->visible && (!ec->input_only))
135 e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
137 e_comp_render_queue();
138 e_comp_shape_queue_block(0);
139 ecore_event_add(E_EVENT_COMPOSITOR_ENABLE, NULL, NULL, NULL);
143 session_state = EINA_FALSE;
144 ecore_evas_hide(e_comp->ee);
145 edje_file_cache_flush();
146 edje_collection_cache_flush();
147 evas_image_cache_flush(e_comp->evas);
148 evas_font_cache_flush(e_comp->evas);
149 evas_render_dump(e_comp->evas);
151 e_comp_render_queue();
152 e_comp_shape_queue_block(1);
153 ecore_event_add(E_EVENT_COMPOSITOR_DISABLE, NULL, NULL, NULL);
157 return ECORE_CALLBACK_PASS_ON;
162 _e_comp_screen_cb_output_drm(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
166 Ecore_Drm_Event_Output *e;
167 E_Comp_Screen *e_comp_screen = NULL;
169 if (!(e = event)) goto end;
170 if (!e_comp) goto end;
171 if (!e_comp->e_comp_screen) goto end;
173 e_comp_screen = e_comp->e_comp_screen;
175 DBG("WL_DRM OUTPUT CHANGE");
177 EINA_LIST_FOREACH(e_comp_screen->outputs, l, output)
179 if ((!strcmp(output->info.name, e->name)) &&
180 (!strcmp(output->info.screen, e->model)))
184 if (!e_comp_wl_output_init(output->id, e->make, e->model,
185 e->x, e->y, e->w, e->h,
186 e->phys_width, e->phys_height,
187 e->refresh, e->subpixel_order,
190 ERR("Could not setup new output: %s", output->id);
194 e_comp_wl_output_remove(output->id);
200 /* previous calculation of e_scale gave unsuitable value because
201 * there were no sufficient information to calculate dpi.
202 * so it's considerable to re-calculate e_scale with output geometry.
207 target_inch = (round((sqrt(e->phys_width * e->phys_width + e->phys_height * e->phys_height) / 25.4) * 10) / 10);
208 dpi = (round((sqrt(e->w * e->w + e->h * e->h) / target_inch) * 10) / 10);
210 e_scale_manual_update(dpi);
213 return ECORE_CALLBACK_PASS_ON;
218 _e_comp_screen_commit_idle_cb(void *data EINA_UNUSED)
221 E_Comp_Screen *e_comp_screen = NULL;
222 E_Output *output = NULL;
224 if (!e_comp->e_comp_screen) goto end;
226 e_comp_screen = e_comp->e_comp_screen;
228 EINA_LIST_FOREACH_SAFE(e_comp_screen->outputs, l, ll, output)
230 if (!output) continue;
231 if (!output->config.enabled) continue;
233 if (!e_output_commit(output))
234 ERR("fail to commit e_comp_screen->outputs.");
236 if (!e_output_render(output))
237 ERR("fail to render e_comp_screen->outputs.");
242 return ECORE_CALLBACK_RENEW;
246 _e_comp_screen_cb_input_device_add(void *data, int type, void *event)
248 Ecore_Drm_Event_Input_Device_Add *e;
251 if (!(e = event)) goto end;
253 if (e->caps & EVDEV_SEAT_POINTER)
255 if (comp->wl_comp_data->ptr.num_devices == 0)
257 e_pointer_object_set(comp->pointer, NULL, 0, 0);
258 e_comp_wl_input_pointer_enabled_set(EINA_TRUE);
260 comp->wl_comp_data->ptr.num_devices++;
262 if (e->caps & EVDEV_SEAT_KEYBOARD)
264 comp->wl_comp_data->kbd.num_devices++;
265 e_comp_wl_input_keyboard_enabled_set(EINA_TRUE);
267 if (e->caps & EVDEV_SEAT_TOUCH)
269 e_comp_wl_input_touch_enabled_set(EINA_TRUE);
270 comp->wl_comp_data->touch.num_devices++;
274 return ECORE_CALLBACK_PASS_ON;
278 _e_comp_screen_cb_input_device_del(void *data, int type, void *event)
280 Ecore_Drm_Event_Input_Device_Del *e;
283 if (!(e = event)) goto end;
285 if (e->caps & EVDEV_SEAT_POINTER)
287 comp->wl_comp_data->ptr.num_devices--;
288 if (comp->wl_comp_data->ptr.num_devices == 0)
290 e_comp_wl_input_pointer_enabled_set(EINA_FALSE);
291 e_pointer_object_set(comp->pointer, NULL, 0, 0);
292 e_pointer_hide(e_comp->pointer);
298 return ECORE_CALLBACK_PASS_ON;
302 _e_comp_screen_cb_ee_resize(Ecore_Evas *ee EINA_UNUSED)
304 e_comp_canvas_update();
307 static E_Comp_Screen *
308 _e_comp_screen_new(E_Comp *comp)
310 E_Comp_Screen *e_comp_screen = NULL;
311 tdm_error error = TDM_ERROR_NONE;
313 e_comp_screen = E_NEW(E_Comp_Screen, 1);
314 if (!e_comp_screen) return NULL;
316 /* tdm display init */
317 e_comp_screen->tdisplay = tdm_display_init(&error);
318 if (!e_comp_screen->tdisplay)
320 ERR("fail to get tdm_display\n");
325 if (e_comp_socket_init("tdm-socket"))
326 PRCTL("[Winsys] change permission and create sym link for %s", "tdm-socket");
328 return e_comp_screen;
332 _e_comp_screen_del(E_Comp_Screen *e_comp_screen)
334 if (!e_comp_screen) return;
336 if (e_comp_screen->tdisplay) tdm_display_deinit(e_comp_screen->tdisplay);
342 _e_comp_screen_deinit_outputs(E_Comp_Screen *e_comp_screen)
347 EINA_LIST_FREE(e_comp_screen->outputs, output)
349 e_output_del(output);
356 _e_comp_screen_init_outputs(E_Comp_Screen *e_comp_screen)
358 E_Output *output = NULL;
359 E_Output_Mode *mode = NULL;
360 tdm_display *tdisplay = e_comp_screen->tdisplay;
363 Eina_Bool scale_updated = EINA_FALSE;
366 if (!e_output_init())
368 ERR("fail to e_output_init.");
372 /* get the num of outputs */
373 tdm_display_get_output_count(tdisplay, &num_outputs);
376 ERR("fail to get tdm_display_get_output_count\n");
379 e_comp_screen->num_outputs = num_outputs;
381 INF("E_COMP_SCREEN: num_outputs = %i", e_comp_screen->num_outputs);
383 for (i = 0; i < num_outputs; i++)
385 output = e_output_new(e_comp_screen, i);
386 if (!output) goto fail;
388 if (!e_output_update(output))
390 ERR("fail to e_output_update.");
394 e_comp_screen->outputs = eina_list_append(e_comp_screen->outputs, output);
396 if (!e_output_connected(output)) continue;
398 /* setting with the best mode and enable the output */
399 mode = e_output_best_mode_find(output);
402 ERR("fail to get best mode.");
406 if (!e_output_mode_apply(output, mode))
408 ERR("fail to e_output_mode_apply.");
411 if (!e_output_dpms_set(output, E_OUTPUT_DPMS_ON))
413 ERR("fail to e_output_dpms.");
417 /* update e_scale with first available output size */
418 if ((e_config->scale.for_tdm) && (!scale_updated))
423 target_inch = (round((sqrt(output->info.size.w * output->info.size.w + output->info.size.h * output->info.size.h) / 25.4) * 10) / 10);
424 dpi = (round((sqrt(mode->w * mode->w + mode->h * mode->h) / target_inch) * 10) / 10);
426 e_scale_manual_update(dpi);
427 scale_updated = EINA_TRUE;
431 //TODO: if there is no output connected, make the fake output which is connected.
436 _e_comp_screen_deinit_outputs(e_comp_screen);
442 _drm_read_pixels(E_Comp_Wl_Output *output, void *pixels)
444 Ecore_Drm_Device *dev;
445 Ecore_Drm_Fb *fb = NULL;
446 const Eina_List *drm_devs, *l;
448 unsigned char *s, *d = pixels;
450 drm_devs = ecore_drm_devices_get();
451 EINA_LIST_FOREACH(drm_devs, l, dev)
454 if (!fb) fb = dev->current;
458 if (!fb) return EINA_FALSE;
460 bstride = output->w * sizeof(int);
462 for (i = output->y; i < output->y + output->h; i++)
465 s += (fb->stride * i) + (output->x * sizeof(int));
466 memcpy(d, s, (output->w * sizeof(int)));
474 _e_comp_screen_keymap_set(struct xkb_context **ctx, struct xkb_keymap **map)
476 char *keymap_path = NULL;
477 struct xkb_context *context;
478 struct xkb_keymap *keymap;
479 struct xkb_rule_names names = {0,};
480 const char* default_rules, *default_model, *default_layout, *default_variant, *default_options;
482 TRACE_INPUT_BEGIN(_e_comp_screen_keymap_set);
484 context = xkb_context_new(0);
485 EINA_SAFETY_ON_NULL_RETURN(context);
487 /* assemble xkb_rule_names so we can fetch keymap */
488 memset(&names, 0, sizeof(names));
490 default_rules = e_comp_wl_input_keymap_default_rules_get();
491 default_model = e_comp_wl_input_keymap_default_model_get();
492 default_layout = e_comp_wl_input_keymap_default_layout_get();
493 default_variant = e_comp_wl_input_keymap_default_variant_get();
494 default_options = e_comp_wl_input_keymap_default_options_get();
496 names.rules = strdup(default_rules);
497 names.model = strdup(default_model);
498 names.layout = strdup(default_layout);
499 if (default_variant) names.variant = strdup(default_variant);
500 if (default_options) names.options = strdup(default_options);
502 keymap = e_comp_wl_input_keymap_compile(context, names, &keymap_path);
503 eina_stringshare_del(keymap_path);
504 EINA_SAFETY_ON_NULL_GOTO(keymap, cleanup);
509 if (dont_set_ecore_drm_keymap == EINA_FALSE)
511 ecore_drm_device_keyboard_cached_context_set(*ctx);
512 ecore_drm_device_keyboard_cached_keymap_set(*map);
516 free((char *)names.rules);
517 free((char *)names.model);
518 free((char *)names.layout);
519 if (names.variant) free((char *)names.variant);
520 if (names.options) free((char *)names.options);
526 _e_comp_screen_e_screen_sort_cb(const void *data1, const void *data2)
528 const E_Output *s1 = data1, *s2 = data2;
531 dif = -(s1->config.priority - s2->config.priority);
534 dif = s1->config.geom.x - s2->config.geom.x;
536 dif = s1->config.geom.y - s2->config.geom.y;
542 _e_comp_screen_e_screen_free(E_Screen *scr)
549 _e_comp_screen_e_screens_set(E_Comp_Screen *e_comp_screen, Eina_List *screens)
551 E_FREE_LIST(e_comp_screen->e_screens, _e_comp_screen_e_screen_free);
552 e_comp_screen->e_screens = screens;
556 _e_comp_screen_engine_deinit(void)
559 if (!e_comp->e_comp_screen) return;
561 _e_comp_screen_deinit_outputs(e_comp->e_comp_screen);
562 _e_comp_screen_del(e_comp->e_comp_screen);
563 e_comp->e_comp_screen = NULL;
567 _e_comp_screen_engine_init(void)
569 E_Comp_Screen *e_comp_screen = NULL;
570 int w = 0, h = 0, scr_w = 1, scr_h = 1;
573 E_Output *output = NULL;
575 INF("ecore evase engine init with TDM. HWC.");
577 /* check the screen rotation */
578 screen_rotation = (e_config->screen_rotation_pre + e_config->screen_rotation_setting) % 360;
580 INF("E_COMP_SCREEN: screen_rotation_pre %d and screen_rotation_setting %d",
581 e_config->screen_rotation_pre, e_config->screen_rotation_setting);
583 /* set env for use tbm_surface_queue*/
584 setenv("USE_EVAS_SOFTWARE_TBM_ENGINE", "1", 1);
586 /* set gl available if we have ecore_evas support */
587 if (ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_OPENGL_DRM))
588 e_comp_gl_set(EINA_TRUE);
590 /* e_comp_screen new */
591 e_comp_screen = _e_comp_screen_new(e_comp);
592 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
594 e_comp->e_comp_screen = e_comp_screen;
595 e_comp_screen->rotation = screen_rotation;
597 e_main_ts("\tE_Outputs Init");
598 if (!_e_comp_screen_init_outputs(e_comp_screen))
600 e_error_message_show(_("Enlightenment cannot initialize outputs!\n"));
601 _e_comp_screen_engine_deinit();
604 e_main_ts("\tE_Outputs Init Done");
606 /* get the primary output */
607 output = e_comp_screen_primary_output_get(e_comp_screen);
610 e_error_message_show(_("Fail to get the primary output!\n"));
611 _e_comp_screen_engine_deinit();
615 /* get the size of the primary output */
616 e_output_size_get(output, &scr_w, &scr_h);
618 INF("GL available:%d config engine:%d screen size:%dx%d",
619 e_comp_gl_get(), e_comp_config_get()->engine, scr_w, scr_h);
621 if ((e_comp_gl_get()) &&
622 (e_comp_config_get()->engine == E_COMP_ENGINE_GL))
624 e_main_ts("\tEE_GL_DRM New");
625 e_comp->ee = ecore_evas_gl_drm_new(NULL, 0, 0, 0, scr_w, scr_h);
626 snprintf(buf, sizeof(buf), "\tEE_GL_DRM New Done %p %dx%d", e_comp->ee, scr_w, scr_h);
630 e_comp_gl_set(EINA_FALSE);
633 Evas_GL *evasgl = NULL;
634 Evas_GL_API *glapi = NULL;
636 e_main_ts("\tEvas_GL New");
637 evasgl = evas_gl_new(ecore_evas_get(e_comp->ee));
640 glapi = evas_gl_api_get(evasgl);
641 if (!((glapi) && (glapi->evasglBindWaylandDisplay)))
643 e_comp_gl_set(EINA_FALSE);
644 ecore_evas_free(e_comp->ee);
646 e_main_ts("\tEvas_GL New Failed 1");
650 e_main_ts("\tEvas_GL New Done");
655 e_comp_gl_set(EINA_FALSE);
656 ecore_evas_free(e_comp->ee);
658 e_main_ts("\tEvas_GL New Failed 2");
660 evas_gl_free(evasgl);
664 /* fallback to framebuffer drm (non-accel) */
667 e_main_ts("\tEE_DRM New");
668 e_comp->ee = ecore_evas_drm_new(NULL, 0, 0, 0, scr_w, scr_h);
669 snprintf(buf, sizeof(buf), "\tEE_DRM New Done %p %dx%d", e_comp->ee, scr_w, scr_h);
675 e_error_message_show(_("Enlightenment cannot initialize outputs!\n"));
676 _e_comp_screen_engine_deinit();
680 ecore_evas_data_set(e_comp->ee, "comp", e_comp);
682 ecore_evas_callback_resize_set(e_comp->ee, _e_comp_screen_cb_ee_resize);
686 /* SHOULD called with resize option after ecore_evas_resize */
687 ecore_evas_rotation_with_resize_set(e_comp->ee, screen_rotation);
688 ecore_evas_geometry_get(e_comp->ee, NULL, NULL, &w, &h);
690 snprintf(buf, sizeof(buf), "\tEE Rotate and Resize %d, %dx%d", screen_rotation, w, h);
694 if (!E_EVENT_SCREEN_CHANGE) E_EVENT_SCREEN_CHANGE = ecore_event_type_new();
696 ecore_event_add(E_EVENT_SCREEN_CHANGE, NULL, NULL, NULL);
698 e_comp_screen_e_screens_setup(e_comp_screen, -1, -1);
700 /* TODO: need the output changed handler with TDM */
701 //E_LIST_HANDLER_APPEND(event_handlers, ECORE_DRM_EVENT_OUTPUT, _e_comp_screen_cb_output_drm, comp);
703 /* update the screen, outputs and planes at the idle enterer of the ecore_loop */
704 ecore_idle_enterer_add(_e_comp_screen_commit_idle_cb, e_comp);
710 e_comp_screen_e_screens_setup(E_Comp_Screen *e_comp_screen, int rw, int rh)
714 Eina_List *outputs = NULL, *outputs_rem;
715 Eina_List *e_screens = NULL;
717 E_Output *output, *s2, *s_chosen;
720 if (!e_comp_screen->outputs) goto out;
721 // put screens in tmp list
722 EINA_LIST_FOREACH(e_comp_screen->outputs, l, output)
724 if ((output->config.enabled) &&
725 (output->config.geom.w > 0) &&
726 (output->config.geom.h > 0))
728 outputs = eina_list_append(outputs, output);
731 // remove overlapping screens - if a set of screens overlap, keep the
732 // smallest/lowest res
735 removed = EINA_FALSE;
737 EINA_LIST_FOREACH(outputs, l, output)
741 EINA_LIST_FOREACH(l->next, ll, s2)
743 if (E_INTERSECTS(output->config.geom.x, output->config.geom.y,
744 output->config.geom.w, output->config.geom.h,
745 s2->config.geom.x, s2->config.geom.y,
746 s2->config.geom.w, s2->config.geom.h))
749 outputs_rem = eina_list_append(outputs_rem, output);
750 outputs_rem = eina_list_append(outputs_rem, s2);
753 // we have intersecting screens - choose the lowest res one
757 // find the smallest screen (chosen one)
759 EINA_LIST_FOREACH(outputs_rem, ll, s2)
761 if (!s_chosen) s_chosen = s2;
764 if ((s_chosen->config.geom.w *
765 s_chosen->config.geom.h) >
771 // remove all from screens but the chosen one
772 EINA_LIST_FREE(outputs_rem, s2)
775 outputs = eina_list_remove_list(outputs, l);
777 // break our list walk and try again
783 // sort screens by priority etc.
784 outputs = eina_list_sort(outputs, 0, _e_comp_screen_e_screen_sort_cb);
786 EINA_LIST_FOREACH(outputs, l, output)
788 screen = E_NEW(E_Screen, 1);
789 screen->escreen = screen->screen = i;
790 screen->x = output->config.geom.x;
791 screen->y = output->config.geom.y;
793 if (output->config.rotation % 180)
795 screen->w = output->config.geom.h;
796 screen->h = output->config.geom.w;
800 screen->w = output->config.geom.w;
801 screen->h = output->config.geom.h;
804 if (output->id) screen->id = strdup(output->id);
806 e_screens = eina_list_append(e_screens, screen);
807 INF("E INIT: SCREEN: [%i][%i], %ix%i+%i+%i",
808 i, i, screen->w, screen->h, screen->x, screen->y);
811 eina_list_free(outputs);
812 // if we have NO screens at all (above - i will be 0) AND we have no
813 // existing screens set up in xinerama - then just say root window size
814 // is the entire screen. this should handle the case where you unplug ALL
815 // screens from an existing setup (unplug external monitors and/or close
816 // laptop lid), in which case as long as at least one screen is configured
817 // in xinerama, it will be left-as is until next time we re-eval screen
818 // setup and have at least one screen
819 printf("e_comp_screen_e_screens_setup............... %i %p\n", i, e_comp_screen->e_screens);
820 if ((i == 0) && (!e_comp_screen->e_screens))
823 screen = E_NEW(E_Screen, 1);
824 screen->escreen = screen->screen = 0;
827 if ((rw > 0) && (rh > 0))
828 screen->w = rw, screen->h = rh;
831 if (e_comp_screen->rotation % 180)
832 ecore_evas_screen_geometry_get(e_comp->ee, NULL, NULL, &screen->h, &screen->w);
834 ecore_evas_screen_geometry_get(e_comp->ee, NULL, NULL, &screen->w, &screen->h);
836 e_screens = eina_list_append(e_screens, screen);
838 _e_comp_screen_e_screens_set(e_comp_screen, e_screens);
841 EINTERN const Eina_List *
842 e_comp_screen_e_screens_get(E_Comp_Screen *e_comp_screen)
844 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, NULL);
846 return e_comp_screen->e_screens;
854 struct xkb_context *ctx = NULL;
855 struct xkb_keymap *map = NULL;
857 TRACE_DS_BEGIN(E_COMP_SCREEN:INIT);
858 if (!(comp = e_comp))
861 EINA_SAFETY_ON_NULL_RETURN_VAL(comp, EINA_FALSE);
864 if (!_e_comp_screen_engine_init())
866 ERR("Could not initialize the ecore_evas engine.");
867 goto failed_comp_screen;
870 e_main_ts("\tE_Comp_Wl Init");
871 if (!e_comp_wl_init())
873 goto failed_comp_screen;
875 e_main_ts("\tE_Comp_Wl Init Done");
877 /* get the current screen geometry */
878 ecore_evas_screen_geometry_get(e_comp->ee, NULL, NULL, &w, &h);
881 e_main_ts("\tE_Comp_Canvas Init");
882 if (!e_comp_canvas_init(w, h))
884 e_error_message_show(_("Enlightenment cannot initialize outputs!\n"));
885 goto failed_comp_screen;
887 e_main_ts("\tE_Comp_Canvas Init Done");
889 e_comp_wl->screenshooter.read_pixels = _drm_read_pixels;
892 ecore_evas_pointer_xy_get(e_comp->ee,
896 evas_event_feed_mouse_in(e_comp->evas, 0, NULL);
898 e_main_ts("\tE_Pointer New");
899 if ((comp->pointer = e_pointer_canvas_new(comp->ee, EINA_TRUE)))
901 e_pointer_hide(comp->pointer);
903 if (comp->e_comp_screen->rotation)
906 Ecore_Drm_Device *dev;
907 EINA_LIST_FOREACH(ecore_drm_devices_get(), l, dev)
908 ecore_drm_device_pointer_rotation_set(dev, comp->e_comp_screen->rotation);
911 e_main_ts("\tE_Pointer New Done");
914 dont_set_ecore_drm_keymap = getenv("NO_ECORE_DRM_KEYMAP_CACHE") ? EINA_TRUE : EINA_FALSE;
915 dont_use_xkb_cache = getenv("NO_KEYMAP_CACHE") ? EINA_TRUE : EINA_FALSE;
917 if (e_config->xkb.use_cache && !dont_use_xkb_cache)
919 e_main_ts("\tDRM Keymap Init");
920 _e_comp_screen_keymap_set(&ctx, &map);
921 e_main_ts("\tDRM Keymap Init Done");
924 /* FIXME: We need a way to trap for user changing the keymap inside of E
925 * without the event coming from X11 */
927 /* FIXME: We should make a decision here ...
929 * Fetch the keymap from drm, OR set this to what the E config is....
932 /* FIXME: This is just for testing at the moment....
933 * happens to jive with what drm does */
934 e_main_ts("\tE_Comp_WL Keymap Init");
935 e_comp_wl_input_keymap_set(e_comp_wl_input_keymap_default_rules_get(),
936 e_comp_wl_input_keymap_default_model_get(),
937 e_comp_wl_input_keymap_default_layout_get(),
938 e_comp_wl_input_keymap_default_variant_get(),
939 e_comp_wl_input_keymap_default_options_get(),
941 e_main_ts("\tE_Comp_WL Keymap Init Done");
943 /* try to add tizen_video to wayland globals */
944 if (!wl_global_create(e_comp_wl->wl.disp, &tizen_screen_rotation_interface, 1,
945 NULL, _tz_screen_rotation_cb_bind))
947 ERR("Could not add tizen_screen_rotation to wayland globals");
948 goto failed_comp_screen;
951 /* this setup function is called after e_comp_canvas_init */
952 if (!e_comp_screen_setup(e_comp->e_comp_screen))
954 ERR("fail to e_comp_screen_setup");
958 tzsr_client_hook_del = e_client_hook_add(E_CLIENT_HOOK_DEL, _tz_screen_rotation_cb_client_del, NULL);
960 E_LIST_HANDLER_APPEND(event_handlers, ECORE_DRM_EVENT_ACTIVATE, _e_comp_screen_cb_activate, comp);
961 E_LIST_HANDLER_APPEND(event_handlers, ECORE_DRM_EVENT_INPUT_DEVICE_ADD, _e_comp_screen_cb_input_device_add, comp);
962 E_LIST_HANDLER_APPEND(event_handlers, ECORE_DRM_EVENT_INPUT_DEVICE_DEL, _e_comp_screen_cb_input_device_del, comp);
970 _e_comp_screen_engine_deinit();
978 e_comp_screen_shutdown()
981 if (!e_comp->e_comp_screen) return;
983 /* shutdown ecore_drm */
984 /* ecore_drm_shutdown(); */
986 _e_comp_screen_deinit_outputs(e_comp->e_comp_screen);
988 e_client_hook_del(tzsr_client_hook_del);
989 tzsr_client_hook_del = NULL;
991 dont_set_ecore_drm_keymap = EINA_FALSE;
992 dont_use_xkb_cache = EINA_FALSE;
993 E_FREE_LIST(event_handlers, ecore_event_handler_del);
995 /* delete e_comp_sreen */
996 _e_comp_screen_del(e_comp->e_comp_screen);
997 e_comp->e_comp_screen = NULL;
1001 e_comp_screen_setup(E_Comp_Screen *e_comp_screen)
1004 E_Output *output = NULL;
1006 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
1008 EINA_LIST_FOREACH_SAFE(e_comp_screen->outputs, l, ll, output)
1010 if (!output) continue;
1011 if (!output->config.enabled) continue;
1013 if (!e_output_setup(output))
1015 ERR("fail to e_ouptut_hwc_setup.");
1024 e_comp_screen_rotation_setting_set(E_Comp_Screen *e_comp_screen, int rotation)
1026 E_Output *output = NULL, *o;
1028 const Eina_List *ll;
1030 int screen_rotation;
1031 Ecore_Drm_Device *dev;
1033 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, EINA_FALSE);
1034 EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation % 90, EINA_FALSE);
1035 EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation < 0, EINA_FALSE);
1036 EINA_SAFETY_ON_TRUE_RETURN_VAL(rotation > 270, EINA_FALSE);
1038 if (e_config->screen_rotation_setting == rotation) return EINA_TRUE;
1040 EINA_LIST_FOREACH(e_comp_screen->outputs, l, o)
1042 unsigned int pipe = 0;
1045 error = tdm_output_get_pipe(o->toutput, &pipe);
1046 if (error != TDM_ERROR_NONE || pipe != 0)
1055 ERR("couldn't find the primary output");
1059 screen_rotation = (e_config->screen_rotation_pre + rotation) % 360;
1061 if (!e_output_rotate(output, screen_rotation))
1064 /* TODO: need to save e_config->screen_rotation_setting to e_config data file */
1065 e_config->screen_rotation_setting = rotation;
1066 e_comp_screen->rotation = screen_rotation;
1068 ecore_evas_rotation_with_resize_set(e_comp->ee, e_comp_screen->rotation);
1069 ecore_evas_geometry_get(e_comp->ee, NULL, NULL, &w, &h);
1071 EINA_LIST_FOREACH(ecore_drm_devices_get(), ll, dev)
1072 ecore_drm_device_pointer_rotation_set(dev, e_comp_screen->rotation);
1074 INF("EE Rotated and Resized: %d, %dx%d", e_comp_screen->rotation, w, h);
1080 e_comp_screen_rotation_ignore_output_transform_send(E_Client *ec, Eina_Bool ignore)
1082 E_Comp_Screen_Tzsr *tzsr = _tz_surface_rotation_find(ec);
1086 ELOGF("COMP", "|tzsr(%p) ignore(%d)", NULL, ec, tzsr, ignore);
1088 tizen_screen_rotation_send_ignore_output_transform(tzsr->resource, ec->comp_data->surface, ignore);
1092 e_comp_screen_primary_output_get(E_Comp_Screen *e_comp_screen)
1094 EINA_SAFETY_ON_NULL_RETURN_VAL(e_comp_screen, NULL);
1096 E_Output *output = NULL, *o = NULL;
1097 Eina_List *l = NULL;
1098 int highest_priority = 0;
1100 /* find the highest priority of the e_output */
1101 EINA_LIST_FOREACH(e_comp_screen->outputs, l, o)
1103 if (highest_priority < o->config.priority)
1105 highest_priority = o->config.priority;
1114 e_comp_screen_hwc_info_debug(void)
1116 EINA_SAFETY_ON_NULL_RETURN(e_comp);
1117 EINA_SAFETY_ON_NULL_RETURN(e_comp->e_comp_screen);
1119 E_Comp_Screen *e_comp_screen = e_comp->e_comp_screen;
1120 E_Output *output = NULL;
1121 E_Plane *plane = NULL;
1122 Eina_List *l_o, *ll_o;
1123 Eina_List *l_l, *ll_l;
1124 tdm_output_conn_status conn_status;
1126 tdm_layer_capability layer_capabilities;
1127 char layer_cap[4096] = {0, };
1129 INF("HWC: HWC Information ==========================================================");
1130 EINA_LIST_FOREACH_SAFE(e_comp_screen->outputs, l_o, ll_o, output)
1132 if (!output) continue;
1133 tdm_output_get_conn_status(output->toutput, &conn_status);
1134 if (conn_status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED) continue;
1136 INF("HWC: HWC Output(%d):(x, y, w, h)=(%d, %d, %d, %d) Information.",
1138 output->config.geom.x, output->config.geom.y, output->config.geom.w, output->config.geom.h);
1139 INF("HWC: num_layers=%d", output->plane_count);
1140 EINA_LIST_FOREACH_SAFE(output->planes, l_l, ll_l, plane)
1142 if (!plane) continue;
1143 tdm_layer_get_capabilities(plane->tlayer, &layer_capabilities);
1144 snprintf(layer_cap, sizeof(layer_cap), "%s%s%s%s%s%s%s%s",
1145 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_CURSOR),
1146 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_PRIMARY),
1147 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_OVERLAY),
1148 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_GRAPHIC),
1149 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_VIDEO),
1150 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_TRANSFORM),
1151 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_RESEVED_MEMORY),
1152 _layer_cap_to_str(layer_capabilities, TDM_LAYER_CAPABILITY_NO_CROP));
1153 INF("HWC: index=%d zpos=%d ec=%p %s",
1154 plane->index, plane->zpos,
1155 plane->ec?plane->ec:NULL,
1159 INF("HWC: =========================================================================");