OSDN Git Service

minigbm: Remove (c) from copyright notice.
[android-x86/external-minigbm.git] / tegra.c
diff --git a/tegra.c b/tegra.c
index 28f98c6..b3e362a 100644 (file)
--- a/tegra.c
+++ b/tegra.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
+ * Copyright 2014 The Chromium OS Authors. All rights reserved.
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
@@ -33,6 +33,17 @@ enum nv_mem_kind
        NV_MEM_KIND_GENERIC_16Bx2 = 0xfe,
 };
 
+static struct supported_combination combos[4] = {
+       {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE,
+               BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN},
+       {DRM_FORMAT_ARGB8888, DRM_FORMAT_MOD_NONE,
+               BO_USE_RENDERING | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
+       {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE,
+               BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN},
+       {DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE,
+               BO_USE_RENDERING | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},
+};
+
 static int compute_block_height_log2(int height)
 {
        int block_height_log2 = NV_DEFAULT_BLOCK_HEIGHT_LOG2;
@@ -83,10 +94,16 @@ static void compute_layout_blocklinear(int width, int height, int format,
 static void compute_layout_linear(int width, int height, int format,
                                  uint32_t *stride, uint32_t *size)
 {
-       *stride = drv_stride_from_format(format, width, 0);
+       *stride = ALIGN(drv_stride_from_format(format, width, 0), 64);
        *size = *stride * height;
 }
 
+static int tegra_init(struct driver *drv)
+{
+       drv_insert_combinations(drv, combos, ARRAY_SIZE(combos));
+       return drv_add_kms_flags(drv);
+}
+
 static int tegra_bo_create(struct bo *bo, uint32_t width, uint32_t height,
                           uint32_t format, uint32_t flags)
 {
@@ -95,7 +112,7 @@ static int tegra_bo_create(struct bo *bo, uint32_t width, uint32_t height,
        struct drm_tegra_gem_create gem_create;
        int ret;
 
-       if (flags & DRV_BO_USE_RENDERING)
+       if (flags & BO_USE_RENDERING)
                compute_layout_blocklinear(width, height, format, &kind,
                                           &block_height_log2, &stride, &size);
        else
@@ -135,7 +152,7 @@ static int tegra_bo_create(struct bo *bo, uint32_t width, uint32_t height,
                /* Encode blocklinear parameters for EGLImage creation. */
                bo->tiling = (kind & 0xff) |
                             ((block_height_log2 & 0xf) << 8);
-               bo->format_modifiers[0] = drv_fourcc_mod_code(NV, bo->tiling);
+               bo->format_modifiers[0] = fourcc_mod_code(NV, bo->tiling);
        }
 
        return 0;
@@ -162,24 +179,13 @@ static void *tegra_bo_map(struct bo *bo, struct map_info *data, size_t plane)
                    bo->drv->fd, gem_map.offset);
 }
 
-const struct backend backend_tegra =
+struct backend backend_tegra =
 {
        .name = "tegra",
+       .init = tegra_init,
        .bo_create = tegra_bo_create,
        .bo_destroy = drv_gem_bo_destroy,
        .bo_map = tegra_bo_map,
-       .format_list = {
-               /* Linear support */
-               {DRV_FORMAT_XRGB8888, DRV_BO_USE_SCANOUT | DRV_BO_USE_CURSOR | DRV_BO_USE_LINEAR
-                                     | DRV_BO_USE_SW_READ_OFTEN | DRV_BO_USE_SW_WRITE_OFTEN},
-               {DRV_FORMAT_ARGB8888, DRV_BO_USE_SCANOUT | DRV_BO_USE_CURSOR | DRV_BO_USE_LINEAR
-                                     | DRV_BO_USE_SW_READ_OFTEN | DRV_BO_USE_SW_WRITE_OFTEN},
-               /* Blocklinear support */
-               {DRV_FORMAT_XRGB8888, DRV_BO_USE_SCANOUT | DRV_BO_USE_RENDERING |
-                                     DRV_BO_USE_SW_READ_RARELY | DRV_BO_USE_SW_WRITE_RARELY},
-               {DRV_FORMAT_ARGB8888, DRV_BO_USE_SCANOUT | DRV_BO_USE_RENDERING |
-                                     DRV_BO_USE_SW_READ_RARELY | DRV_BO_USE_SW_WRITE_RARELY},
-       }
 };
 
 #endif