8261b0d21eff52b211527d1ebae929eeff1b020a
[openwrt/staging/thess.git] /
1 From bf3bea12753fff59c1e7f4b75b2f10923d8f992f Mon Sep 17 00:00:00 2001
2 From: Eric Anholt <eric@anholt.net>
3 Date: Mon, 18 Mar 2019 16:38:32 -0700
4 Subject: [PATCH 589/782] drm/vc4: Expose the format modifiers for firmware
5 kms.
6
7 This should technically not expose VC4_T_TILED on pi4. However, if we
8 don't expose anything, then userspace will assume that display can
9 handle whatever modifiers 3d can do (UIF on 2711). By exposing a
10 list, that will get intersected with what 3D can do so that we get T
11 tiling for display on 2710 and linear on 2711.
12
13 Signed-off-by: Eric Anholt <eric@anholt.net>
14 ---
15 drivers/gpu/drm/vc4/vc4_firmware_kms.c | 33 +++++++++++++++++++++++++-
16 1 file changed, 32 insertions(+), 1 deletion(-)
17
18 --- a/drivers/gpu/drm/vc4/vc4_firmware_kms.c
19 +++ b/drivers/gpu/drm/vc4/vc4_firmware_kms.c
20 @@ -281,6 +281,27 @@ static void vc4_plane_destroy(struct drm
21 drm_plane_cleanup(plane);
22 }
23
24 +static bool vc4_fkms_format_mod_supported(struct drm_plane *plane,
25 + uint32_t format,
26 + uint64_t modifier)
27 +{
28 + /* Support T_TILING for RGB formats only. */
29 + switch (format) {
30 + case DRM_FORMAT_XRGB8888:
31 + case DRM_FORMAT_ARGB8888:
32 + switch (modifier) {
33 + case DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED:
34 + case DRM_FORMAT_MOD_LINEAR:
35 + case DRM_FORMAT_MOD_BROADCOM_UIF:
36 + return true;
37 + default:
38 + return false;
39 + }
40 + default:
41 + return false;
42 + }
43 +}
44 +
45 static const struct drm_plane_funcs vc4_plane_funcs = {
46 .update_plane = drm_atomic_helper_update_plane,
47 .disable_plane = drm_atomic_helper_disable_plane,
48 @@ -289,6 +310,7 @@ static const struct drm_plane_funcs vc4_
49 .reset = drm_atomic_helper_plane_reset,
50 .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
51 .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
52 + .format_mod_supported = vc4_fkms_format_mod_supported,
53 };
54
55 static const struct drm_plane_helper_funcs vc4_primary_plane_helper_funcs = {
56 @@ -316,6 +338,14 @@ static struct drm_plane *vc4_fkms_plane_
57 u32 argb8888 = DRM_FORMAT_ARGB8888;
58 int ret = 0;
59 bool primary = (type == DRM_PLANE_TYPE_PRIMARY);
60 + static const uint64_t modifiers[] = {
61 + DRM_FORMAT_MOD_LINEAR,
62 + /* VC4_T_TILED should come after linear, because we
63 + * would prefer to scan out linear (less bus traffic).
64 + */
65 + DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED,
66 + DRM_FORMAT_MOD_INVALID,
67 + };
68
69 vc4_plane = devm_kzalloc(dev->dev, sizeof(*vc4_plane),
70 GFP_KERNEL);
71 @@ -327,7 +357,8 @@ static struct drm_plane *vc4_fkms_plane_
72 plane = &vc4_plane->base;
73 ret = drm_universal_plane_init(dev, plane, 0xff,
74 &vc4_plane_funcs,
75 - primary ? &xrgb8888 : &argb8888, 1, NULL,
76 + primary ? &xrgb8888 : &argb8888, 1,
77 + modifiers,
78 type, primary ? "primary" : "cursor");
79
80 if (type == DRM_PLANE_TYPE_PRIMARY) {