blob: baceca1c164aff8bbb096f23881685ad0e22e1bf [file] [log] [blame]
Anders Delliene5bef532020-06-10 10:30:44 +01001/*
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
Yiwei Zhangb7a64442021-09-30 05:13:10 +00007#include "drv_helpers.h"
Anders Delliene5bef532020-06-10 10:30:44 +01008#include "drv_priv.h"
Anders Delliene5bef532020-06-10 10:30:44 +01009#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, \
Yiwei Zhangb8ad7b82021-10-01 17:55:14 +000020 .resolve_format_and_use_flags = drv_resolve_format_and_use_flags_helper, \
Anders Delliene5bef532020-06-10 10:30:44 +010021 };
22
23static const uint32_t scanout_render_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888,
24 DRM_FORMAT_ABGR8888, DRM_FORMAT_XBGR8888,
25 DRM_FORMAT_BGR888, DRM_FORMAT_BGR565 };
26
27static const uint32_t texture_only_formats[] = { DRM_FORMAT_NV12, DRM_FORMAT_NV21,
28 DRM_FORMAT_YVU420, DRM_FORMAT_YVU420_ANDROID };
29
30static int dumb_driver_init(struct driver *drv)
31{
32 drv_add_combinations(drv, scanout_render_formats, ARRAY_SIZE(scanout_render_formats),
33 &LINEAR_METADATA, BO_USE_RENDER_MASK | BO_USE_SCANOUT);
34
35 drv_add_combinations(drv, texture_only_formats, ARRAY_SIZE(texture_only_formats),
36 &LINEAR_METADATA, BO_USE_TEXTURE_MASK);
37
38 drv_modify_combination(drv, DRM_FORMAT_NV12, &LINEAR_METADATA,
39 BO_USE_HW_VIDEO_ENCODER | BO_USE_HW_VIDEO_DECODER |
40 BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE);
41 drv_modify_combination(drv, DRM_FORMAT_NV21, &LINEAR_METADATA, BO_USE_HW_VIDEO_ENCODER);
42
43 return drv_modify_linear_combinations(drv);
44}
45
Gurchetan Singh238001f2020-10-28 15:00:10 -070046INIT_DUMB_DRIVER(evdi)
Anders Delliene5bef532020-06-10 10:30:44 +010047INIT_DUMB_DRIVER(komeda)
48INIT_DUMB_DRIVER(marvell)
49INIT_DUMB_DRIVER(meson)
50INIT_DUMB_DRIVER(nouveau)
51INIT_DUMB_DRIVER(radeon)
52INIT_DUMB_DRIVER(synaptics)
Gurchetan Singh238001f2020-10-28 15:00:10 -070053INIT_DUMB_DRIVER(udl)
François-Denis Gonthiercea0b842020-05-22 18:02:24 -040054INIT_DUMB_DRIVER(vkms)