OSDN Git Service

minigbm: Consolidate format info in new struct planar_layout
[android-x86/external-minigbm.git] / rockchip.c
index 7cecf3b..a0d9141 100644 (file)
@@ -186,7 +186,7 @@ static int rockchip_bo_create_with_modifiers(struct bo *bo, uint32_t width, uint
        } else {
                if (!has_modifier(modifiers, count, DRM_FORMAT_MOD_LINEAR)) {
                        errno = EINVAL;
-                       fprintf(stderr, "no usable modifier found\n");
+                       drv_log("no usable modifier found\n");
                        return -1;
                }
 
@@ -212,8 +212,7 @@ static int rockchip_bo_create_with_modifiers(struct bo *bo, uint32_t width, uint
        ret = drmIoctl(bo->drv->fd, DRM_IOCTL_ROCKCHIP_GEM_CREATE, &gem_create);
 
        if (ret) {
-               fprintf(stderr, "drv: DRM_IOCTL_ROCKCHIP_GEM_CREATE failed (size=%llu)\n",
-                       gem_create.size);
+               drv_log("DRM_IOCTL_ROCKCHIP_GEM_CREATE failed (size=%llu)\n", gem_create.size);
                return ret;
        }
 
@@ -247,7 +246,7 @@ static void *rockchip_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint3
 
        ret = drmIoctl(bo->drv->fd, DRM_IOCTL_ROCKCHIP_GEM_MAP_OFFSET, &gem_map);
        if (ret) {
-               fprintf(stderr, "drv: DRM_IOCTL_ROCKCHIP_GEM_MAP_OFFSET failed\n");
+               drv_log("DRM_IOCTL_ROCKCHIP_GEM_MAP_OFFSET failed\n");
                return MAP_FAILED;
        }
 
@@ -260,7 +259,6 @@ static void *rockchip_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint3
                priv = calloc(1, sizeof(*priv));
                priv->cached_addr = calloc(1, bo->total_size);
                priv->gem_addr = addr;
-               memcpy(priv->cached_addr, priv->gem_addr, bo->total_size);
                vma->priv = priv;
                addr = priv->cached_addr;
        }
@@ -281,6 +279,16 @@ static int rockchip_bo_unmap(struct bo *bo, struct vma *vma)
        return munmap(vma->addr, vma->length);
 }
 
+static int rockchip_bo_invalidate(struct bo *bo, struct mapping *mapping)
+{
+       if (mapping->vma->priv) {
+               struct rockchip_private_map_data *priv = mapping->vma->priv;
+               memcpy(priv->cached_addr, priv->gem_addr, bo->total_size);
+       }
+
+       return 0;
+}
+
 static int rockchip_bo_flush(struct bo *bo, struct mapping *mapping)
 {
        struct rockchip_private_map_data *priv = mapping->vma->priv;
@@ -315,6 +323,7 @@ const struct backend backend_rockchip = {
        .bo_import = drv_prime_bo_import,
        .bo_map = rockchip_bo_map,
        .bo_unmap = rockchip_bo_unmap,
+       .bo_invalidate = rockchip_bo_invalidate,
        .bo_flush = rockchip_bo_flush,
        .resolve_format = rockchip_resolve_format,
 };