diff options
author | Gurchetan Singh <gurchetansingh@chromium.org> | 2016-08-12 16:38:25 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-08-17 19:15:51 -0700 |
commit | ef920536083c3e6959daa6a98db01b0f653c1c83 (patch) | |
tree | 39147f8f0e9a43dfbbb667a067e1e371309fc385 /mediatek.c | |
parent | 1647fbe1196e21cb314a4c9b950846393e1dbc6a (diff) |
minigbm: Add mmap() in backends
Gralloc requires the ability to mmap a buffer into userspace. This
change adds the necessary entry points to our internal "drv"
interface.
BUG=chromium:616275
TEST=minigbm still builds. Also ran:
./gralloctest mapping
with CL:362062 applied on minnie and cyan (decided to split that CL
into smaller patches).
CQ-DEPEND=CL:366041
Change-Id: I7396b0c79702f24eb779984805bc679c237bd932
Reviewed-on: https://chromium-review.googlesource.com/370798
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Diffstat (limited to 'mediatek.c')
-rw-r--r-- | mediatek.c | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -8,9 +8,10 @@ #include <stdio.h> #include <string.h> +#include <sys/mman.h> #include <xf86drm.h> #include <mediatek_drm.h> -#include <stdio.h> + #include "drv_priv.h" #include "helpers.h" @@ -42,11 +43,30 @@ static int drv_mediatek_bo_create(struct bo *bo, return 0; } +static void *drv_mediatek_bo_map(struct bo *bo) +{ + int ret; + struct drm_mtk_gem_map_off gem_map; + + memset(&gem_map, 0, sizeof(gem_map)); + gem_map.handle = bo->handles[0].u32; + + ret = drmIoctl(bo->drv->fd, DRM_IOCTL_MTK_GEM_MAP_OFFSET, &gem_map); + if (ret) { + fprintf(stderr,"drv: DRM_IOCTL_MTK_GEM_MAP_OFFSET failed\n"); + return MAP_FAILED; + } + + return mmap(0, bo->sizes[0], PROT_READ | PROT_WRITE, MAP_SHARED, + bo->drv->fd, gem_map.offset); +} + const struct backend backend_mediatek = { .name = "mediatek", .bo_create = drv_mediatek_bo_create, .bo_destroy = drv_gem_bo_destroy, + .bo_map = drv_mediatek_bo_map, .format_list = { {DRV_FORMAT_XRGB8888, DRV_BO_USE_SCANOUT | DRV_BO_USE_CURSOR | DRV_BO_USE_RENDERING}, {DRV_FORMAT_XRGB8888, DRV_BO_USE_SCANOUT | DRV_BO_USE_CURSOR | DRV_BO_USE_LINEAR}, |