From e5bef53ed26db51d5a9dffea939dea0deb37b950 Mon Sep 17 00:00:00 2001 From: Anders Dellien Date: Wed, 10 Jun 2020 10:30:44 +0100 Subject: [PATCH] minigbm: komeda: Refactor the 'dumb' drivers and add Komeda support Several drivers are very similar in that they only use the 'dumb' operations. This patch puts all such drivers into a single file and also adds a driver to support the Arm Komeda/D71 display processor. TEST=Boot Android and verify that we reach the home screen Change-Id: If39605deaef446adf8d6693d760a16c2c3f84649 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2429952 Reviewed-by: Gurchetan Singh Tested-by: Gurchetan Singh Commit-Queue: Gurchetan Singh --- Android.mk | 6 +----- drv.c | 46 ++++++++++++---------------------------------- meson.c => dumb_driver.c | 34 +++++++++++++++++++--------------- evdi.c | 29 ----------------------------- marvell.c | 34 ---------------------------------- nouveau.c | 29 ----------------------------- radeon.c | 29 ----------------------------- synaptics.c | 39 --------------------------------------- udl.c | 29 ----------------------------- 9 files changed, 32 insertions(+), 243 deletions(-) rename meson.c => dumb_driver.c (50%) delete mode 100644 evdi.c delete mode 100644 marvell.c delete mode 100644 nouveau.c delete mode 100644 radeon.c delete mode 100644 synaptics.c delete mode 100644 udl.c diff --git a/Android.mk b/Android.mk index 8b110b4..18c1bba 100644 --- a/Android.mk +++ b/Android.mk @@ -11,21 +11,17 @@ MINIGBM_SRC := \ amdgpu.c \ dri.c \ drv.c \ - evdi.c \ + dumb_driver.c \ exynos.c \ helpers_array.c \ helpers.c \ i915.c \ - marvell.c \ mediatek.c \ meson.c \ msm.c \ - nouveau.c \ radeon.c \ rockchip.c \ - synaptics.c \ tegra.c \ - udl.c \ vc4.c \ virtio_gpu.c diff --git a/drv.c b/drv.c index 8db5a5d..3f973c3 100644 --- a/drv.c +++ b/drv.c @@ -28,43 +28,38 @@ #ifdef DRV_AMDGPU extern const struct backend backend_amdgpu; #endif -extern const struct backend backend_evdi; #ifdef DRV_EXYNOS extern const struct backend backend_exynos; #endif #ifdef DRV_I915 extern const struct backend backend_i915; #endif -#ifdef DRV_MARVELL -extern const struct backend backend_marvell; -#endif #ifdef DRV_MEDIATEK extern const struct backend backend_mediatek; #endif -#ifdef DRV_MESON -extern const struct backend backend_meson; -#endif #ifdef DRV_MSM extern const struct backend backend_msm; #endif -extern const struct backend backend_nouveau; -#ifdef DRV_RADEON -extern const struct backend backend_radeon; -#endif #ifdef DRV_ROCKCHIP extern const struct backend backend_rockchip; #endif -#ifdef DRV_SYNAPTICS -extern const struct backend backend_synaptics; -#endif #ifdef DRV_TEGRA extern const struct backend backend_tegra; #endif -extern const struct backend backend_udl; #ifdef DRV_VC4 extern const struct backend backend_vc4; #endif + +// Dumb / generic drivers +extern const struct backend backend_evdi; +extern const struct backend backend_marvell; +extern const struct backend backend_meson; +extern const struct backend backend_nouveau; +extern const struct backend backend_komeda; +extern const struct backend backend_radeon; +extern const struct backend backend_synaptics; extern const struct backend backend_virtio_gpu; +extern const struct backend backend_udl; static const struct backend *drv_get_backend(int fd) { @@ -80,43 +75,26 @@ static const struct backend *drv_get_backend(int fd) #ifdef DRV_AMDGPU &backend_amdgpu, #endif - &backend_evdi, #ifdef DRV_EXYNOS &backend_exynos, #endif #ifdef DRV_I915 &backend_i915, #endif -#ifdef DRV_MARVELL - &backend_marvell, -#endif #ifdef DRV_MEDIATEK &backend_mediatek, #endif -#ifdef DRV_MESON - &backend_meson, -#endif #ifdef DRV_MSM &backend_msm, #endif - &backend_nouveau, -#ifdef DRV_RADEON - &backend_radeon, -#endif #ifdef DRV_ROCKCHIP &backend_rockchip, #endif -#ifdef DRV_SYNAPTICS - &backend_synaptics, -#endif -#ifdef DRV_TEGRA - &backend_tegra, -#endif - &backend_udl, #ifdef DRV_VC4 &backend_vc4, #endif - &backend_virtio_gpu, + &backend_marvell, &backend_meson, &backend_nouveau, &backend_komeda, + &backend_radeon, &backend_synaptics, &backend_virtio_gpu, }; for (i = 0; i < ARRAY_SIZE(backend_list); i++) { diff --git a/meson.c b/dumb_driver.c similarity index 50% rename from meson.c rename to dumb_driver.c index bfbf4e6..92f2e80 100644 --- a/meson.c +++ b/dumb_driver.c @@ -1,15 +1,24 @@ /* - * Copyright 2018 The Chromium OS Authors. All rights reserved. + * Copyright 2020 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. */ -#ifdef DRV_MESON - #include "drv_priv.h" #include "helpers.h" #include "util.h" +#define INIT_DUMB_DRIVER(driver) \ + const struct backend backend_##driver = { \ + .name = #driver, \ + .init = dumb_driver_init, \ + .bo_create = drv_dumb_bo_create, \ + .bo_destroy = drv_dumb_bo_destroy, \ + .bo_import = drv_prime_bo_import, \ + .bo_map = drv_dumb_bo_map, \ + .bo_unmap = drv_bo_munmap, \ + }; + static const uint32_t scanout_render_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888, DRM_FORMAT_ABGR8888, DRM_FORMAT_XBGR8888, DRM_FORMAT_BGR888, DRM_FORMAT_BGR565 }; @@ -17,7 +26,7 @@ static const uint32_t scanout_render_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORM static const uint32_t texture_only_formats[] = { DRM_FORMAT_NV12, DRM_FORMAT_NV21, DRM_FORMAT_YVU420, DRM_FORMAT_YVU420_ANDROID }; -static int meson_init(struct driver *drv) +static int dumb_driver_init(struct driver *drv) { drv_add_combinations(drv, scanout_render_formats, ARRAY_SIZE(scanout_render_formats), &LINEAR_METADATA, BO_USE_RENDER_MASK | BO_USE_SCANOUT); @@ -33,14 +42,9 @@ static int meson_init(struct driver *drv) return drv_modify_linear_combinations(drv); } -const struct backend backend_meson = { - .name = "meson", - .init = meson_init, - .bo_create = drv_dumb_bo_create, - .bo_destroy = drv_dumb_bo_destroy, - .bo_import = drv_prime_bo_import, - .bo_map = drv_dumb_bo_map, - .bo_unmap = drv_bo_munmap, -}; - -#endif +INIT_DUMB_DRIVER(komeda) +INIT_DUMB_DRIVER(marvell) +INIT_DUMB_DRIVER(meson) +INIT_DUMB_DRIVER(nouveau) +INIT_DUMB_DRIVER(radeon) +INIT_DUMB_DRIVER(synaptics) diff --git a/evdi.c b/evdi.c deleted file mode 100644 index bfa62a0..0000000 --- a/evdi.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2016 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. - */ - -#include "drv_priv.h" -#include "helpers.h" -#include "util.h" - -static const uint32_t render_target_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888 }; - -static int evdi_init(struct driver *drv) -{ - drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats), - &LINEAR_METADATA, BO_USE_RENDER_MASK); - - return drv_modify_linear_combinations(drv); -} - -const struct backend backend_evdi = { - .name = "evdi", - .init = evdi_init, - .bo_create = drv_dumb_bo_create, - .bo_destroy = drv_dumb_bo_destroy, - .bo_import = drv_prime_bo_import, - .bo_map = drv_dumb_bo_map, - .bo_unmap = drv_bo_munmap, -}; diff --git a/marvell.c b/marvell.c deleted file mode 100644 index c0b600b..0000000 --- a/marvell.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2015 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. - */ - -#ifdef DRV_MARVELL - -#include "drv_priv.h" -#include "helpers.h" -#include "util.h" - -static const uint32_t render_target_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888 }; - -static int marvell_init(struct driver *drv) -{ - drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats), - &LINEAR_METADATA, BO_USE_RENDER_MASK); - - return drv_add_linear_combinations(drv, render_target_formats, - ARRAY_SIZE(render_target_formats)); -} - -const struct backend backend_marvell = { - .name = "marvell", - .init = marvell_init, - .bo_create = drv_dumb_bo_create, - .bo_destroy = drv_dumb_bo_destroy, - .bo_import = drv_prime_bo_import, - .bo_map = drv_dumb_bo_map, - .bo_unmap = drv_bo_munmap, -}; - -#endif diff --git a/nouveau.c b/nouveau.c deleted file mode 100644 index d0f25d4..0000000 --- a/nouveau.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2016 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. - */ - -#include "drv_priv.h" -#include "helpers.h" -#include "util.h" - -static const uint32_t render_target_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888 }; - -static int nouveau_init(struct driver *drv) -{ - drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats), - &LINEAR_METADATA, BO_USE_RENDER_MASK); - - return drv_modify_linear_combinations(drv); -} - -const struct backend backend_nouveau = { - .name = "nouveau", - .init = nouveau_init, - .bo_create = drv_dumb_bo_create, - .bo_destroy = drv_dumb_bo_destroy, - .bo_import = drv_prime_bo_import, - .bo_map = drv_dumb_bo_map, - .bo_unmap = drv_bo_munmap, -}; diff --git a/radeon.c b/radeon.c deleted file mode 100644 index 68445c1..0000000 --- a/radeon.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2017 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. - */ - -#include "drv_priv.h" -#include "helpers.h" -#include "util.h" - -static const uint32_t render_target_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888 }; - -static int radeon_init(struct driver *drv) -{ - drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats), - &LINEAR_METADATA, BO_USE_RENDER_MASK); - - return drv_modify_linear_combinations(drv); -} - -const struct backend backend_radeon = { - .name = "radeon", - .init = radeon_init, - .bo_create = drv_dumb_bo_create, - .bo_destroy = drv_dumb_bo_destroy, - .bo_import = drv_prime_bo_import, - .bo_map = drv_dumb_bo_map, - .bo_unmap = drv_bo_munmap, -}; diff --git a/synaptics.c b/synaptics.c deleted file mode 100644 index 62f3a6b..0000000 --- a/synaptics.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2020 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. - */ -#ifdef DRV_SYNAPTICS - -#include "drv_priv.h" -#include "helpers.h" -#include "util.h" - -static const uint32_t render_target_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_ABGR8888, - DRM_FORMAT_XRGB8888 }; - -static const uint32_t texture_source_formats[] = { DRM_FORMAT_R8, DRM_FORMAT_NV12, - DRM_FORMAT_YVU420, DRM_FORMAT_YVU420_ANDROID }; - -static int synaptics_init(struct driver *drv) -{ - drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats), - &LINEAR_METADATA, BO_USE_RENDER_MASK | BO_USE_SCANOUT); - - drv_add_combinations(drv, texture_source_formats, ARRAY_SIZE(texture_source_formats), - &LINEAR_METADATA, BO_USE_TEXTURE_MASK | BO_USE_HW_VIDEO_ENCODER); - - return drv_modify_linear_combinations(drv); -} - -const struct backend backend_synaptics = { - .name = "synaptics", - .init = synaptics_init, - .bo_create = drv_dumb_bo_create, - .bo_destroy = drv_dumb_bo_destroy, - .bo_import = drv_prime_bo_import, - .bo_map = drv_dumb_bo_map, - .bo_unmap = drv_bo_munmap, -}; - -#endif diff --git a/udl.c b/udl.c deleted file mode 100644 index 12dc967..0000000 --- a/udl.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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. - */ - -#include "drv_priv.h" -#include "helpers.h" -#include "util.h" - -static const uint32_t render_target_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888 }; - -static int udl_init(struct driver *drv) -{ - drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats), - &LINEAR_METADATA, BO_USE_RENDER_MASK); - - return drv_modify_linear_combinations(drv); -} - -const struct backend backend_udl = { - .name = "udl", - .init = udl_init, - .bo_create = drv_dumb_bo_create, - .bo_destroy = drv_dumb_bo_destroy, - .bo_import = drv_prime_bo_import, - .bo_map = drv_dumb_bo_map, - .bo_unmap = drv_bo_munmap, -}; -- 2.11.0