OSDN Git Service

minigbm: add (*bo_flush) implementations
[android-x86/external-minigbm.git] / i915.c
diff --git a/i915.c b/i915.c
index fe162f1..a16050f 100644 (file)
--- a/i915.c
+++ b/i915.c
@@ -57,8 +57,8 @@ static int i915_add_kms_item(struct driver *drv, const struct kms_item *item)
         * Older hardware can't scanout Y-tiled formats. Newer devices can, and
         * report this functionality via format modifiers.
         */
-       for (i = 0; i < drv->backend->combos.size; i++) {
-               combo = &drv->backend->combos.data[i];
+       for (i = 0; i < drv->combos.size; i++) {
+               combo = &drv->combos.data[i];
                if (combo->format != item->format)
                        continue;
 
@@ -218,12 +218,18 @@ static int i915_align_dimensions(struct bo *bo, uint32_t tiling, uint32_t *strid
        case DRM_FORMAT_YVU420_ANDROID:
        case DRM_FORMAT_YVU420:
                horizontal_alignment *= 2;
-               /* Fall through */
+       /* Fall through */
        case DRM_FORMAT_NV12:
                vertical_alignment *= 2;
                break;
        }
 
+       /*
+        * For multi-planar formats we must be aligned to 16
+        */
+       if (bo->num_planes > 1)
+               vertical_alignment = MAX(vertical_alignment, 16);
+
        *aligned_height = ALIGN(bo->height, vertical_alignment);
        if (i915->gen > 3) {
                *stride = ALIGN(*stride, horizontal_alignment);
@@ -470,13 +476,13 @@ static void *i915_bo_map(struct bo *bo, struct map_info *data, size_t plane, int
        return addr;
 }
 
-static int i915_bo_unmap(struct bo *bo, struct map_info *data)
+static int i915_bo_flush(struct bo *bo, struct map_info *data)
 {
        struct i915_device *i915 = bo->drv->priv;
        if (!i915->has_llc && bo->tiling == I915_TILING_NONE)
                i915_clflush(data->addr, data->length);
 
-       return munmap(data->addr, data->length);
+       return 0;
 }
 
 static uint32_t i915_resolve_format(uint32_t format, uint64_t usage)
@@ -506,7 +512,8 @@ struct backend backend_i915 = {
        .bo_destroy = drv_gem_bo_destroy,
        .bo_import = i915_bo_import,
        .bo_map = i915_bo_map,
-       .bo_unmap = i915_bo_unmap,
+       .bo_unmap = drv_bo_munmap,
+       .bo_flush = i915_bo_flush,
        .resolve_format = i915_resolve_format,
 };