uterm: video: share set_dpms code
The set_dpms callback of dumb and drm backends is identical so share it in drm-shared module. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
1 parent
415a53bfd7
commit
ca6d86d8e8
5 files changed
+25
-45
No files matched your search
@@ -281,6 +281,27 @@ void uterm_drm_display_deactivate(struct uterm_display *disp, int fd)
|
||||
ddrm->crtc_id = 0;
|
||||
}
|
||||
|
||||
int uterm_drm_display_set_dpms(struct uterm_display *disp, int state)
|
||||
{
|
||||
int ret;
|
||||
struct uterm_drm_display *ddrm = disp->data;
|
||||
struct uterm_drm_video *vdrm;
|
||||
|
||||
if (!display_is_conn(disp) || !video_is_awake(disp->video))
|
||||
return -EINVAL;
|
||||
|
||||
vdrm = disp->video->data;
|
||||
log_info("setting DPMS of display %p to %s", disp,
|
||||
uterm_dpms_to_name(state));
|
||||
|
||||
ret = uterm_drm_set_dpms(vdrm->fd, ddrm->conn_id, state);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
disp->dpms = ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uterm_drm_display_bind(struct uterm_video *video,
|
||||
struct uterm_display *disp, drmModeRes *res,
|
||||
drmModeConnector *conn, int fd)
|
||||
|
||||
@@ -79,6 +79,7 @@ int uterm_drm_display_bind(struct uterm_video *video,
|
||||
struct uterm_display *disp, drmModeRes *res,
|
||||
drmModeConnector *conn, int fd);
|
||||
void uterm_drm_display_unbind(struct uterm_display *disp);
|
||||
int uterm_drm_display_set_dpms(struct uterm_display *disp, int state);
|
||||
|
||||
static inline void *uterm_drm_display_get_data(struct uterm_display *disp)
|
||||
{
|
||||
|
||||
+1
-22
@@ -312,27 +312,6 @@ static void display_deactivate(struct uterm_display *disp)
|
||||
disp->flags &= ~(DISPLAY_ONLINE | DISPLAY_VSYNC);
|
||||
}
|
||||
|
||||
static int display_set_dpms(struct uterm_display *disp, int state)
|
||||
{
|
||||
int ret;
|
||||
struct uterm_drm_display *ddrm = disp->data;
|
||||
struct uterm_drm_video *vdrm;
|
||||
|
||||
if (!display_is_conn(disp) || !video_is_awake(disp->video))
|
||||
return -EINVAL;
|
||||
|
||||
vdrm = disp->video->data;
|
||||
log_info("setting DPMS of display %p to %s", disp,
|
||||
uterm_dpms_to_name(state));
|
||||
|
||||
ret = uterm_drm_set_dpms(vdrm->fd, ddrm->conn_id, state);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
disp->dpms = ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int display_use(struct uterm_display *disp)
|
||||
{
|
||||
struct uterm_drm3d_display *d3d = uterm_drm_display_get_data(disp);
|
||||
@@ -922,7 +901,7 @@ static const struct display_ops drm_display_ops = {
|
||||
.destroy = display_destroy,
|
||||
.activate = display_activate,
|
||||
.deactivate = display_deactivate,
|
||||
.set_dpms = display_set_dpms,
|
||||
.set_dpms = uterm_drm_display_set_dpms,
|
||||
.use = display_use,
|
||||
.swap = display_swap,
|
||||
.blit = display_blit,
|
||||
|
||||
+1
-22
@@ -246,27 +246,6 @@ static void display_deactivate(struct uterm_display *disp)
|
||||
disp->flags &= ~(DISPLAY_ONLINE | DISPLAY_VSYNC);
|
||||
}
|
||||
|
||||
static int display_set_dpms(struct uterm_display *disp, int state)
|
||||
{
|
||||
int ret;
|
||||
struct uterm_drm_display *ddrm = disp->data;
|
||||
struct uterm_drm_video *vdrm;
|
||||
|
||||
if (!display_is_conn(disp) || !video_is_awake(disp->video))
|
||||
return -EINVAL;
|
||||
|
||||
vdrm = disp->video->data;
|
||||
log_info("setting DPMS of display %p to %s", disp,
|
||||
uterm_dpms_to_name(state));
|
||||
|
||||
ret = uterm_drm_set_dpms(vdrm->fd, ddrm->conn_id, state);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
disp->dpms = ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int display_swap(struct uterm_display *disp)
|
||||
{
|
||||
int ret;
|
||||
@@ -477,7 +456,7 @@ static const struct display_ops dumb_display_ops = {
|
||||
.destroy = display_destroy,
|
||||
.activate = display_activate,
|
||||
.deactivate = display_deactivate,
|
||||
.set_dpms = display_set_dpms,
|
||||
.set_dpms = uterm_drm_display_set_dpms,
|
||||
.use = NULL,
|
||||
.swap = display_swap,
|
||||
.blit = display_blit,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* uterm - Linux User-Space Terminal
|
||||
*
|
||||
* Copyright (c) 2011-2012 David Herrmann <dh.herrmann@googlemail.com>
|
||||
* Copyright (c) 2011-2013 David Herrmann <dh.herrmann@googlemail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files
|
||||
|
||||
Reference in new issue
Block a user