summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@googlemail.com>2013-01-12 01:01:54 +0100
committerDavid Herrmann <dh.herrmann@googlemail.com>2013-01-12 01:01:54 +0100
commit415a53bfd7d2c9624485c536631c1a94baab241a (patch)
treeb956d264ae3d15e7de053bf19869f2428475ad28 /src
parent9d70156dc9614016fa3a56135f628b485ea8355a (diff)
uterm: share drm-video wakeup helpers
The dumb and drm backends still use the same code to perform wakeup/sleep code. Hence, move it into the drm-shared file so we can use the same helpers for both. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Diffstat (limited to 'src')
-rw-r--r--src/uterm_drm_shared.c38
-rw-r--r--src/uterm_drm_shared_internal.h5
-rw-r--r--src/uterm_video_drm.c29
-rw-r--r--src/uterm_video_dumb.c29
4 files changed, 51 insertions, 50 deletions
diff --git a/src/uterm_drm_shared.c b/src/uterm_drm_shared.c
index 13f06c2..72c2fe0 100644
--- a/src/uterm_drm_shared.c
+++ b/src/uterm_drm_shared.c
@@ -516,3 +516,41 @@ int uterm_drm_video_hotplug(struct uterm_video *video,
video->flags &= ~VIDEO_HOTPLUG;
return 0;
}
+
+int uterm_drm_video_wake_up(struct uterm_video *video,
+ const struct display_ops *ops)
+{
+ int ret;
+ struct uterm_drm_video *vdrm = video->data;
+
+ ret = drmSetMaster(vdrm->fd);
+ if (ret) {
+ log_err("cannot set DRM-master");
+ return -EACCES;
+ }
+
+ video->flags |= VIDEO_AWAKE;
+ ret = uterm_drm_video_hotplug(video, ops);
+ if (ret) {
+ video->flags &= ~VIDEO_AWAKE;
+ drmDropMaster(vdrm->fd);
+ return ret;
+ }
+
+ return 0;
+}
+
+void uterm_drm_video_sleep(struct uterm_video *video)
+{
+ struct uterm_drm_video *vdrm = video->data;
+
+ drmDropMaster(vdrm->fd);
+ video->flags &= ~VIDEO_AWAKE;
+}
+
+int uterm_drm_video_poll(struct uterm_video *video,
+ const struct display_ops *ops)
+{
+ video->flags |= VIDEO_HOTPLUG;
+ return uterm_drm_video_hotplug(video, ops);
+}
diff --git a/src/uterm_drm_shared_internal.h b/src/uterm_drm_shared_internal.h
index be7315f..b00bc76 100644
--- a/src/uterm_drm_shared_internal.h
+++ b/src/uterm_drm_shared_internal.h
@@ -107,6 +107,11 @@ int uterm_drm_video_find_crtc(struct uterm_video *video, drmModeRes *res,
drmModeEncoder *enc);
int uterm_drm_video_hotplug(struct uterm_video *video,
const struct display_ops *ops);
+int uterm_drm_video_wake_up(struct uterm_video *video,
+ const struct display_ops *ops);
+void uterm_drm_video_sleep(struct uterm_video *video);
+int uterm_drm_video_poll(struct uterm_video *video,
+ const struct display_ops *ops);
static inline void *uterm_drm_video_get_data(struct uterm_video *video)
{
diff --git a/src/uterm_video_drm.c b/src/uterm_video_drm.c
index 4790f6c..7697add 100644
--- a/src/uterm_video_drm.c
+++ b/src/uterm_video_drm.c
@@ -1124,43 +1124,22 @@ static void video_destroy(struct uterm_video *video)
static int video_poll(struct uterm_video *video)
{
- video->flags |= VIDEO_HOTPLUG;
- return uterm_drm_video_hotplug(video, &drm_display_ops);
+ return uterm_drm_video_poll(video, &drm_display_ops);
}
static void video_sleep(struct uterm_video *video)
{
- struct uterm_drm_video *vdrm = video->data;
-
- if (!video_is_awake(video))
- return;
-
show_displays(video);
- drmDropMaster(vdrm->fd);
- video->flags &= ~VIDEO_AWAKE;
+ uterm_drm_video_sleep(video);
}
static int video_wake_up(struct uterm_video *video)
{
int ret;
- struct uterm_drm_video *vdrm = video->data;
-
- if (video_is_awake(video))
- return 0;
-
- ret = drmSetMaster(vdrm->fd);
- if (ret) {
- log_err("cannot set DRM-master");
- return -EACCES;
- }
- video->flags |= VIDEO_AWAKE;
- ret = uterm_drm_video_hotplug(video, &drm_display_ops);
- if (ret) {
- video->flags &= ~VIDEO_AWAKE;
- drmDropMaster(vdrm->fd);
+ ret = uterm_drm_video_wake_up(video, &drm_display_ops);
+ if (ret)
return ret;
- }
show_displays(video);
return 0;
diff --git a/src/uterm_video_dumb.c b/src/uterm_video_dumb.c
index 5c07852..95e0109 100644
--- a/src/uterm_video_dumb.c
+++ b/src/uterm_video_dumb.c
@@ -569,43 +569,22 @@ static void video_destroy(struct uterm_video *video)
static int video_poll(struct uterm_video *video)
{
- video->flags |= VIDEO_HOTPLUG;
- return uterm_drm_video_hotplug(video, &dumb_display_ops);
+ return uterm_drm_video_poll(video, &dumb_display_ops);
}
static void video_sleep(struct uterm_video *video)
{
- struct uterm_drm_video *vdrm = video->data;
-
- if (!video_is_awake(video))
- return;
-
show_displays(video);
- drmDropMaster(vdrm->fd);
- video->flags &= ~VIDEO_AWAKE;
+ uterm_drm_video_sleep(video);
}
static int video_wake_up(struct uterm_video *video)
{
int ret;
- struct uterm_drm_video *vdrm = video->data;
-
- if (video_is_awake(video))
- return 0;
- ret = drmSetMaster(vdrm->fd);
- if (ret) {
- log_err("cannot set DRM-master");
- return -EACCES;
- }
-
- video->flags |= VIDEO_AWAKE;
- ret = uterm_drm_video_hotplug(video, &dumb_display_ops);
- if (ret) {
- video->flags &= ~VIDEO_AWAKE;
- drmDropMaster(vdrm->fd);
+ ret = uterm_drm_video_wake_up(video, &dumb_display_ops);
+ if (ret)
return ret;
- }
show_displays(video);
return 0;