summaryrefslogtreecommitdiff
path: root/src/lib/ecore_drm/ecore_drm_device.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/ecore_drm/ecore_drm_device.c')
-rw-r--r--src/lib/ecore_drm/ecore_drm_device.c132
1 files changed, 65 insertions, 67 deletions
diff --git a/src/lib/ecore_drm/ecore_drm_device.c b/src/lib/ecore_drm/ecore_drm_device.c
index cca3332..756a5fc 100644
--- a/src/lib/ecore_drm/ecore_drm_device.c
+++ b/src/lib/ecore_drm/ecore_drm_device.c
@@ -10,93 +10,86 @@
10 ((x) >= (xx)) && ((y) >= (yy))) 10 ((x) >= (xx)) && ((y) >= (yy)))
11 11
12static Eina_List *drm_devices; 12static Eina_List *drm_devices;
13static int flip_count = 0; 13static int ticking = 0;
14 14
15static void 15static void
16_ecore_drm_device_cb_page_flip(int fd EINA_UNUSED, unsigned int frame EINA_UNUSED, unsigned int sec EINA_UNUSED, unsigned int usec EINA_UNUSED, void *data) 16_ecore_drm_tick_schedule(Ecore_Drm_Device *dev)
17{ 17{
18 Ecore_Drm_Pageflip_Callback *cb; 18 drmVBlank vbl;
19
20 /* DBG("Drm Page Flip Event"); */
21
22 if (!(cb = data)) return;
23
24 flip_count++;
25 if (flip_count < cb->count) return;
26 19
27 cb->dev->current = cb->dev->next; 20 if (!ticking) return;
28 cb->dev->next = NULL;
29 21
30 flip_count = 0; 22 vbl.request.type = (DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT);
31 if (cb->func) cb->func(cb->data); 23 vbl.request.sequence = 1;
32 /* free(cb); */ 24 vbl.request.signal = (unsigned long)dev;
25 drmWaitVBlank(dev->drm.fd, &vbl);
26}
33 27
34 /* Ecore_Drm_Output *output; */ 28static void
29_ecore_drm_tick_begin(void *data)
30{
31 ticking = 1;
32 _ecore_drm_tick_schedule(data);
33}
35 34
36 /* DBG("Drm Page Flip Event"); */ 35static void
36_ecore_drm_tick_end(void *data EINA_UNUSED)
37{
38 ticking = 0;
39}
37 40
38 /* if (!(output = data)) return; */ 41static void
42_ecore_drm_tick_source_set(Ecore_Drm_Device *dev)
43{
44 ecore_animator_custom_source_tick_begin_callback_set
45 (_ecore_drm_tick_begin, dev);
46 ecore_animator_custom_source_tick_end_callback_set
47 (_ecore_drm_tick_end, dev);
48 ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM);
49}
39 50
40 /* if (output->pending_flip) */ 51static void
41 /* { */ 52_ecore_drm_device_cb_page_flip(int fd EINA_UNUSED, unsigned int frame EINA_UNUSED, unsigned int sec EINA_UNUSED, unsigned int usec EINA_UNUSED, void *data)
42 /* if (output->dev->current) */ 53{
43 /* ecore_drm_output_fb_release(output, output->dev->current); */ 54 Ecore_Drm_Output *output = data;
44 /* output->dev->current = output->dev->next; */ 55 Ecore_Drm_Fb *next;
45 /* output->dev->next = NULL; */
46 /* } */
47 56
48 /* output->pending_flip = EINA_FALSE; */ 57 if (output->pending_destroy)
49 /* if (output->pending_destroy) */ 58 {
50 /* { */ 59 ecore_drm_output_free(output);
51 /* output->pending_destroy = EINA_FALSE; */ 60 return;
52 /* ecore_drm_output_free(output); */ 61 }
53 /* } */ 62 /* We were unable to queue a page on the last flip attempt, so we'll
54 /* else if (!output->pending_vblank) */ 63 * try again now. */
55 /* ecore_drm_output_repaint(output); */ 64 next = output->next;
65 if (next)
66 {
67 output->next = NULL;
68 ecore_drm_fb_send(output->dev, next, NULL, NULL);
69 }
56} 70}
57 71
58static void 72static void
59_ecore_drm_device_cb_vblank(int fd EINA_UNUSED, unsigned int frame EINA_UNUSED, unsigned int sec EINA_UNUSED, unsigned int usec EINA_UNUSED, void *data) 73_ecore_drm_device_cb_vblank(int fd EINA_UNUSED, unsigned int frame EINA_UNUSED, unsigned int sec EINA_UNUSED, unsigned int usec EINA_UNUSED, void *data)
60{ 74{
61 Ecore_Drm_Sprite *sprite; 75 ecore_animator_custom_tick();
62 Ecore_Drm_Output *output; 76 if (ticking) _ecore_drm_tick_schedule(data);
63
64 /* DBG("Drm VBlank Event"); */
65
66 if (!(sprite = data)) return;
67
68 output = sprite->output;
69 output->pending_vblank = EINA_FALSE;
70
71 ecore_drm_output_fb_release(output, sprite->current_fb);
72 sprite->current_fb = sprite->next_fb;
73 sprite->next_fb = NULL;
74
75 if (!output->pending_flip) _ecore_drm_output_frame_finish(output);
76} 77}
77 78
78#if 0 79static Eina_Bool
79static Eina_Bool 80_cb_drm_event_handle(void *data, Ecore_Fd_Handler *hdlr EINA_UNUSED)
80_ecore_drm_device_cb_idle(void *data)
81{ 81{
82 Ecore_Drm_Device *dev; 82 Ecore_Drm_Device *dev = data;
83 Ecore_Drm_Output *output; 83 int err;
84 Eina_List *l;
85
86 if (!(dev = data)) return ECORE_CALLBACK_CANCEL;
87 84
88 if (!dev->active) return ECORE_CALLBACK_RENEW; 85 err = drmHandleEvent(dev->drm.fd, &dev->drm_ctx);
89 86 if (err)
90 EINA_LIST_FOREACH(dev->outputs, l, output)
91 { 87 {
92 if ((!output->enabled) || (!output->need_repaint)) continue; 88 ERR("drmHandleEvent failed to read an event");
93 if (output->repaint_scheduled) continue; 89 return EINA_FALSE;
94 _ecore_drm_output_repaint_start(output);
95 } 90 }
96 91 return EINA_TRUE;
97 return ECORE_CALLBACK_RENEW;
98} 92}
99#endif
100 93
101static void 94static void
102_ecore_drm_device_cb_output_event(const char *device EINA_UNUSED, Eeze_Udev_Event event EINA_UNUSED, void *data, Eeze_Udev_Watch *watch EINA_UNUSED) 95_ecore_drm_device_cb_output_event(const char *device EINA_UNUSED, Eeze_Udev_Event event EINA_UNUSED, void *data, Eeze_Udev_Watch *watch EINA_UNUSED)
@@ -379,6 +372,10 @@ ecore_drm_device_open(Ecore_Drm_Device *dev)
379 eeze_udev_watch_add(EEZE_UDEV_TYPE_DRM, events, 372 eeze_udev_watch_add(EEZE_UDEV_TYPE_DRM, events,
380 _ecore_drm_device_cb_output_event, dev); 373 _ecore_drm_device_cb_output_event, dev);
381 374
375 dev->drm.hdlr =
376 ecore_main_fd_handler_add(dev->drm.fd, ECORE_FD_READ,
377 _cb_drm_event_handle, dev, NULL, NULL);
378
382 /* dev->drm.idler = */ 379 /* dev->drm.idler = */
383 /* ecore_idle_enterer_add(_ecore_drm_device_cb_idle, dev); */ 380 /* ecore_idle_enterer_add(_ecore_drm_device_cb_idle, dev); */
384 381
@@ -546,6 +543,7 @@ ecore_drm_device_software_setup(Ecore_Drm_Device *dev)
546 DBG("\tSize: %d", dev->dumb[i]->size); 543 DBG("\tSize: %d", dev->dumb[i]->size);
547 DBG("\tW: %d\tH: %d", dev->dumb[i]->w, dev->dumb[i]->h); 544 DBG("\tW: %d\tH: %d", dev->dumb[i]->w, dev->dumb[i]->h);
548 } 545 }
546 _ecore_drm_tick_source_set(dev);
549 547
550 return EINA_TRUE; 548 return EINA_TRUE;
551 549