diff options
author | Derek Foreman <derekf@osg.samsung.com> | 2017-07-28 15:25:25 -0500 |
---|---|---|
committer | Derek Foreman <derekf@osg.samsung.com> | 2017-07-28 15:35:03 -0500 |
commit | 0584fc81a2960c47426560fa52bab675b10527b5 (patch) | |
tree | 058d5a027763e2b00894def735b9de9f8cf94314 /src/lib/ecore_drm2 | |
parent | 6bb56b3f5651fab85b1a0a1a1a8040f4e488c799 (diff) |
ecore_drm2: Add a fallback method for vblank waiting
We can't depend on vblank waits being implemented by the driver, but we
can count on page flips functioning, so add a fallback that does a page
flip and waits for it.
Diffstat (limited to 'src/lib/ecore_drm2')
-rw-r--r-- | src/lib/ecore_drm2/ecore_drm2_outputs.c | 49 | ||||
-rw-r--r-- | src/lib/ecore_drm2/ecore_drm2_private.h | 2 |
2 files changed, 51 insertions, 0 deletions
diff --git a/src/lib/ecore_drm2/ecore_drm2_outputs.c b/src/lib/ecore_drm2/ecore_drm2_outputs.c index fba4be0c8d..85504a0d6d 100644 --- a/src/lib/ecore_drm2/ecore_drm2_outputs.c +++ b/src/lib/ecore_drm2/ecore_drm2_outputs.c | |||
@@ -1583,6 +1583,49 @@ ecore_drm2_output_subpixel_get(const Ecore_Drm2_Output *output) | |||
1583 | return output->subpixel; | 1583 | return output->subpixel; |
1584 | } | 1584 | } |
1585 | 1585 | ||
1586 | static void | ||
1587 | _blank_fallback_handler(int fd EINA_UNUSED, unsigned int frame EINA_UNUSED, unsigned int sec, unsigned int usec, void *data EINA_UNUSED) | ||
1588 | { | ||
1589 | Ecore_Drm2_Output *output; | ||
1590 | |||
1591 | output = data; | ||
1592 | output->fallback_usec = usec; | ||
1593 | output->fallback_sec = sec; | ||
1594 | } | ||
1595 | static int | ||
1596 | _blanktime_fallback(Ecore_Drm2_Output *output, int sequence, long *sec, long *usec) | ||
1597 | { | ||
1598 | drmEventContext ctx; | ||
1599 | int ret; | ||
1600 | |||
1601 | /* Too lazy to loop for > 1, and don't want to block for < 1 */ | ||
1602 | if (sequence != 1) return -1; | ||
1603 | |||
1604 | /* If we got here with a flip waiting to complete we can do nothing. */ | ||
1605 | if (output->pending.fb) return -1; | ||
1606 | |||
1607 | if (!output->current.fb) return -1; | ||
1608 | |||
1609 | memset(&ctx, 0, sizeof(ctx)); | ||
1610 | ctx.version = 2; | ||
1611 | ctx.page_flip_handler = _blank_fallback_handler; | ||
1612 | ctx.vblank_handler = NULL; | ||
1613 | |||
1614 | ret = sym_drmModePageFlip(output->current.fb->fd, output->crtc_id, | ||
1615 | output->current.fb->id, DRM_MODE_PAGE_FLIP_EVENT, | ||
1616 | output); | ||
1617 | if (ret < 0) return -1; | ||
1618 | do | ||
1619 | { | ||
1620 | ret = sym_drmHandleEvent(output->current.fb->fd, &ctx); | ||
1621 | } while (ret != 0 && errno == EAGAIN); | ||
1622 | if (ret < 0) return -1; | ||
1623 | |||
1624 | *sec = output->fallback_sec; | ||
1625 | *usec = output->fallback_usec; | ||
1626 | return 0; | ||
1627 | } | ||
1628 | |||
1586 | EAPI Eina_Bool | 1629 | EAPI Eina_Bool |
1587 | ecore_drm2_output_blanktime_get(Ecore_Drm2_Output *output, int sequence, long *sec, long *usec) | 1630 | ecore_drm2_output_blanktime_get(Ecore_Drm2_Output *output, int sequence, long *sec, long *usec) |
1588 | { | 1631 | { |
@@ -1597,6 +1640,12 @@ ecore_drm2_output_blanktime_get(Ecore_Drm2_Output *output, int sequence, long *s | |||
1597 | v.request.type = DRM_VBLANK_RELATIVE; | 1640 | v.request.type = DRM_VBLANK_RELATIVE; |
1598 | v.request.sequence = sequence; | 1641 | v.request.sequence = sequence; |
1599 | ret = sym_drmWaitVBlank(output->fd, &v); | 1642 | ret = sym_drmWaitVBlank(output->fd, &v); |
1643 | if (ret) | ||
1644 | { | ||
1645 | ret = _blanktime_fallback(output, sequence, sec, usec); | ||
1646 | if (ret) return EINA_FALSE; | ||
1647 | return EINA_TRUE; | ||
1648 | } | ||
1600 | if (ret) return EINA_FALSE; | 1649 | if (ret) return EINA_FALSE; |
1601 | if (v.reply.tval_sec < 0) return EINA_FALSE; | 1650 | if (v.reply.tval_sec < 0) return EINA_FALSE; |
1602 | if (v.reply.tval_usec < 0) return EINA_FALSE; | 1651 | if (v.reply.tval_usec < 0) return EINA_FALSE; |
diff --git a/src/lib/ecore_drm2/ecore_drm2_private.h b/src/lib/ecore_drm2/ecore_drm2_private.h index c8c2bf66c2..a85cb0c2d5 100644 --- a/src/lib/ecore_drm2/ecore_drm2_private.h +++ b/src/lib/ecore_drm2/ecore_drm2_private.h | |||
@@ -209,6 +209,8 @@ struct _Ecore_Drm2_Output | |||
209 | int pipe; | 209 | int pipe; |
210 | int x, y, w, h, pw, ph; | 210 | int x, y, w, h, pw, ph; |
211 | 211 | ||
212 | long fallback_sec, fallback_usec; | ||
213 | |||
212 | uint32_t subpixel; | 214 | uint32_t subpixel; |
213 | uint32_t crtc_id, conn_id, conn_type; | 215 | uint32_t crtc_id, conn_id, conn_type; |
214 | uint32_t scale; | 216 | uint32_t scale; |