X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=rockchip.c;h=ccc0335d697dbb194dce5a02da923b0ae87d0dea;hb=293d9e3edfb46d0a988f99a835be16349bea0c3c;hp=7cecf3b1328269ef42960a678d05f74afd6684ba;hpb=bc9a87d54c5296d467ead2b4ea35e317f00ee401;p=android-x86%2Fexternal-minigbm.git diff --git a/rockchip.c b/rockchip.c index 7cecf3b..ccc0335 100644 --- a/rockchip.c +++ b/rockchip.c @@ -24,8 +24,8 @@ struct rockchip_private_map_data { }; static const uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888, - DRM_FORMAT_RGB565, DRM_FORMAT_XBGR8888, - DRM_FORMAT_XRGB8888 }; + DRM_FORMAT_BGR888, DRM_FORMAT_RGB565, + DRM_FORMAT_XBGR8888, DRM_FORMAT_XRGB8888 }; static const uint32_t texture_source_formats[] = { DRM_FORMAT_R8, DRM_FORMAT_NV12, DRM_FORMAT_YVU420, DRM_FORMAT_YVU420_ANDROID }; @@ -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,8 @@ 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", + (unsigned long long)gem_create.size); return ret; } @@ -247,7 +247,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 +260,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 +280,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 +324,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, };