bcm27xx: add support for linux v5.15
[openwrt/staging/chunkeey.git] / target / linux / bcm27xx / patches-5.15 / 950-0779-drm-object-Add-default-zpos-value-at-reset.patch
1 From 69b992bf70df1892cfc8ccff07a79e8ea91e2902 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Mon, 21 Feb 2022 10:59:03 +0100
4 Subject: [PATCH] drm/object: Add default zpos value at reset
5
6 Upstream commit 1a7998dab5dd3d11bada7e3921781922082e7fe6
7
8 The drm_plane_create_zpos_property() function asks for an initial value,
9 and will set the associated plane state variable with that value if a
10 state is present.
11
12 However, that function is usually called at a time where there's no
13 state yet. Since the drm_plane_state reset helper doesn't take care of
14 reading that value when it's called, it means that in most cases the
15 initial value will be 0, or the drivers will have to work around it.
16
17 Let's add some code in __drm_atomic_helper_plane_state_reset() to get
18 the initial zpos value if the property has been attached in order to fix
19 this.
20
21 Reviewed-by: Harry Wentland <harry.wentland@amd.com>
22 Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
23 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
24 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
25 Link: https://patchwork.freedesktop.org/patch/msgid/20220221095918.18763-8-maxime@cerno.tech
26 ---
27 drivers/gpu/drm/drm_atomic_state_helper.c | 11 +++++++++++
28 1 file changed, 11 insertions(+)
29
30 --- a/drivers/gpu/drm/drm_atomic_state_helper.c
31 +++ b/drivers/gpu/drm/drm_atomic_state_helper.c
32 @@ -243,11 +243,22 @@ EXPORT_SYMBOL(drm_atomic_helper_crtc_des
33 void __drm_atomic_helper_plane_state_reset(struct drm_plane_state *plane_state,
34 struct drm_plane *plane)
35 {
36 + u64 val;
37 +
38 plane_state->plane = plane;
39 plane_state->rotation = DRM_MODE_ROTATE_0;
40
41 plane_state->alpha = DRM_BLEND_ALPHA_OPAQUE;
42 plane_state->pixel_blend_mode = DRM_MODE_BLEND_PREMULTI;
43 +
44 + if (plane->zpos_property) {
45 + if (!drm_object_property_get_default_value(&plane->base,
46 + plane->zpos_property,
47 + &val)) {
48 + plane_state->zpos = val;
49 + plane_state->normalized_zpos = val;
50 + }
51 + }
52 }
53 EXPORT_SYMBOL(__drm_atomic_helper_plane_state_reset);
54