118 lines
4.3 KiB
Diff
118 lines
4.3 KiB
Diff
|
From 66695cc343647dcbf654fbb4b3f38bd1ee092a0d Mon Sep 17 00:00:00 2001
|
||
|
From: David Herrmann <dh.herrmann@gmail.com>
|
||
|
Date: Thu, 2 Oct 2014 18:47:01 +0200
|
||
|
Subject: [PATCH] terminal/grdev: allow arbitrary fb-age contexts
|
||
|
|
||
|
Instead of limiting fb-aging to 64bit integers, allow any arbitrary
|
||
|
context together with a release function to free it once the FB is
|
||
|
destroyed.
|
||
|
---
|
||
|
src/libsystemd-terminal/grdev-drm.c | 3 +++
|
||
|
src/libsystemd-terminal/grdev.c | 11 +----------
|
||
|
src/libsystemd-terminal/grdev.h | 14 ++++++++++----
|
||
|
src/libsystemd-terminal/modeset.c | 2 +-
|
||
|
4 files changed, 15 insertions(+), 15 deletions(-)
|
||
|
|
||
|
diff --git a/src/libsystemd-terminal/grdev-drm.c b/src/libsystemd-terminal/grdev-drm.c
|
||
|
index 57b930bc0f..f01df1dae2 100644
|
||
|
--- a/src/libsystemd-terminal/grdev-drm.c
|
||
|
+++ b/src/libsystemd-terminal/grdev-drm.c
|
||
|
@@ -1442,6 +1442,9 @@ grdrm_fb *grdrm_fb_free(grdrm_fb *fb) {
|
||
|
|
||
|
assert(fb->card);
|
||
|
|
||
|
+ if (fb->base.free_fn)
|
||
|
+ fb->base.free_fn(fb->base.data.ptr);
|
||
|
+
|
||
|
if (fb->id > 0 && fb->card->fd >= 0) {
|
||
|
r = ioctl(fb->card->fd, DRM_IOCTL_MODE_RMFB, fb->id);
|
||
|
if (r < 0)
|
||
|
diff --git a/src/libsystemd-terminal/grdev.c b/src/libsystemd-terminal/grdev.c
|
||
|
index a700a7316b..0c21eac551 100644
|
||
|
--- a/src/libsystemd-terminal/grdev.c
|
||
|
+++ b/src/libsystemd-terminal/grdev.c
|
||
|
@@ -393,28 +393,19 @@ const grdev_display_target *grdev_display_next_target(grdev_display *display, co
|
||
|
return NULL;
|
||
|
}
|
||
|
|
||
|
-void grdev_display_flip_target(grdev_display *display, const grdev_display_target *target, uint64_t age) {
|
||
|
+void grdev_display_flip_target(grdev_display *display, const grdev_display_target *target) {
|
||
|
grdev_display_cache *cache;
|
||
|
- size_t i;
|
||
|
|
||
|
assert(display);
|
||
|
assert(!display->modified);
|
||
|
assert(display->enabled);
|
||
|
assert(target);
|
||
|
- assert(target->back);
|
||
|
|
||
|
cache = container_of(target, grdev_display_cache, target);
|
||
|
|
||
|
assert(cache->pipe);
|
||
|
assert(cache->pipe->tile->display == display);
|
||
|
|
||
|
- /* reset age of all FB on overflow */
|
||
|
- if (age < target->back->age)
|
||
|
- for (i = 0; i < cache->pipe->max_fbs; ++i)
|
||
|
- if (cache->pipe->fbs[i])
|
||
|
- cache->pipe->fbs[i]->age = 0;
|
||
|
-
|
||
|
- ((grdev_fb*)target->back)->age = age;
|
||
|
cache->pipe->flip = true;
|
||
|
}
|
||
|
|
||
|
diff --git a/src/libsystemd-terminal/grdev.h b/src/libsystemd-terminal/grdev.h
|
||
|
index ca0373ed29..35d6eb2abf 100644
|
||
|
--- a/src/libsystemd-terminal/grdev.h
|
||
|
+++ b/src/libsystemd-terminal/grdev.h
|
||
|
@@ -93,9 +93,15 @@ struct grdev_fb {
|
||
|
uint32_t width;
|
||
|
uint32_t height;
|
||
|
uint32_t format;
|
||
|
- uint64_t age;
|
||
|
int32_t strides[4];
|
||
|
void *maps[4];
|
||
|
+
|
||
|
+ union {
|
||
|
+ void *ptr;
|
||
|
+ uint64_t u64;
|
||
|
+ } data;
|
||
|
+
|
||
|
+ void (*free_fn) (void *ptr);
|
||
|
};
|
||
|
|
||
|
struct grdev_display_target {
|
||
|
@@ -105,8 +111,8 @@ struct grdev_display_target {
|
||
|
uint32_t height;
|
||
|
unsigned int rotate;
|
||
|
unsigned int flip;
|
||
|
- const grdev_fb *front;
|
||
|
- const grdev_fb *back;
|
||
|
+ grdev_fb *front;
|
||
|
+ grdev_fb *back;
|
||
|
};
|
||
|
|
||
|
void grdev_display_set_userdata(grdev_display *display, void *userdata);
|
||
|
@@ -121,7 +127,7 @@ void grdev_display_enable(grdev_display *display);
|
||
|
void grdev_display_disable(grdev_display *display);
|
||
|
|
||
|
const grdev_display_target *grdev_display_next_target(grdev_display *display, const grdev_display_target *prev);
|
||
|
-void grdev_display_flip_target(grdev_display *display, const grdev_display_target *target, uint64_t age);
|
||
|
+void grdev_display_flip_target(grdev_display *display, const grdev_display_target *target);
|
||
|
|
||
|
#define GRDEV_DISPLAY_FOREACH_TARGET(_display, _t) \
|
||
|
for ((_t) = grdev_display_next_target((_display), NULL); \
|
||
|
diff --git a/src/libsystemd-terminal/modeset.c b/src/libsystemd-terminal/modeset.c
|
||
|
index 2f8860dd5f..f5be38e4fa 100644
|
||
|
--- a/src/libsystemd-terminal/modeset.c
|
||
|
+++ b/src/libsystemd-terminal/modeset.c
|
||
|
@@ -258,7 +258,7 @@ static void modeset_render(Modeset *m, grdev_display *d) {
|
||
|
|
||
|
GRDEV_DISPLAY_FOREACH_TARGET(d, t) {
|
||
|
modeset_draw(m, t);
|
||
|
- grdev_display_flip_target(d, t, 1);
|
||
|
+ grdev_display_flip_target(d, t);
|
||
|
}
|
||
|
|
||
|
grdev_session_commit(m->grdev_session);
|