summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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;