summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King <rmk@armlinux.org.uk>2018-06-27 10:41:35 +0100
committerRussell King <rmk@armlinux.org.uk>2018-06-27 19:17:44 +0100
commit8d5454c1ac102c4e0e0ec5f724806d714b00cc40 (patch)
tree4d6ac16e65c3f2daa460a86e683044e4c5995a81
parent3d8cbe8c5a6a3b086b73e500edd92663337b5a05 (diff)
src: move armada_get_cap() to common_drm.c
There is nothing armada specific about armada_get_cap(), so move it to common_drm.c. Signed-off-by: Russell King <rmk@armlinux.org.uk>
-rw-r--r--src/armada_drm.c25
-rw-r--r--src/common_drm.c15
-rw-r--r--src/common_drm.h4
3 files changed, 24 insertions, 20 deletions
diff --git a/src/armada_drm.c b/src/armada_drm.c
index 567350d..6abdaf3 100644
--- a/src/armada_drm.c
+++ b/src/armada_drm.c
@@ -560,20 +560,6 @@ static Bool armada_drm_pre_init(ScrnInfoPtr pScrn)
return TRUE;
}
-static int armada_get_cap(int fd, uint64_t cap, uint64_t *val, int scrnIndex,
- const char *name)
-{
- int err;
-
- err = drmGetCap(fd, cap, val);
- if (err)
- xf86DrvMsg(scrnIndex, X_ERROR,
- "[drm] failed to get %s capability: %s\n",
- name, strerror(errno));
-
- return err;
-}
-
static Bool armada_drm_alloc(ScrnInfoPtr pScrn,
struct common_drm_device *drm_dev)
{
@@ -591,8 +577,9 @@ static Bool armada_drm_alloc(ScrnInfoPtr pScrn,
drm->common.fd = drm_dev->fd;
drm->common.dev = drm_dev;
- if (armada_get_cap(drm->common.fd, DRM_CAP_PRIME, &val,
- pScrn->scrnIndex, "DRM_CAP_PRIME"))
+ SET_DRM_INFO(pScrn, &drm->common);
+
+ if (common_drm_get_cap(pScrn, DRM_CAP_PRIME, &val))
goto err_free;
if (!(val & DRM_PRIME_CAP_EXPORT)) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
@@ -600,8 +587,7 @@ static Bool armada_drm_alloc(ScrnInfoPtr pScrn,
goto err_free;
}
- if (armada_get_cap(drm->common.fd, DRM_CAP_DUMB_BUFFER, &val,
- pScrn->scrnIndex, "DRM_CAP_DUMB_BUFFER"))
+ if (common_drm_get_cap(pScrn, DRM_CAP_DUMB_BUFFER, &val))
goto err_free;
if (!val) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
@@ -616,8 +602,6 @@ static Bool armada_drm_alloc(ScrnInfoPtr pScrn,
goto err_free;
}
- SET_DRM_INFO(pScrn, &drm->common);
-
drm->armada.version = drmGetVersion(drm->common.fd);
if (drm->armada.version)
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "hardware: %s\n",
@@ -626,6 +610,7 @@ static Bool armada_drm_alloc(ScrnInfoPtr pScrn,
return TRUE;
err_free:
+ SET_DRM_INFO(pScrn, NULL);
free(drm);
return FALSE;
}
diff --git a/src/common_drm.c b/src/common_drm.c
index 18e48a0..8d847e5 100644
--- a/src/common_drm.c
+++ b/src/common_drm.c
@@ -1089,6 +1089,21 @@ static Bool common_drm_CloseScreen(CLOSE_SCREEN_ARGS_DECL)
return ret;
}
+int __common_drm_get_cap(ScrnInfoPtr pScrn, uint64_t cap, uint64_t *val,
+ const char *name)
+{
+ struct common_drm_info *drm = GET_DRM_INFO(pScrn);
+ int err;
+
+ err = drmGetCap(drm->fd, cap, val);
+ if (err)
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "[drm] failed to get %s capability: %s\n",
+ name, strerror(errno));
+
+ return err;
+}
+
Bool common_drm_PreScreenInit(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
diff --git a/src/common_drm.h b/src/common_drm.h
index 62cbd17..ef144e0 100644
--- a/src/common_drm.h
+++ b/src/common_drm.h
@@ -121,6 +121,10 @@ void common_drm_flip_pixmap(ScreenPtr pScreen, PixmapPtr a, PixmapPtr b);
void common_drm_LoadPalette(ScrnInfoPtr pScrn, int num, int *indices,
LOCO *colors, VisualPtr pVisual);
+int __common_drm_get_cap(ScrnInfoPtr pScrn, uint64_t cap, uint64_t *val,
+ const char *name);
+#define common_drm_get_cap(pScrn, cap, val) \
+ __common_drm_get_cap(pScrn, cap, val, #cap)
Bool common_drm_PreScreenInit(ScreenPtr pScreen);
Bool common_drm_PostScreenInit(ScreenPtr pScreen);
Bool common_drm_SwitchMode(SWITCH_MODE_ARGS_DECL);