summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Michael <cpmichael@osg.samsung.com>2016-05-11 10:02:22 -0400
committerChris Michael <cpmichael@osg.samsung.com>2016-05-27 09:53:41 -0400
commit0d2b6b047c88753fce671b5023ce5959e525679d (patch)
treea69b2e1fb571e7e79301a354fe755f63862cc058
parentbb583a94f84bad27ba10f055f190a91469085892 (diff)
port enlightenment to use drm2devs/devilhorns/ecore_drm2
Signed-off-by: Chris Michael <cpmichael@osg.samsung.com>
-rw-r--r--configure.ac18
-rw-r--r--src/bin/e_alert_main.c281
-rw-r--r--src/bin/e_comp_wl_input.c20
-rw-r--r--src/bin/e_mouse.c18
-rw-r--r--src/bin/e_signals.c21
-rw-r--r--src/modules/wl_drm/e_mod_main.c579
6 files changed, 807 insertions, 130 deletions
diff --git a/configure.ac b/configure.ac
index 9ff2d1ad1..951b8af93 100644
--- a/configure.ac
+++ b/configure.ac
@@ -893,11 +893,19 @@ e_alert_requires="\
893 893
894if test "x${have_wayland}" = "xyes"; then 894if test "x${have_wayland}" = "xyes"; then
895 if test "x${HAVE_WL_DRM}" = "xyes"; then 895 if test "x${HAVE_WL_DRM}" = "xyes"; then
896 e_alert_requires="\ 896 if test "x${have_ecore_drm2}" = "xyes"; then
897 $e_alert_requires \ 897 e_alert_requires="\
898 ecore-input >= ${efl_version} \ 898 $e_alert_requires \
899 ecore-drm >= ${efl_version} \ 899 ecore-input >= ${efl_version} \
900 evas >= ${efl_version}" 900 ecore-drm2 >= ${efl_version} \
901 evas >= ${efl_version}"
902 else
903 e_alert_requires="\
904 $e_alert_requires \
905 ecore-input >= ${efl_version} \
906 ecore-drm >= ${efl_version} \
907 evas >= ${efl_version}"
908 fi
901 fi 909 fi
902fi 910fi
903 911
diff --git a/src/bin/e_alert_main.c b/src/bin/e_alert_main.c
index 0df784cf1..b2bcd3c54 100644
--- a/src/bin/e_alert_main.c
+++ b/src/bin/e_alert_main.c
@@ -18,7 +18,13 @@
18 18
19# ifdef HAVE_WL_DRM 19# ifdef HAVE_WL_DRM
20# include <Ecore_Input.h> 20# include <Ecore_Input.h>
21# include <Ecore_Drm.h> 21# ifdef HAVE_DRM2
22# define EFL_BETA_API_SUPPORT
23# include <drm_fourcc.h>
24# include <Ecore_Drm2.h>
25# else
26# include <Ecore_Drm.h>
27# endif
22# include <Evas.h> 28# include <Evas.h>
23# include <Evas_Engine_Buffer.h> 29# include <Evas_Engine_Buffer.h>
24# endif 30# endif
@@ -82,8 +88,6 @@ struct
82}; 88};
83 89
84# ifdef HAVE_WL_DRM 90# ifdef HAVE_WL_DRM
85static Ecore_Drm_Device *dev = NULL;
86static Ecore_Drm_Fb *buffer;
87static Evas *canvas = NULL; 91static Evas *canvas = NULL;
88 92
89static Eina_Bool 93static Eina_Bool
@@ -106,63 +110,6 @@ _e_alert_drm_cb_key_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *eve
106 return ECORE_CALLBACK_RENEW; 110 return ECORE_CALLBACK_RENEW;
107} 111}
108 112
109static int
110_e_alert_drm_connect(void)
111{
112 fprintf(stderr, "E_Alert Drm Connect\n");
113
114 if (!evas_init())
115 {
116 printf("\tCannot init evas\n");
117 return 0;
118 }
119
120 if (!ecore_drm_init())
121 {
122 printf("\tCannot init ecore_drm\n");
123 return 0;
124 }
125
126 dev = ecore_drm_device_find(NULL, NULL);
127 if (!dev)
128 {
129 printf("\tCannot find drm device\n");
130 return 0;
131 }
132
133 if (!ecore_drm_launcher_connect(dev))
134 {
135 printf("\tCannot connect to drm device\n");
136 return 0;
137 }
138
139 if (!ecore_drm_device_open(dev))
140 {
141 printf("\tCannot open drm device\n");
142 return 0;
143 }
144
145 if (!ecore_drm_outputs_create(dev))
146 {
147 printf("\tCannot create drm outputs\n");
148 return 0;
149 }
150
151 if (!ecore_drm_inputs_create(dev))
152 {
153 printf("\tCannot create drm inputs\n");
154 return 0;
155 }
156
157 ecore_drm_outputs_geometry_get(dev, NULL, NULL, &sw, &sh);
158 fprintf(stderr, "\tOutput Size: %d %d\n", sw, sh);
159
160 ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
161 _e_alert_drm_cb_key_down, NULL);
162
163 return 1;
164}
165
166static void 113static void
167_e_alert_drm_draw_outline(void) 114_e_alert_drm_draw_outline(void)
168{ 115{
@@ -383,6 +330,212 @@ _e_alert_drm_draw_button_outlines(void)
383} 330}
384 331
385static void 332static void
333_e_alert_drm_run(void)
334{
335 printf("E_Alert Drm Run\n");
336 ecore_main_loop_begin();
337}
338
339# ifdef HAVE_DRM2
340static Ecore_Drm2_Device *dev = NULL;
341static Ecore_Drm2_Fb *buffer = NULL;
342static Ecore_Drm2_Output *output = NULL;
343static int fd = 0;
344
345static int
346_e_alert_drm_connect(void)
347{
348 fprintf(stderr, "E_Alert Drm Connect\n");
349
350 if (!evas_init())
351 {
352 printf("\tCannot init evas\n");
353 return 0;
354 }
355
356 if (!ecore_drm2_init())
357 {
358 printf("\tCannot init ecore_drm\n");
359 return 0;
360 }
361
362 dev = ecore_drm2_device_find("seat0", 0);
363 if (!dev)
364 {
365 printf("\tCannot find drm device\n");
366 return 0;
367 }
368
369 fd = ecore_drm2_device_open(dev);
370 if (fd < 0)
371 {
372 printf("\tCannot open drm device\n");
373 return 0;
374 }
375
376 if (!ecore_drm2_outputs_create(dev))
377 {
378 printf("\tCannot create drm outputs\n");
379 return 0;
380 }
381
382 output = ecore_drm2_output_find(dev, 0, 0);
383 if (output) ecore_drm2_output_crtc_size_get(output, &sw, &sh);
384 fprintf(stderr, "\tOutput Size: %d %d\n", sw, sh);
385
386 ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
387 _e_alert_drm_cb_key_down, NULL);
388
389 return 1;
390}
391
392static void
393_e_alert_drm_create(void)
394{
395 Evas_Engine_Info_Buffer *einfo;
396 int method = 0;
397
398 fprintf(stderr, "E_Alert Drm Create\n");
399
400 fh = 13;
401
402 buffer = ecore_drm2_fb_create(fd, sw, sh, 24, 32, DRM_FORMAT_XRGB8888);
403
404 method = evas_render_method_lookup("buffer");
405 if (method <= 0)
406 {
407 fprintf(stderr, "\tCould not get evas render method\n");
408 return;
409 }
410
411 canvas = evas_new();
412 if (!canvas)
413 {
414 fprintf(stderr, "\tFailed to create new canvas\n");
415 return;
416 }
417
418 evas_output_method_set(canvas, method);
419 evas_output_size_set(canvas, sw, sh);
420 evas_output_viewport_set(canvas, 0, 0, sw, sh);
421
422 einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(canvas);
423 if (!einfo)
424 {
425 printf("\tFailed to get evas engine info\n");
426 evas_free(canvas);
427 return;
428 }
429
430 einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32;
431 einfo->info.dest_buffer = ecore_drm2_fb_data_get(buffer);
432 einfo->info.dest_buffer_row_bytes = (sw * sizeof(int));
433 einfo->info.use_color_key = 0;
434 einfo->info.alpha_threshold = 0;
435 einfo->info.func.new_update_region = NULL;
436 einfo->info.func.free_update_region = NULL;
437 evas_engine_info_set(canvas, (Evas_Engine_Info *)einfo);
438
439 _e_alert_drm_draw_outline();
440 _e_alert_drm_draw_title_outline();
441 _e_alert_drm_draw_title();
442 _e_alert_drm_draw_text();
443 _e_alert_drm_draw_button_outlines();
444}
445
446static void
447_e_alert_drm_display(void)
448{
449 Eina_List *updates;
450
451 printf("E_Alert Drm Display\n");
452
453 updates = evas_render_updates(canvas);
454 evas_render_updates_free(updates);
455
456 ecore_drm2_fb_flip(buffer, output, NULL);
457}
458
459static void
460_e_alert_drm_shutdown(void)
461{
462 printf("E_Alert Drm Shutdown\n");
463
464 evas_free(canvas);
465
466 if (dev)
467 {
468 ecore_drm2_outputs_destroy(dev);
469 ecore_drm2_device_close(dev);
470 ecore_drm2_device_free(dev);
471 }
472
473 ecore_drm2_shutdown();
474 evas_shutdown();
475}
476
477# else
478static Ecore_Drm_Device *dev = NULL;
479static Ecore_Drm_Fb *buffer;
480
481static int
482_e_alert_drm_connect(void)
483{
484 fprintf(stderr, "E_Alert Drm Connect\n");
485
486 if (!evas_init())
487 {
488 printf("\tCannot init evas\n");
489 return 0;
490 }
491
492 if (!ecore_drm_init())
493 {
494 printf("\tCannot init ecore_drm\n");
495 return 0;
496 }
497
498 dev = ecore_drm_device_find(NULL, NULL);
499 if (!dev)
500 {
501 printf("\tCannot find drm device\n");
502 return 0;
503 }
504
505 if (!ecore_drm_launcher_connect(dev))
506 {
507 printf("\tCannot connect to drm device\n");
508 return 0;
509 }
510
511 if (!ecore_drm_device_open(dev))
512 {
513 printf("\tCannot open drm device\n");
514 return 0;
515 }
516
517 if (!ecore_drm_outputs_create(dev))
518 {
519 printf("\tCannot create drm outputs\n");
520 return 0;
521 }
522
523 if (!ecore_drm_inputs_create(dev))
524 {
525 printf("\tCannot create drm inputs\n");
526 return 0;
527 }
528
529 ecore_drm_outputs_geometry_get(dev, NULL, NULL, &sw, &sh);
530 fprintf(stderr, "\tOutput Size: %d %d\n", sw, sh);
531
532 ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
533 _e_alert_drm_cb_key_down, NULL);
534
535 return 1;
536}
537
538static void
386_e_alert_drm_create(void) 539_e_alert_drm_create(void)
387{ 540{
388 int method = 0; 541 int method = 0;
@@ -457,13 +610,6 @@ _e_alert_drm_display(void)
457} 610}
458 611
459static void 612static void
460_e_alert_drm_run(void)
461{
462 printf("E_Alert Drm Run\n");
463 ecore_main_loop_begin();
464}
465
466static void
467_e_alert_drm_shutdown(void) 613_e_alert_drm_shutdown(void)
468{ 614{
469 printf("E_Alert Drm Shutdown\n"); 615 printf("E_Alert Drm Shutdown\n");
@@ -480,6 +626,7 @@ _e_alert_drm_shutdown(void)
480 ecore_drm_shutdown(); 626 ecore_drm_shutdown();
481 evas_shutdown(); 627 evas_shutdown();
482} 628}
629# endif
483#endif 630#endif
484 631
485int 632int
diff --git a/src/bin/e_comp_wl_input.c b/src/bin/e_comp_wl_input.c
index 2eea0574c..ff66feb61 100644
--- a/src/bin/e_comp_wl_input.c
+++ b/src/bin/e_comp_wl_input.c
@@ -3,7 +3,11 @@
3#include "e.h" 3#include "e.h"
4#include <sys/mman.h> 4#include <sys/mman.h>
5#ifdef HAVE_WL_DRM 5#ifdef HAVE_WL_DRM
6#include <Ecore_Drm.h> 6# ifdef HAVE_DRM2
7# include <Ecore_Drm2.h>
8# else
9# include <Ecore_Drm.h>
10# endif
7#endif 11#endif
8 12
9E_API int E_EVENT_TEXT_INPUT_PANEL_VISIBILITY_CHANGE = -1; 13E_API int E_EVENT_TEXT_INPUT_PANEL_VISIBILITY_CHANGE = -1;
@@ -638,10 +642,24 @@ _e_comp_wl_input_context_keymap_set(struct xkb_keymap *keymap, struct xkb_contex
638 642
639//set the values to the drm devices 643//set the values to the drm devices
640#ifdef HAVE_WL_DRM 644#ifdef HAVE_WL_DRM
645# ifdef HAVE_DRM2
646 if (e_config->xkb.use_cache)
647 {
648 Ecore_Drm2_Device *dev;
649
650 dev = ecore_evas_data_get(e_comp->ee, "device");
651 if (dev)
652 {
653 ecore_drm2_device_keyboard_cached_context_set(dev, context);
654 ecore_drm2_device_keyboard_cached_keymap_set(dev, keymap);
655 }
656 }
657# else
641 if (e_config->xkb.use_cache) 658 if (e_config->xkb.use_cache)
642 ecore_drm_device_keyboard_cached_context_set(context); 659 ecore_drm_device_keyboard_cached_context_set(context);
643 if (e_config->xkb.use_cache) 660 if (e_config->xkb.use_cache)
644 ecore_drm_device_keyboard_cached_keymap_set(keymap); 661 ecore_drm_device_keyboard_cached_keymap_set(keymap);
662# endif
645#endif 663#endif
646} 664}
647 665
diff --git a/src/bin/e_mouse.c b/src/bin/e_mouse.c
index ac90d7415..40c00cb07 100644
--- a/src/bin/e_mouse.c
+++ b/src/bin/e_mouse.c
@@ -1,6 +1,10 @@
1#include "e.h" 1#include "e.h"
2#ifdef HAVE_WL_DRM 2#ifdef HAVE_WL_DRM
3#include <Ecore_Drm.h> 3# ifdef HAVE_DRM2
4# include <Ecore_Drm2.h>
5# else
6# include <Ecore_Drm2.h>
7# endif
4#endif 8#endif
5 9
6E_API int 10E_API int
@@ -44,7 +48,18 @@ e_mouse_update(void)
44 if (!ecore_x_pointer_mapping_set(map, n)) return 0; 48 if (!ecore_x_pointer_mapping_set(map, n)) return 0;
45 } 49 }
46#endif 50#endif
51
47#ifdef HAVE_WL_DRM 52#ifdef HAVE_WL_DRM
53# ifdef HAVE_DRM2
54 if (strstr(ecore_evas_engine_name_get(e_comp->ee), "drm"))
55 {
56 Ecore_Drm2_Device *dev;
57
58 dev = ecore_evas_data_get(e_comp->ee, "device");
59 if (dev)
60 ecore_drm2_device_pointer_left_handed_set(dev, (Eina_Bool)!e_config->mouse_hand);
61 }
62# else
48 if (strstr(ecore_evas_engine_name_get(e_comp->ee), "drm")) 63 if (strstr(ecore_evas_engine_name_get(e_comp->ee), "drm"))
49 { 64 {
50 const Eina_List *list, *l; 65 const Eina_List *list, *l;
@@ -56,6 +71,7 @@ e_mouse_update(void)
56 ecore_drm_device_pointer_left_handed_set(dev, (Eina_Bool)!e_config->mouse_hand); 71 ecore_drm_device_pointer_left_handed_set(dev, (Eina_Bool)!e_config->mouse_hand);
57 } 72 }
58 } 73 }
74# endif
59#endif 75#endif
60 return 1; 76 return 1;
61} 77}
diff --git a/src/bin/e_signals.c b/src/bin/e_signals.c
index 9f1668d95..712dd2fee 100644
--- a/src/bin/e_signals.c
+++ b/src/bin/e_signals.c
@@ -7,7 +7,11 @@
7 7
8#ifdef HAVE_WAYLAND 8#ifdef HAVE_WAYLAND
9# ifdef HAVE_WL_DRM 9# ifdef HAVE_WL_DRM
10#include <Ecore_Drm.h> 10# ifdef HAVE_DRM2
11# include <Ecore_Drm2.h>
12# else
13# include <Ecore_Drm.h>
14# endif
11# endif 15# endif
12#endif 16#endif
13 17
@@ -72,10 +76,22 @@ _e_crash(void)
72 if (e_comp->comp_type == E_PIXMAP_TYPE_WL) 76 if (e_comp->comp_type == E_PIXMAP_TYPE_WL)
73 { 77 {
74#ifdef HAVE_WL_DRM 78#ifdef HAVE_WL_DRM
79 if (!strstr(ecore_evas_engine_name_get(e_comp->ee), "drm")) return;
80# ifdef HAVE_DRM2
81 Ecore_Drm2_Device *dev;
82
83 dev = ecore_evas_data_get(e_comp->ee, "device");
84 if (dev)
85 {
86 ecore_drm2_outputs_destroy(dev);
87 ecore_drm2_device_close(dev);
88 ecore_drm2_device_free(dev);
89 }
90 ecore_drm2_shutdown();
91# else
75 const Eina_List *list, *l, *ll; 92 const Eina_List *list, *l, *ll;
76 Ecore_Drm_Device *dev; 93 Ecore_Drm_Device *dev;
77 94
78 if (!strstr(ecore_evas_engine_name_get(e_comp->ee), "drm")) return;
79 list = ecore_drm_devices_get(); 95 list = ecore_drm_devices_get();
80 EINA_LIST_FOREACH_SAFE(list, l, ll, dev) 96 EINA_LIST_FOREACH_SAFE(list, l, ll, dev)
81 { 97 {
@@ -87,6 +103,7 @@ _e_crash(void)
87 } 103 }
88 104
89 ecore_drm_shutdown(); 105 ecore_drm_shutdown();
106# endif
90#endif 107#endif
91 return; 108 return;
92 } 109 }
diff --git a/src/modules/wl_drm/e_mod_main.c b/src/modules/wl_drm/e_mod_main.c
index f85770140..98f31a849 100644
--- a/src/modules/wl_drm/e_mod_main.c
+++ b/src/modules/wl_drm/e_mod_main.c
@@ -1,5 +1,11 @@
1#include "e.h" 1#include "e.h"
2#include <Ecore_Drm.h> 2#include <drm_mode.h>
3
4#ifdef HAVE_DRM2
5# include <Ecore_Drm2.h>
6#else
7# include <Ecore_Drm.h>
8#endif
3 9
4E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Wl_Drm" }; 10E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Wl_Drm" };
5 11
@@ -7,14 +13,48 @@ static Ecore_Event_Handler *activate_handler;
7static Ecore_Event_Handler *output_handler; 13static Ecore_Event_Handler *output_handler;
8static Eina_Bool session_state = EINA_FALSE; 14static Eina_Bool session_state = EINA_FALSE;
9 15
16static const char *conn_types[] =
17{
18 "None", "VGA", "DVI-I", "DVI-D", "DVI-A",
19 "Composite", "S-Video", "LVDS", "Component", "DIN",
20 "DisplayPort", "HDMI-A", "HDMI-B", "TV", "eDP", "Virtual",
21 "DSI", "UNKNOWN"
22};
23
24static E_Randr2_Connector rtype[] =
25{
26 E_RANDR2_CONNECTOR_UNDEFINED,
27 E_RANDR2_CONNECTOR_UNDEFINED,
28 E_RANDR2_CONNECTOR_DVI,
29 E_RANDR2_CONNECTOR_DVI,
30 E_RANDR2_CONNECTOR_DVI,
31 E_RANDR2_CONNECTOR_UNDEFINED,
32 E_RANDR2_CONNECTOR_UNDEFINED,
33 E_RANDR2_CONNECTOR_UNDEFINED,
34 E_RANDR2_CONNECTOR_UNDEFINED,
35 E_RANDR2_CONNECTOR_UNDEFINED,
36 E_RANDR2_CONNECTOR_DISPLAY_PORT,
37 E_RANDR2_CONNECTOR_HDMI_A,
38 E_RANDR2_CONNECTOR_HDMI_B,
39 E_RANDR2_CONNECTOR_UNDEFINED,
40 E_RANDR2_CONNECTOR_DISPLAY_PORT,
41 E_RANDR2_CONNECTOR_UNDEFINED,
42 E_RANDR2_CONNECTOR_UNDEFINED,
43 E_RANDR2_CONNECTOR_UNDEFINED,
44};
45
10static Eina_Bool 46static Eina_Bool
11_e_mod_drm_cb_activate(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) 47_e_mod_drm_cb_activate(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
12{ 48{
13 Ecore_Drm_Event_Activate *e; 49# ifdef HAVE_DRM2
50 Ecore_Drm2_Event_Activate *ev;
51# else
52 Ecore_Drm_Event_Activate *ev;
53# endif
14 54
15 if (!(e = event)) goto end; 55 if (!(ev = event)) goto end;
16 56
17 if (e->active) 57 if (ev->active)
18 { 58 {
19 E_Client *ec; 59 E_Client *ec;
20 60
@@ -55,7 +95,13 @@ _e_mod_drm_cb_output(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
55{ 95{
56 const Eina_List *l; 96 const Eina_List *l;
57 E_Randr2_Screen *screen; 97 E_Randr2_Screen *screen;
98 Eina_Bool connected = EINA_FALSE;
99 int subpixel = 0;
100#ifdef HAVE_DRM2
101 Ecore_Drm2_Event_Output_Changed *e;
102#else
58 Ecore_Drm_Event_Output *e; 103 Ecore_Drm_Event_Output *e;
104#endif
59 105
60 if (!(e = event)) goto end; 106 if (!(e = event)) goto end;
61 107
@@ -66,12 +112,20 @@ _e_mod_drm_cb_output(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
66 if ((!strcmp(screen->info.name, e->name)) && 112 if ((!strcmp(screen->info.name, e->name)) &&
67 (!strcmp(screen->info.screen, e->model))) 113 (!strcmp(screen->info.screen, e->model)))
68 { 114 {
69 if (e->plug) 115#ifdef HAVE_DRM2
116 connected = e->enabled;
117 subpixel = e->subpixel;
118#else
119 connected = e->plug;
120 subpixel = e->subpixel_order;
121#endif
122
123 if (connected)
70 { 124 {
71 if (!e_comp_wl_output_init(screen->id, e->make, e->model, 125 if (!e_comp_wl_output_init(screen->id, e->make, e->model,
72 e->x, e->y, e->w, e->h, 126 e->x, e->y, e->w, e->h,
73 e->phys_width, e->phys_height, 127 e->phys_width, e->phys_height,
74 e->refresh, e->subpixel_order, 128 e->refresh, subpixel,
75 e->transform)) 129 e->transform))
76 { 130 {
77 ERR("Could not setup new output: %s", screen->id); 131 ERR("Could not setup new output: %s", screen->id);
@@ -91,6 +145,7 @@ end:
91 return ECORE_CALLBACK_PASS_ON; 145 return ECORE_CALLBACK_PASS_ON;
92} 146}
93 147
148#ifndef HAVE_DRM2
94static Ecore_Drm_Output_Mode * 149static Ecore_Drm_Output_Mode *
95_e_mod_drm_mode_screen_find(E_Randr2_Screen *s, Ecore_Drm_Output *output) 150_e_mod_drm_mode_screen_find(E_Randr2_Screen *s, Ecore_Drm_Output *output)
96{ 151{
@@ -130,6 +185,7 @@ _e_mod_drm_output_screen_get(Ecore_Drm_Output *output)
130 185
131 return strdup(model); 186 return strdup(model);
132} 187}
188#endif
133 189
134static E_Randr2_Screen * 190static E_Randr2_Screen *
135_info_unconf_primary_find(E_Randr2 *r) 191_info_unconf_primary_find(E_Randr2 *r)
@@ -297,6 +353,428 @@ _e_mod_drm_relative_fixup(E_Randr2 *r)
297 } 353 }
298} 354}
299 355
356#ifdef HAVE_DRM2
357static E_Randr2 *
358_drm2_randr_create(void)
359{
360 const Eina_List *l;
361 E_Randr2 *r = NULL;
362 Ecore_Drm2_Device *dev;
363 const Eina_List *outputs;
364 Ecore_Drm2_Output *output;
365 unsigned int type;
366
367 dev = ecore_evas_data_get(e_comp->ee, "device");
368 if (!dev) return NULL;
369
370 outputs = ecore_drm2_outputs_get(dev);
371 if (!outputs) return NULL;
372
373 printf("DRM2 RRR: ................. info get!\n");
374
375 r = E_NEW(E_Randr2, 1);
376 if (!r) return NULL;
377
378 EINA_LIST_FOREACH(outputs, l, output)
379 {
380 E_Randr2_Screen *s;
381 const Eina_List *m;
382 Ecore_Drm2_Output_Mode *omode;
383 E_Config_Randr2_Screen *cs = NULL;
384 unsigned int *crtcs;
385 int priority = 0, num = 0, j = 0;
386 Eina_Bool ok = EINA_FALSE;
387 Eina_Bool possible = EINA_FALSE;
388
389 s = E_NEW(E_Randr2_Screen, 1);
390 if (!s) continue;
391
392 s->info.name = ecore_drm2_output_name_get(output);
393 printf("DRM2 RRR: .... out %s\n", s->info.name);
394
395 s->info.connected = ecore_drm2_output_connected_get(output);
396 printf("DRM2 RRR: ...... connected %i\n", s->info.connected);
397
398 s->info.screen = ecore_drm2_output_model_get(output);
399
400 s->info.edid = ecore_drm2_output_edid_get(output);
401 if (s->info.edid)
402 s->id = malloc(strlen(s->info.name) + 1 + strlen(s->info.edid) + 1);
403 else
404 s->id = malloc(strlen(s->info.name) + 1 + 1);
405 if (!s->id)
406 {
407 free(s->info.screen);
408 free(s->info.edid);
409 free(s);
410 continue;
411 }
412 strcpy(s->id, s->info.name);
413 strcat(s->id, "/");
414 if (s->info.edid) strcat(s->id, s->info.edid);
415
416 printf("DRM2 RRR: Created Screen: %s\n", s->id);
417
418 type = MIN(ecore_drm2_output_connector_type_get(output),
419 EINA_C_ARRAY_LENGTH(conn_types) - 1);
420 s->info.connector = rtype[type];
421 s->info.is_lid = ((type == DRM_MODE_CONNECTOR_LVDS) ||
422 (type == DRM_MODE_CONNECTOR_eDP));
423 s->info.lid_closed = (s->info.is_lid && e_acpi_lid_is_closed());
424 printf("DRM2 RRR: ...... lid_closed = %i (%i && %i)\n",
425 s->info.lid_closed, s->info.is_lid, e_acpi_lid_is_closed());
426
427 s->info.backlight = ecore_drm2_output_backlight_get(output);
428
429 ecore_drm2_output_physical_size_get(output, &s->info.size.w,
430 &s->info.size.h);
431
432 EINA_LIST_FOREACH(ecore_drm2_output_modes_get(output), m, omode)
433 {
434 E_Randr2_Mode *rmode;
435 unsigned int flags, refresh;
436
437 rmode = malloc(sizeof(E_Randr2_Mode));
438 if (!rmode) continue;
439
440 ecore_drm2_output_mode_info_get(omode, &rmode->w, &rmode->h,
441 &refresh, &flags);
442
443 rmode->refresh = refresh;
444 rmode->preferred = (flags & DRM_MODE_TYPE_PREFERRED);
445
446 s->info.modes = eina_list_append(s->info.modes, rmode);
447 }
448
449 if (e_randr2_cfg)
450 cs = e_randr2_config_screen_find(s, e_randr2_cfg);
451 if (cs)
452 priority = cs->priority;
453 else if (ecore_drm2_output_primary_get(output))
454 priority = 100;
455 s->config.priority = priority;
456
457 crtcs = ecore_drm2_device_crtcs_get(dev, &num);
458 for (j = 0; j < num; j++)
459 {
460 if (crtcs[j] == ecore_drm2_output_crtc_get(output))
461 {
462 ok = EINA_TRUE;
463 break;
464 }
465 }
466
467 if (!ok)
468 {
469 /* get possible crtcs, compare to output_crtc_get */
470 for (j = 0; j < num; j++)
471 {
472 if (ecore_drm2_output_possible_crtc_get(output, crtcs[j]))
473 {
474 ok = EINA_TRUE;
475 possible = EINA_TRUE;
476 break;
477 }
478 }
479 }
480
481 if (ok)
482 {
483 if (!possible)
484 {
485 unsigned int refresh;
486
487 ecore_drm2_output_geometry_get(output, &s->config.geom.x,
488 &s->config.geom.y, NULL, NULL);
489 ecore_drm2_output_crtc_size_get(output, &s->config.geom.w,
490 &s->config.geom.h);
491 ecore_drm2_output_resolution_get(output,
492 &s->config.mode.w,
493 &s->config.mode.h,
494 &refresh);
495
496 s->config.mode.refresh = refresh;
497 s->config.enabled =
498 ((s->config.mode.w != 0) && (s->config.mode.h != 0));
499
500 printf("DRM2 RRR: '%s' %i %i %ix%i\n", s->info.name,
501 s->config.geom.x, s->config.geom.y,
502 s->config.geom.w, s->config.geom.h);
503 }
504
505 /* TODO: cannot support rotations until we support planes
506 * and we cannot support planes until Atomic support is in */
507
508 s->info.can_rot_0 = EINA_FALSE;
509 s->info.can_rot_90 = EINA_FALSE;
510 s->info.can_rot_180 = EINA_FALSE;
511 s->info.can_rot_270 = EINA_FALSE;
512
513/* # if (EFL_VERSION_MAJOR > 1) || (EFL_VERSION_MINOR >= 18) */
514/* unsigned int rotations; */
515
516/* rotations = */
517/* ecore_drm_output_supported_rotations_get(output, */
518/* ECORE_DRM_PLANE_TYPE_PRIMARY); */
519
520/* if (rotations & ECORE_DRM_PLANE_ROTATION_NORMAL) */
521/* s->info.can_rot_0 = EINA_TRUE; */
522/* if (rotations & ECORE_DRM_PLANE_ROTATION_90) */
523/* s->info.can_rot_90 = EINA_TRUE; */
524/* if (rotations & ECORE_DRM_PLANE_ROTATION_180) */
525/* s->info.can_rot_180 = EINA_TRUE; */
526/* if (rotations & ECORE_DRM_PLANE_ROTATION_270) */
527/* s->info.can_rot_270 = EINA_TRUE; */
528/* # endif */
529
530 if (cs)
531 {
532 if (cs->profile)
533 s->config.profile = strdup(cs->profile);
534 else
535 s->config.profile = NULL;
536 s->config.scale_multiplier = cs->scale_multiplier;
537 }
538 }
539
540 r->screens = eina_list_append(r->screens, s);
541 }
542
543 _e_mod_drm_relative_fixup(r);
544
545 return r;
546}
547
548static Ecore_Drm2_Output *
549_drm2_output_find(const Eina_List *outputs, const char *oname)
550{
551 const Eina_List *l;
552 Ecore_Drm2_Output *output = NULL;
553
554 EINA_LIST_FOREACH(outputs, l, output)
555 {
556 char *name;
557
558 name = ecore_drm2_output_name_get(output);
559 if (!name) continue;
560
561 if (!strcmp(name, oname))
562 {
563 free(name);
564 return output;
565 }
566
567 free(name);
568 }
569
570 return NULL;
571}
572
573static Ecore_Drm2_Output_Mode *
574_drm2_mode_screen_find(E_Randr2_Screen *s, Ecore_Drm2_Output *output)
575{
576 Ecore_Drm2_Output_Mode *mode, *m = NULL;
577 const Eina_List *l;
578 int diff, distance = 0x7fffffff;
579
580 EINA_LIST_FOREACH(ecore_drm2_output_modes_get(output), l, mode)
581 {
582 int width, height;
583 unsigned int refresh;
584
585 ecore_drm2_output_mode_info_get(mode, &width, &height, &refresh, NULL);
586
587 diff = (100 * abs(s->config.mode.w - width)) +
588 (100 * abs(s->config.mode.h - height)) +
589 fabs((100 * s->config.mode.refresh) - (100 * refresh));
590 if (diff < distance)
591 {
592 m = mode;
593 distance = diff;
594 }
595 }
596
597 return m;
598}
599
600static void
601_drm2_output_primary_set(const Eina_List *outputs, Ecore_Drm2_Output *output)
602{
603 const Eina_List *l;
604 Ecore_Drm2_Output *o;
605
606 EINA_LIST_FOREACH(outputs, l, o)
607 {
608 if (o == output)
609 ecore_drm2_output_primary_set(output, EINA_TRUE);
610 else
611 ecore_drm2_output_primary_set(output, EINA_FALSE);
612 }
613}
614
615static void
616_drm2_randr_apply(void)
617{
618 const Eina_List *l;
619 Eina_List *ll;
620 E_Randr2_Screen *s;
621 Ecore_Drm2_Device *dev;
622 const Eina_List *outputs;
623 Ecore_Drm2_Output *output;
624 int minw, minh, maxw, maxh;
625 int ow = 0, oh = 0;
626 int pw = 0, ph = 0;
627 int vw = 0, vh = 0;
628 int nw = 0, nh = 0;
629 int top_priority = 0;
630
631 dev = ecore_evas_data_get(e_comp->ee, "device");
632 if (!dev) return;
633
634 outputs = ecore_drm2_outputs_get(dev);
635 if (!outputs) return;
636
637 ecore_drm2_device_screen_size_range_get(dev, &minw, &minh, &maxw, &maxh);
638 printf("DRM2 RRR: size range: %ix%i -> %ix%i\n", minw, minh, maxw, maxh);
639
640 nw = e_randr2->w;
641 nh = e_randr2->h;
642
643 /* get virtual size */
644 EINA_LIST_FOREACH(outputs, l, output)
645 {
646 if (!ecore_drm2_output_connected_get(output)) continue;
647 if (!ecore_drm2_output_enabled_get(output)) continue;
648 if (ecore_drm2_output_cloned_get(output)) continue;
649
650 ecore_drm2_output_geometry_get(output, NULL, NULL, &ow, &oh);
651 pw += MAX(pw, ow);
652 ph = MAX(ph, oh);
653 }
654
655 if (nw > maxw) nw = maxw;
656 if (nh > maxh) nh = maxh;
657 if (nw < minw) nw = minw;
658 if (nh < minh) nh = minh;
659 vw = nw;
660 vh = nh;
661 if (nw < pw) vw = pw;
662 if (nh < ph) vh = ph;
663
664 printf("DRM2 RRR: set vsize: %ix%i\n", vw, vh);
665
666 EINA_LIST_FOREACH(e_randr2->screens, ll, s)
667 {
668 Ecore_Drm2_Output_Mode *mode = NULL;
669
670 if (!s->config.configured) continue;
671
672 output = _drm2_output_find(outputs, s->info.name);
673 if (!output) continue;
674
675 if (s->config.enabled)
676 mode = _drm2_mode_screen_find(s, output);
677
678 if (s->config.priority > top_priority)
679 top_priority = s->config.priority;
680
681 ecore_drm2_output_mode_set(output, mode,
682 s->config.geom.x, s->config.geom.y);
683
684 /* TODO: cannot support rotations until we support planes
685 * and we cannot support planes until Atomic support is in */
686
687 if (s->config.priority == top_priority)
688 _drm2_output_primary_set(outputs, output);
689
690 ecore_drm2_output_enabled_set(output, s->config.enabled);
691
692 printf("\tDRM2 RRR: Mode\n");
693 printf("\t\tDRM2 RRR: Geom: %d %d\n",
694 s->config.mode.w, s->config.mode.h);
695 printf("\t\tDRM2 RRR: Refresh: %f\n", s->config.mode.refresh);
696 printf("\t\tDRM2 RRR: Preferred: %d\n", s->config.mode.preferred);
697 printf("\tDRM2 RRR: Rotation: %d\n", s->config.rotation);
698 printf("\tDRM2 RRR: Relative Mode: %d\n", s->config.relative.mode);
699 printf("\tDRM2 RRR: Relative To: %s\n", s->config.relative.to);
700 printf("\tDRM2 RRR: Align: %f\n", s->config.relative.align);
701 }
702}
703
704static void
705_drm2_dpms(int set)
706{
707 Eina_List *l;
708 E_Randr2_Screen *s;
709 Ecore_Drm2_Device *dev;
710 const Eina_List *outputs, *ll;
711 Ecore_Drm2_Output *output;
712
713 dev = ecore_evas_data_get(e_comp->ee, "device");
714 if (!dev) return;
715
716 outputs = ecore_drm2_outputs_get(dev);
717 if (!outputs) return;
718
719 EINA_LIST_FOREACH(e_randr2->screens, l, s)
720 {
721 EINA_LIST_FOREACH(outputs, ll, output)
722 {
723 char *name;
724
725 name = ecore_drm2_output_name_get(output);
726 if (!name) continue;
727
728 if (!strcmp(name, s->info.name))
729 {
730 if ((!s->config.configured) || s->config.enabled)
731 ecore_drm2_output_dpms_set(output, set);
732 }
733
734 free(name);
735 }
736 }
737}
738
739static void
740_drm2_read_pixels(E_Comp_Wl_Output *output, void *pixels)
741{
742 Ecore_Drm2_Device *dev;
743 Ecore_Drm2_Output *out;
744 Ecore_Drm2_Fb *fb;
745 int i = 0, bstride;
746 unsigned char *s, *d = pixels;
747 unsigned int fstride = 0;
748 void *data;
749
750 dev = ecore_evas_data_get(e_comp->ee, "device");
751 if (!dev) return;
752
753 out = ecore_drm2_output_find(dev, output->x, output->y);
754 if (!out) return;
755
756 fb = ecore_drm2_output_next_fb_get(out);
757 if (!fb)
758 {
759 fb = ecore_drm2_output_current_fb_get(out);
760 if (!fb) return;
761 }
762
763 data = ecore_drm2_fb_data_get(fb);
764 fstride = ecore_drm2_fb_stride_get(fb);
765
766 bstride = output->w * sizeof(int);
767
768 for (i = output->y; i < output->y + output->h; i++)
769 {
770 s = data;
771 s += (fstride * i) + (output->x * sizeof(int));
772 memcpy(d, s, (output->w * sizeof(int)));
773 d += bstride;
774 }
775
776}
777#else
300static E_Randr2 * 778static E_Randr2 *
301_drm_randr_create(void) 779_drm_randr_create(void)
302{ 780{
@@ -304,34 +782,6 @@ _drm_randr_create(void)
304 Ecore_Drm_Output *output; 782 Ecore_Drm_Output *output;
305 const Eina_List *l, *ll; 783 const Eina_List *l, *ll;
306 E_Randr2 *r = NULL; 784 E_Randr2 *r = NULL;
307 const char *conn_types[] =
308 {
309 "None", "VGA", "DVI-I", "DVI-D", "DVI-A",
310 "Composite", "S-Video", "LVDS", "Component", "DIN",
311 "DisplayPort", "HDMI-A", "HDMI-B", "TV", "eDP", "Virtual",
312 "DSI", "UNKNOWN"
313 };
314 E_Randr2_Connector rtype[] =
315 {
316 E_RANDR2_CONNECTOR_UNDEFINED,
317 E_RANDR2_CONNECTOR_UNDEFINED,
318 E_RANDR2_CONNECTOR_DVI,
319 E_RANDR2_CONNECTOR_DVI,
320 E_RANDR2_CONNECTOR_DVI,
321 E_RANDR2_CONNECTOR_UNDEFINED,
322 E_RANDR2_CONNECTOR_UNDEFINED,
323 E_RANDR2_CONNECTOR_UNDEFINED,
324 E_RANDR2_CONNECTOR_UNDEFINED,
325 E_RANDR2_CONNECTOR_UNDEFINED,
326 E_RANDR2_CONNECTOR_DISPLAY_PORT,
327 E_RANDR2_CONNECTOR_HDMI_A,
328 E_RANDR2_CONNECTOR_HDMI_B,
329 E_RANDR2_CONNECTOR_UNDEFINED,
330 E_RANDR2_CONNECTOR_DISPLAY_PORT,
331 E_RANDR2_CONNECTOR_UNDEFINED,
332 E_RANDR2_CONNECTOR_UNDEFINED,
333 E_RANDR2_CONNECTOR_UNDEFINED,
334 };
335 unsigned int type; 785 unsigned int type;
336 786
337 printf("DRM RRR: ................. info get!\n"); 787 printf("DRM RRR: ................. info get!\n");
@@ -504,16 +954,6 @@ _drm_randr_create(void)
504 return r; 954 return r;
505} 955}
506 956
507static Eina_Bool
508_drm_randr_available(void)
509{
510 return EINA_TRUE;
511}
512
513static void
514_drm_randr_stub(void)
515{}
516
517static void 957static void
518_drm_randr_apply(void) 958_drm_randr_apply(void)
519{ 959{
@@ -653,16 +1093,6 @@ _drm_dpms(int set)
653 } 1093 }
654} 1094}
655 1095
656static E_Comp_Screen_Iface drmiface =
657{
658 .available = _drm_randr_available,
659 .init = _drm_randr_stub,
660 .shutdown = _drm_randr_stub,
661 .create = _drm_randr_create,
662 .apply = _drm_randr_apply,
663 .dpms = _drm_dpms,
664};
665
666static void 1096static void
667_drm_read_pixels(E_Comp_Wl_Output *output, void *pixels) 1097_drm_read_pixels(E_Comp_Wl_Output *output, void *pixels)
668{ 1098{
@@ -692,6 +1122,33 @@ _drm_read_pixels(E_Comp_Wl_Output *output, void *pixels)
692 d += bstride; 1122 d += bstride;
693 } 1123 }
694} 1124}
1125#endif
1126
1127static Eina_Bool
1128_drm_randr_available(void)
1129{
1130 return EINA_TRUE;
1131}
1132
1133static void
1134_drm_randr_stub(void)
1135{}
1136
1137static E_Comp_Screen_Iface drmiface =
1138{
1139 .available = _drm_randr_available,
1140 .init = _drm_randr_stub,
1141 .shutdown = _drm_randr_stub,
1142#ifdef HAVE_DRM2
1143 .create = _drm2_randr_create,
1144 .apply = _drm2_randr_apply,
1145 .dpms = _drm2_dpms,
1146#else
1147 .create = _drm_randr_create,
1148 .apply = _drm_randr_apply,
1149 .dpms = _drm_dpms,
1150#endif
1151};
695 1152
696E_API void * 1153E_API void *
697e_modapi_init(E_Module *m) 1154e_modapi_init(E_Module *m)
@@ -741,7 +1198,11 @@ e_modapi_init(E_Module *m)
741 if (!e_comp_wl_init()) return NULL; 1198 if (!e_comp_wl_init()) return NULL;
742 if (!e_comp_canvas_init(w, h)) return NULL; 1199 if (!e_comp_canvas_init(w, h)) return NULL;
743 1200
1201#ifdef HAVE_DRM2
1202 e_comp_wl->extensions->screenshooter.read_pixels = _drm2_read_pixels;
1203#else
744 e_comp_wl->extensions->screenshooter.read_pixels = _drm_read_pixels; 1204 e_comp_wl->extensions->screenshooter.read_pixels = _drm_read_pixels;
1205#endif
745 1206
746 ecore_evas_pointer_xy_get(e_comp->ee, &e_comp_wl->ptr.x, 1207 ecore_evas_pointer_xy_get(e_comp->ee, &e_comp_wl->ptr.x,
747 &e_comp_wl->ptr.y); 1208 &e_comp_wl->ptr.y);
@@ -756,6 +1217,15 @@ e_modapi_init(E_Module *m)
756 e_comp->pointer = e_pointer_canvas_new(e_comp->ee, EINA_TRUE); 1217 e_comp->pointer = e_pointer_canvas_new(e_comp->ee, EINA_TRUE);
757 e_comp->pointer->color = EINA_TRUE; 1218 e_comp->pointer->color = EINA_TRUE;
758 1219
1220#ifdef HAVE_DRM2
1221 activate_handler =
1222 ecore_event_handler_add(ECORE_DRM2_EVENT_ACTIVATE,
1223 _e_mod_drm_cb_activate, NULL);
1224
1225 output_handler =
1226 ecore_event_handler_add(ECORE_DRM2_EVENT_OUTPUT_CHANGED,
1227 _e_mod_drm_cb_output, NULL);
1228#else
759 activate_handler = 1229 activate_handler =
760 ecore_event_handler_add(ECORE_DRM_EVENT_ACTIVATE, 1230 ecore_event_handler_add(ECORE_DRM_EVENT_ACTIVATE,
761 _e_mod_drm_cb_activate, NULL); 1231 _e_mod_drm_cb_activate, NULL);
@@ -763,6 +1233,7 @@ e_modapi_init(E_Module *m)
763 output_handler = 1233 output_handler =
764 ecore_event_handler_add(ECORE_DRM_EVENT_OUTPUT, 1234 ecore_event_handler_add(ECORE_DRM_EVENT_OUTPUT,
765 _e_mod_drm_cb_output, NULL); 1235 _e_mod_drm_cb_output, NULL);
1236#endif
766 1237
767 return m; 1238 return m;
768} 1239}