summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell King <rmk+cubox@arm.linux.org.uk>2013-08-28 13:52:50 +0100
committerRussell King <rmk@arm.linux.org.uk>2013-10-29 19:21:12 +0000
commit4a1e818c35f61f0f18eaf3d2884011f3913db596 (patch)
tree46756fe211816b3e1d5286926e7fefa559a80ee6
parent9c63a8a7442131a6aa3ea8823a8b1390084c256c (diff)
downloadxf86-video-armada-4a1e818c35f61f0f18eaf3d2884011f3913db596.tar.gz
xf86-video-armada-4a1e818c35f61f0f18eaf3d2884011f3913db596.tar.xz
Move bo map/unmap to vivante_utils.c
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
-rw-r--r--src/vivante.c42
-rw-r--r--src/vivante_utils.c50
-rw-r--r--src/vivante_utils.h6
3 files changed, 56 insertions, 42 deletions
diff --git a/src/vivante.c b/src/vivante.c
index 210d5f8..cdeaddb 100644
--- a/src/vivante.c
+++ b/src/vivante.c
@@ -38,48 +38,6 @@
vivante_Key vivante_pixmap_index;
vivante_Key vivante_screen_index;
-static Bool vivante_map_bo_to_gpu(struct vivante *vivante,
- struct drm_armada_bo *bo, void **info, uint32_t *handle)
-{
- struct map_dma_buf map;
- gceSTATUS status;
- int fd;
-
- if (drm_armada_bo_to_fd(bo, &fd)) {
- xf86DrvMsg(vivante->scrnIndex, X_ERROR,
- "vivante: unable to get prime fd for bo: %s\n",
- strerror(errno));
- return FALSE;
- }
-
- map.zero = 0;
- map.fd = fd;
-
- status = gcoOS_DeviceControl(vivante->os, IOC_GDMABUF_MAP,
- &map, sizeof(map), &map, sizeof(map));
-
- /* we don't need to keep the fd around anymore */
- close(fd);
-
- if (gcmIS_ERROR(status)) {
- xf86DrvMsg(vivante->scrnIndex, X_INFO,
- "vivante: gpu dmabuf map failed: %d\n",
- status);
- return FALSE;
- }
-
- *handle = map.Address;
- *info = map.Info;
-
- return TRUE;
-}
-
-static void vivante_unmap_from_gpu(struct vivante *vivante, void *info,
- uint32_t handle)
-{
- gcoOS_UnmapUserMemory(vivante->os, (void *)1, 1, info, handle);
-}
-
void vivante_free_pixmap(PixmapPtr pixmap)
{
struct vivante_pixmap *vPix = vivante_get_pixmap_priv(pixmap);
diff --git a/src/vivante_utils.c b/src/vivante_utils.c
index 086f0a0..cfa9697 100644
--- a/src/vivante_utils.c
+++ b/src/vivante_utils.c
@@ -7,6 +7,12 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <unistd.h>
+
#ifdef HAVE_DIX_CONFIG_H
#include "dix-config.h"
#endif
@@ -15,6 +21,7 @@
#include "xf86.h"
#include <armada_bufmgr.h>
+#include "gal_extension.h"
#include "vivante_accel.h"
#include "vivante_utils.h"
@@ -104,6 +111,49 @@ void vivante_unmap_gpu(struct vivante *vivante, struct vivante_pixmap *vPix)
vPix->info = NULL;
}
+
+Bool vivante_map_bo_to_gpu(struct vivante *vivante, struct drm_armada_bo *bo,
+ void **info, uint32_t *handle)
+{
+ struct map_dma_buf map;
+ gceSTATUS status;
+ int fd;
+
+ if (drm_armada_bo_to_fd(bo, &fd)) {
+ xf86DrvMsg(vivante->scrnIndex, X_ERROR,
+ "vivante: unable to get prime fd for bo: %s\n",
+ strerror(errno));
+ return FALSE;
+ }
+
+ map.zero = 0;
+ map.fd = fd;
+
+ status = gcoOS_DeviceControl(vivante->os, IOC_GDMABUF_MAP,
+ &map, sizeof(map), &map, sizeof(map));
+
+ /* we don't need to keep the fd around anymore */
+ close(fd);
+
+ if (gcmIS_ERROR(status)) {
+ xf86DrvMsg(vivante->scrnIndex, X_INFO,
+ "vivante: gpu dmabuf map failed: %d\n",
+ status);
+ return FALSE;
+ }
+
+ *handle = map.Address;
+ *info = map.Info;
+
+ return TRUE;
+}
+
+void vivante_unmap_from_gpu(struct vivante *vivante, void *info,
+ uint32_t handle)
+{
+ gcoOS_UnmapUserMemory(vivante->os, (void *)1, 1, info, handle);
+}
+
/*
* Map a pixmap to the GPU, and mark the GPU as owning this BO.
*/
diff --git a/src/vivante_utils.h b/src/vivante_utils.h
index f21cf86..e7bd2d4 100644
--- a/src/vivante_utils.h
+++ b/src/vivante_utils.h
@@ -29,6 +29,12 @@ static inline PixmapPtr vivante_drawable_pixmap(DrawablePtr pDrawable)
}
PixmapPtr vivante_drawable_pixmap_deltas(DrawablePtr pDrawable, int *x, int *y);
+
+Bool vivante_map_bo_to_gpu(struct vivante *vivante, struct drm_armada_bo *bo,
+ void **info, uint32_t *handle);
+void vivante_unmap_from_gpu(struct vivante *vivante, void *info,
+ uint32_t handle);
+
void vivante_unmap_gpu(struct vivante *vivante, struct vivante_pixmap *vPix);
Bool vivante_map_gpu(struct vivante *vivante, struct vivante_pixmap *vPix);