From b1c7902eebe618922869318c892508f3f9af5499 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sun, 28 Oct 2012 14:22:19 +0100 Subject: [PATCH] uterm: enable DRM helpers with UTERM_VIDEO_DUMB The DRM helpers can actually also be used with dumb-displays so provide it in both cases. Signed-off-by: David Herrmann --- src/uterm_video.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++----- src/uterm_video_drm.c | 46 ---------------------------------------------- 2 files changed, 46 insertions(+), 51 deletions(-) diff --git a/src/uterm_video.h b/src/uterm_video.h index 9d66ef8..6d1c812 100644 --- a/src/uterm_video.h +++ b/src/uterm_video.h @@ -418,12 +418,53 @@ static inline int video_do_use(struct uterm_video *video) return VIDEO_CALL(video->ops->use, -EOPNOTSUPP, video); } -#ifdef BUILD_ENABLE_VIDEO_DRM +#if defined(BUILD_ENABLE_VIDEO_DRM) || defined(BUILD_ENABLE_VIDEO_DUMB) + +static inline char *video_drm_get_id(int fd) +{ + if (fd < 0) + return NULL; + + return drmGetBusid(fd); +} -char *video_drm_get_id(int fd); -void video_drm_free_id(char *id); -char *video_drm_get_name(int fd); -void video_drm_free_name(char *name); +static inline void video_drm_free_id(char *id) +{ + if (!id) + return; + + drmFreeBusid(id); +} + +static inline char *video_drm_get_name(int fd) +{ + drmVersionPtr v; + char *name; + + if (fd < 0) + return NULL; + + v = drmGetVersion(fd); + if (!v) + return NULL; + + name = malloc(v->name_len + 1); + if (name) { + memcpy(name, v->name, v->name_len); + name[v->name_len] = 0; + } + + drmFreeVersion(v); + return name; +} + +static inline void video_drm_free_name(char *name) +{ + if (!name) + return; + + free(name); +} #else diff --git a/src/uterm_video_drm.c b/src/uterm_video_drm.c index e0c3bc8..a54b603 100644 --- a/src/uterm_video_drm.c +++ b/src/uterm_video_drm.c @@ -1251,52 +1251,6 @@ static int video_wake_up(struct uterm_video *video) return 0; } -char *video_drm_get_id(int fd) -{ - if (fd < 0) - return NULL; - - return drmGetBusid(fd); -} - -void video_drm_free_id(char *id) -{ - if (!id) - return; - - drmFreeBusid(id); -} - -char *video_drm_get_name(int fd) -{ - drmVersionPtr v; - char *name; - - if (fd < 0) - return NULL; - - v = drmGetVersion(fd); - if (!v) - return NULL; - - name = malloc(v->name_len + 1); - if (name) { - memcpy(name, v->name, v->name_len); - name[v->name_len] = 0; - } - - drmFreeVersion(v); - return name; -} - -void video_drm_free_name(char *name) -{ - if (!name) - return; - - free(name); -} - const struct mode_ops drm_mode_ops = { .init = NULL, .destroy = NULL, -- 2.7.4