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