• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2020 The Chromium OS Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6 
7 #include "drv_priv.h"
8 #include "helpers.h"
9 #include "util.h"
10 
11 #define INIT_DUMB_DRIVER(driver)                                                                   \
12 	const struct backend backend_##driver = {                                                  \
13 		.name = #driver,                                                                   \
14 		.init = dumb_driver_init,                                                          \
15 		.bo_create = drv_dumb_bo_create,                                                   \
16 		.bo_destroy = drv_dumb_bo_destroy,                                                 \
17 		.bo_import = drv_prime_bo_import,                                                  \
18 		.bo_map = drv_dumb_bo_map,                                                         \
19 		.bo_unmap = drv_bo_munmap,                                                         \
20 	};
21 
22 static const uint32_t scanout_render_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888,
23 						   DRM_FORMAT_ABGR8888, DRM_FORMAT_XBGR8888,
24 						   DRM_FORMAT_BGR888,	DRM_FORMAT_BGR565 };
25 
26 static const uint32_t texture_only_formats[] = { DRM_FORMAT_NV12, DRM_FORMAT_NV21,
27 						 DRM_FORMAT_YVU420, DRM_FORMAT_YVU420_ANDROID };
28 
dumb_driver_init(struct driver * drv)29 static int dumb_driver_init(struct driver *drv)
30 {
31 	drv_add_combinations(drv, scanout_render_formats, ARRAY_SIZE(scanout_render_formats),
32 			     &LINEAR_METADATA, BO_USE_RENDER_MASK | BO_USE_SCANOUT);
33 
34 	drv_add_combinations(drv, texture_only_formats, ARRAY_SIZE(texture_only_formats),
35 			     &LINEAR_METADATA, BO_USE_TEXTURE_MASK);
36 
37 	drv_modify_combination(drv, DRM_FORMAT_NV12, &LINEAR_METADATA,
38 			       BO_USE_HW_VIDEO_ENCODER | BO_USE_HW_VIDEO_DECODER |
39 				   BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE);
40 	drv_modify_combination(drv, DRM_FORMAT_NV21, &LINEAR_METADATA, BO_USE_HW_VIDEO_ENCODER);
41 
42 	return drv_modify_linear_combinations(drv);
43 }
44 
45 INIT_DUMB_DRIVER(evdi)
46 INIT_DUMB_DRIVER(komeda)
47 INIT_DUMB_DRIVER(marvell)
48 INIT_DUMB_DRIVER(meson)
49 INIT_DUMB_DRIVER(nouveau)
50 INIT_DUMB_DRIVER(radeon)
51 INIT_DUMB_DRIVER(synaptics)
52 INIT_DUMB_DRIVER(udl)
53 INIT_DUMB_DRIVER(vkms)
54