Skip to contentSkip to conversation

drm: Fill in default values for plane properties

PATCH Superseded Maxime Ripard 9 participants 43 messages Feb 7, 2022 – Feb 17, 2022

Subsystems (20)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover drm: Fill in default values for plane properties

Hi,

We have a bunch of functions that create planes properties that will take a default value, but it isn't actually enforced in the plane state.

This leads to drivers having multiple strategies to work around that issue, most of them being a variation of forcing a value at plane state reset time. Others work fine by luck, or have entirely ignored the issue.

This series aims at making sure the default value set by the call to the function isn't ignored, and then making sure all drivers behave consistently.

Let me know what you think,
Maxime

Dave Stevenson (3):
drm/object: Add drm_object_property_get_default_value() function drm/object: Add default zpos value at reset drm/object: Add default color encoding and range value at reset

Maxime Ripard (20):
drm/komeda: plane: switch to plane reset helper drm/tegra: plane: switch to plane reset helper drm/tegra: hub: Fix zpos initial value mismatch drm/msm/mdp5: Fix zpos initial value mismatch drm/amd/display: Fix color encoding mismatch drm/tegra: plane: Remove redundant zpos initialisation drm/komeda: plane: Remove redundant zpos initialisation drm/exynos: plane: Remove redundant zpos initialisation drm/imx: ipuv3-plane: Remove redundant zpos initialisation drm/msm/mdp5: Remove redundant zpos initialisation drm/nouveau/kms: Remove redundant zpos initialisation drm/omap: plane: Fix zpos initial value mismatch drm/omap: plane: Remove redundant zpos initialisation drm/rcar: plane: Remove redundant zpos initialisation drm/sti: plane: Remove redundant zpos initialisation drm/sun4i: layer: Remove redundant zpos initialisation drm/komeda: plane: Remove redundant color encoding and range
initialisation
drm/armada: overlay: Remove redundant color encoding and range
initialisation
drm/imx: ipuv3-plane: Remove redundant color encoding and range
initialisation
drm/omap: plane: Remove redundant color encoding and range
initialisation

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  2 +-
 .../gpu/drm/arm/display/komeda/komeda_plane.c | 13 +----
 drivers/gpu/drm/armada/armada_overlay.c       |  2 -
 drivers/gpu/drm/drm_atomic_state_helper.c     | 25 +++++++++
 drivers/gpu/drm/drm_mode_object.c             | 53 +++++++++++++++----
 drivers/gpu/drm/exynos/exynos_drm_plane.c     |  5 +-
 drivers/gpu/drm/imx/ipuv3-plane.c             |  8 +--
 drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c    | 16 +++---
 drivers/gpu/drm/nouveau/dispnv50/wndw.c       |  2 -
 drivers/gpu/drm/omapdrm/omap_plane.c          | 22 ++++----
 drivers/gpu/drm/rcar-du/rcar_du_plane.c       |  1 -
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c         |  1 -
 drivers/gpu/drm/sti/sti_cursor.c              |  2 +-
 drivers/gpu/drm/sti/sti_gdp.c                 |  2 +-
 drivers/gpu/drm/sti/sti_hqvdp.c               |  2 +-
 drivers/gpu/drm/sti/sti_plane.c               |  6 ---
 drivers/gpu/drm/sti/sti_plane.h               |  1 -
 drivers/gpu/drm/sun4i/sun4i_layer.c           | 16 +++---
 drivers/gpu/drm/tegra/hub.c                   |  2 +-
 drivers/gpu/drm/tegra/plane.c                 |  6 +--
 include/drm/drm_mode_object.h                 |  7 +++
 21 files changed, 111 insertions(+), 83 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/23 drm/komeda: plane: switch to plane reset helper

komeda_plane_reset() does the state initialisation by copying a lot of the code found in the __drm_atomic_helper_plane_reset(). Let's switch to that helper and reduce the boilerplate.

Cc Brian Starkey <[email protected]>
Cc "James (Qian) Wang" <[email protected]>
Cc Liviu Dudau <[email protected]>
Cc Mihail Atanassov <[email protected]>
---
 drivers/gpu/drm/arm/display/komeda/komeda_plane.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpu/drm/arm/display/komeda/komeda_plane.c +1 -5
index d63d83800a8a..1778f6e1ea56 100644
@@ -145,14 +145,10 @@ static void komeda_plane_reset(struct drm_plane *plane)
 
 	state = kzalloc(sizeof(*state), GFP_KERNEL);
 	if (state) {
-		state->base.rotation = DRM_MODE_ROTATE_0;
-		state->base.pixel_blend_mode = DRM_MODE_BLEND_PREMULTI;
-		state->base.alpha = DRM_BLEND_ALPHA_OPAQUE;
+		__drm_atomic_helper_plane_reset(plane, &state->base);
 		state->base.zpos = kplane->layer->base.id;
 		state->base.color_encoding = DRM_COLOR_YCBCR_BT601;
 		state->base.color_range = DRM_COLOR_YCBCR_LIMITED_RANGE;
-		plane->state = &state->base;
-		plane->state->plane = plane;
 	}
 }
 
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/23 drm/tegra: plane: switch to plane reset helper

In reply to Maxime Ripard

tegra_plane_reset() does the state initialisation by copying a lot of the code found in the __drm_atomic_helper_plane_reset(). Let's switch to that helper and reduce the boilerplate.

---
 drivers/gpu/drm/tegra/plane.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/tegra/plane.c +1 -2
index 321cb1f13da6..ec0822c86926 100644
@@ -37,8 +37,7 @@ static void tegra_plane_reset(struct drm_plane *plane)
 
 	state = kzalloc(sizeof(*state), GFP_KERNEL);
 	if (state) {
-		plane->state = &state->base;
-		plane->state->plane = plane;
+		__drm_atomic_helper_plane_reset(plane, &state->base);
 		plane->state->zpos = p->index;
 		plane->state->normalized_zpos = p->index;
 
Signature · 1 line
2.34.1
#3 lore raw

PATCH 3/23 drm/tegra: hub: Fix zpos initial value mismatch

In reply to Maxime Ripard

While the tegra_shared_plane_create() function calls drm_plane_create_zpos_property() with an initial value of 0, tegra_plane_reset() will force it to the plane index.

Fix the discrepancy by setting the initial zpos value to the plane index in the function call.

---
 drivers/gpu/drm/tegra/hub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tegra/hub.c +1 -1
index b910155f80c4..7f68a142d922 100644
@@ -788,7 +788,7 @@ struct drm_plane *tegra_shared_plane_create(struct drm_device *drm,
 	}
 
 	drm_plane_helper_add(p, &tegra_shared_plane_helper_funcs);
-	drm_plane_create_zpos_property(p, 0, 0, 255);
+	drm_plane_create_zpos_property(p, index, 0, 255);
 
 	return p;
 }
Signature · 1 line
2.34.1
#4 lore raw

PATCH 4/23 drm/msm/mdp5: Fix zpos initial value mismatch

In reply to Maxime Ripard

While the mdp5_plane_install_properties() function calls drm_plane_create_zpos_property() with an initial value of 1, mdp5_plane_reset() will force it to another value depending on the plane type.

Fix the discrepancy by setting the initial zpos value to the same value in the drm_plane_create_zpos_property() call.

---
 drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c +8 -1
index c6b69afcbac8..d60982f4bd11 100644
@@ -48,6 +48,8 @@ static void mdp5_plane_destroy(struct drm_plane *plane)
 static void mdp5_plane_install_properties(struct drm_plane *plane,
 		struct drm_mode_object *obj)
 {
+	unsigned int zpos;
+
 	drm_plane_create_rotation_property(plane,
 					   DRM_MODE_ROTATE_0,
 					   DRM_MODE_ROTATE_0 |
@@ -59,7 +61,12 @@ static void mdp5_plane_install_properties(struct drm_plane *plane,
 			BIT(DRM_MODE_BLEND_PIXEL_NONE) |
 			BIT(DRM_MODE_BLEND_PREMULTI) |
 			BIT(DRM_MODE_BLEND_COVERAGE));
-	drm_plane_create_zpos_property(plane, 1, 1, 255);
+
+	if (plane->type == DRM_PLANE_TYPE_PRIMARY)
+		zpos = STAGE_BASE;
+	else
+		zpos = STAGE0 + drm_plane_index(plane);
+	drm_plane_create_zpos_property(plane, zpos, 1, 255);
 }
 
 static void
Signature · 1 line
2.34.1
#7 lore raw

PATCH 5/23 drm/amd/display: Fix color encoding mismatch

In reply to Maxime Ripard

The amdgpu KMS driver calls drm_plane_create_color_properties() with a default encoding set to BT709.

However, the core will ignore it and the driver doesn't force it in its plane state reset hook, so the initial value will be 0, which represents BT601.

Fix the mismatch by using an initial value of BT601 in drm_plane_create_color_properties().

Cc Alex Deucher <[email protected]>
Cc "Christian König" <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Leo Li <[email protected]>
Cc "Pan, Xinhui" <[email protected]>
Cc Rodrigo Siqueira <[email protected]>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
index feccf2b555d2..86b27a355e90 100644
@@ -7914,7 +7914,7 @@ static int amdgpu_dm_plane_init(struct amdgpu_display_manager *dm,
 			BIT(DRM_COLOR_YCBCR_BT2020),
 			BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) |
 			BIT(DRM_COLOR_YCBCR_FULL_RANGE),
-			DRM_COLOR_YCBCR_BT709, DRM_COLOR_YCBCR_LIMITED_RANGE);
+			DRM_COLOR_YCBCR_BT601, DRM_COLOR_YCBCR_LIMITED_RANGE);
 	}
 
 	supported_rotations =
Signature · 1 line
2.34.1
#13 lore raw

PATCH 6/23 drm/object: Add drm_object_property_get_default_value() function

In reply to Maxime Ripard

From: Dave Stevenson <[email protected]>

Some functions to create properties (drm_plane_create_zpos_property or drm_plane_create_color_properties for example) will ask for a range of acceptable value and an initial one.

This initial value is then stored in the values array for that property.

Let's provide an helper to access this property.

---
 drivers/gpu/drm/drm_mode_object.c | 53 +++++++++++++++++++++++++------
 include/drm/drm_mode_object.h     |  7 ++++
 2 files changed, 50 insertions(+), 10 deletions(-)
drivers/gpu/drm/drm_mode_object.c +43 -10
index 86d9e907c0b2..ba1608effc0f 100644
@@ -297,11 +297,26 @@ int drm_object_property_set_value(struct drm_mode_object *obj,
 }
 EXPORT_SYMBOL(drm_object_property_set_value);
 
+static int __drm_object_property_get_prop_value(struct drm_mode_object *obj,
+						struct drm_property *property,
+						uint64_t *val)
+{
+	int i;
+
+	for (i = 0; i < obj->properties->count; i++) {
+		if (obj->properties->properties[i] == property) {
+			*val = obj->properties->values[i];
+			return 0;
+		}
+	}
+
+	return -EINVAL;
+}
+
 static int __drm_object_property_get_value(struct drm_mode_object *obj,
 					   struct drm_property *property,
 					   uint64_t *val)
 {
-	int i;
 
 	/* read-only properties bypass atomic mechanism and still store
 	 * their value in obj->properties->values[].. mostly to avoid
@@ -311,15 +326,7 @@ static int __drm_object_property_get_value(struct drm_mode_object *obj,
 			!(property->flags & DRM_MODE_PROP_IMMUTABLE))
 		return drm_atomic_get_property(obj, property, val);
 
-	for (i = 0; i < obj->properties->count; i++) {
-		if (obj->properties->properties[i] == property) {
-			*val = obj->properties->values[i];
-			return 0;
-		}
-
-	}
-
-	return -EINVAL;
+	return __drm_object_property_get_prop_value(obj, property, val);
 }
 
 /**
@@ -348,6 +355,32 @@ int drm_object_property_get_value(struct drm_mode_object *obj,
 }
 EXPORT_SYMBOL(drm_object_property_get_value);
 
+/**
+ * drm_object_property_get_default_value - retrieve the default value of a
+ * property when in atomic mode.
+ * @obj: drm mode object to get property value from
+ * @property: property to retrieve
+ * @val: storage for the property value
+ *
+ * This function retrieves the default state of the given property as passed in
+ * to drm_object_attach_property
+ *
+ * Only atomic drivers should call this function directly, as for non-atomic
+ * drivers it will return the current value.
+ *
+ * Returns:
+ * Zero on success, error code on failure.
+ */
+int drm_object_property_get_default_value(struct drm_mode_object *obj,
+					  struct drm_property *property,
+					  uint64_t *val)
+{
+	WARN_ON(!drm_drv_uses_atomic_modeset(property->dev));
+
+	return __drm_object_property_get_prop_value(obj, property, val);
+}
+EXPORT_SYMBOL(drm_object_property_get_default_value);
+
 /* helper for getconnector and getproperties ioctls */
 int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic,
 				   uint32_t __user *prop_ptr,
include/drm/drm_mode_object.h +7 -0
index c34a3e8030e1..912f1e415685 100644
@@ -98,6 +98,10 @@ struct drm_object_properties {
 	 * Hence atomic drivers should not use drm_object_property_set_value()
 	 * and drm_object_property_get_value() on mutable objects, i.e. those
 	 * without the DRM_MODE_PROP_IMMUTABLE flag set.
+	 *
+	 * For atomic drivers the default value of properties is stored in this
+	 * array, so drm_object_property_get_default_value can be used to
+	 * retrieve it.
 	 */
 	uint64_t values[DRM_OBJECT_MAX_PROPERTY];
 };
@@ -126,6 +130,9 @@ int drm_object_property_set_value(struct drm_mode_object *obj,
 int drm_object_property_get_value(struct drm_mode_object *obj,
 				  struct drm_property *property,
 				  uint64_t *value);
+int drm_object_property_get_default_value(struct drm_mode_object *obj,
+					  struct drm_property *property,
+					  uint64_t *val);
 
 void drm_object_attach_property(struct drm_mode_object *obj,
 				struct drm_property *property,
Signature · 1 line
2.34.1
#15 lore raw

PATCH 7/23 drm/object: Add default zpos value at reset

In reply to Maxime Ripard

From: Dave Stevenson <[email protected]>

The drm_plane_create_zpos_property() function asks for an initial value, and will set the associated plane state variable with that value if a state is present.

However, that function is usually called at a time where there's no state yet. Since the drm_plane_state reset helper doesn't take care of reading that value when it's called, it means that in most cases the initial value will be 0, or the drivers will have to work around it.

Let's add some code in __drm_atomic_helper_plane_state_reset() to get the initial zpos value if the property has been attached in order to fix this.

---
 drivers/gpu/drm/drm_atomic_state_helper.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpu/drm/drm_atomic_state_helper.c +11 -0
index ddcf5c2c8e6a..1412cee404ca 100644
@@ -243,11 +243,22 @@ EXPORT_SYMBOL(drm_atomic_helper_crtc_destroy_state);
 void __drm_atomic_helper_plane_state_reset(struct drm_plane_state *plane_state,
 					   struct drm_plane *plane)
 {
+	u64 val;
+
 	plane_state->plane = plane;
 	plane_state->rotation = DRM_MODE_ROTATE_0;
 
 	plane_state->alpha = DRM_BLEND_ALPHA_OPAQUE;
 	plane_state->pixel_blend_mode = DRM_MODE_BLEND_PREMULTI;
+
+	if (plane->zpos_property) {
+		if (!drm_object_property_get_default_value(&plane->base,
+							   plane->zpos_property,
+							   &val)) {
+			plane_state->zpos = val;
+			plane_state->normalized_zpos = val;
+		}
+	}
 }
 EXPORT_SYMBOL(__drm_atomic_helper_plane_state_reset);
 
Signature · 1 line
2.34.1
#18 lore raw

PATCH 8/23 drm/tegra: plane: Remove redundant zpos initialisation

In reply to Maxime Ripard

The tegra KMS driver will call drm_plane_create_zpos_property() with an init value of the plane index.

Since the initial value wasn't carried over in the state, the driver had to set it again in tegra_plane_reset(). However, the helpers have been adjusted to set it properly at reset, so this is not needed anymore.

---
 drivers/gpu/drm/tegra/plane.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/gpu/drm/tegra/plane.c +0 -3
index ec0822c86926..a00913d064d3 100644
@@ -25,7 +25,6 @@ static void tegra_plane_destroy(struct drm_plane *plane)
 
 static void tegra_plane_reset(struct drm_plane *plane)
 {
-	struct tegra_plane *p = to_tegra_plane(plane);
 	struct tegra_plane_state *state;
 	unsigned int i;
 
@@ -38,8 +37,6 @@ static void tegra_plane_reset(struct drm_plane *plane)
 	state = kzalloc(sizeof(*state), GFP_KERNEL);
 	if (state) {
 		__drm_atomic_helper_plane_reset(plane, &state->base);
-		plane->state->zpos = p->index;
-		plane->state->normalized_zpos = p->index;
 
 		for (i = 0; i < 3; i++)
 			state->iova[i] = DMA_MAPPING_ERROR;
Signature · 1 line
2.34.1
#19 lore raw

PATCH 9/23 drm/komeda: plane: Remove redundant zpos initialisation

In reply to Maxime Ripard

The komeda KMS driver will call drm_plane_create_zpos_property() with an init value of the plane index.

Since the initial value wasn't carried over in the state, the driver had to set it again in komeda_plane_reset(). However, the helpers have been adjusted to set it properly at reset, so this is not needed anymore.

Cc Brian Starkey <[email protected]>
Cc "James (Qian) Wang" <[email protected]>
Cc Liviu Dudau <[email protected]>
Cc Mihail Atanassov <[email protected]>
---
 drivers/gpu/drm/arm/display/komeda/komeda_plane.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/arm/display/komeda/komeda_plane.c +0 -2
index 1778f6e1ea56..383bb2039bd4 100644
@@ -135,7 +135,6 @@ static void komeda_plane_destroy(struct drm_plane *plane)
 static void komeda_plane_reset(struct drm_plane *plane)
 {
 	struct komeda_plane_state *state;
-	struct komeda_plane *kplane = to_kplane(plane);
 
 	if (plane->state)
 		__drm_atomic_helper_plane_destroy_state(plane->state);
@@ -146,7 +145,6 @@ static void komeda_plane_reset(struct drm_plane *plane)
 	state = kzalloc(sizeof(*state), GFP_KERNEL);
 	if (state) {
 		__drm_atomic_helper_plane_reset(plane, &state->base);
-		state->base.zpos = kplane->layer->base.id;
 		state->base.color_encoding = DRM_COLOR_YCBCR_BT601;
 		state->base.color_range = DRM_COLOR_YCBCR_LIMITED_RANGE;
 	}
Signature · 1 line
2.34.1
#20 lore raw

PATCH 10/23 drm/exynos: plane: Remove redundant zpos initialisation

In reply to Maxime Ripard

The exynos KMS driver will call drm_plane_create_zpos_property() with an init value depending on the plane purpose.

Since the initial value wasn't carried over in the state, the driver had to set it again in exynos_drm_plane_reset(). However, the helpers have been adjusted to set it properly at reset, so this is not needed anymore.

Cc Alim Akhtar <[email protected]>
Cc Inki Dae <[email protected]>
Cc Joonyoung Shim <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Kyungmin Park <[email protected]>
Cc Seung-Woo Kim <[email protected]>
---
 drivers/gpu/drm/exynos/exynos_drm_plane.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_plane.c +1 -4
index df76bdee7dca..3615cf329e32 100644
@@ -122,7 +122,6 @@ static void exynos_plane_mode_set(struct exynos_drm_plane_state *exynos_state)
 
 static void exynos_drm_plane_reset(struct drm_plane *plane)
 {
-	struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane);
 	struct exynos_drm_plane_state *exynos_state;
 
 	if (plane->state) {
@@ -133,10 +132,8 @@ static void exynos_drm_plane_reset(struct drm_plane *plane)
 	}
 
 	exynos_state = kzalloc(sizeof(*exynos_state), GFP_KERNEL);
-	if (exynos_state) {
+	if (exynos_state)
 		__drm_atomic_helper_plane_reset(plane, &exynos_state->base);
-		plane->state->zpos = exynos_plane->config->zpos;
-	}
 }
 
 static struct drm_plane_state *
Signature · 1 line
2.34.1
#21 lore raw

PATCH 11/23 drm/imx: ipuv3-plane: Remove redundant zpos initialisation

In reply to Maxime Ripard

The imx KMS driver will call drm_plane_create_zpos_property() with an init value depending on the plane purpose.

Since the initial value wasn't carried over in the state, the driver had to set it again in ipu_plane_state_reset(). However, the helpers have been adjusted to set it properly at reset, so this is not needed anymore.

Cc NXP Linux Team <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Pengutronix Kernel Team <[email protected]>
Cc Philipp Zabel <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
---
 drivers/gpu/drm/imx/ipuv3-plane.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/gpu/drm/imx/ipuv3-plane.c +0 -3
index 846c1aae69c8..414bdf08d0b0 100644
@@ -297,7 +297,6 @@ void ipu_plane_disable_deferred(struct drm_plane *plane)
 
 static void ipu_plane_state_reset(struct drm_plane *plane)
 {
-	unsigned int zpos = (plane->type == DRM_PLANE_TYPE_PRIMARY) ? 0 : 1;
 	struct ipu_plane_state *ipu_state;
 
 	if (plane->state) {
@@ -311,8 +310,6 @@ static void ipu_plane_state_reset(struct drm_plane *plane)
 
 	if (ipu_state) {
 		__drm_atomic_helper_plane_reset(plane, &ipu_state->base);
-		ipu_state->base.zpos = zpos;
-		ipu_state->base.normalized_zpos = zpos;
 		ipu_state->base.color_encoding = DRM_COLOR_YCBCR_BT601;
 		ipu_state->base.color_range = DRM_COLOR_YCBCR_LIMITED_RANGE;
 	}
Signature · 1 line
2.34.1
#22 lore raw

PATCH 12/23 drm/msm/mdp5: Remove redundant zpos initialisation

In reply to Maxime Ripard

The mdp KMS driver will call drm_plane_create_zpos_property() with an init value depending on the plane purpose.

Since the initial value wasn't carried over in the state, the driver had to set it again in mdp5_plane_reset(). However, the helpers have been adjusted to set it properly at reset, so this is not needed anymore.

---
 drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 7 -------
 1 file changed, 7 deletions(-)
drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c +0 -7
index d60982f4bd11..5d8ac84c510b 100644
@@ -98,13 +98,6 @@ static void mdp5_plane_reset(struct drm_plane *plane)
 
 	kfree(to_mdp5_plane_state(plane->state));
 	mdp5_state = kzalloc(sizeof(*mdp5_state), GFP_KERNEL);
-
-	if (plane->type == DRM_PLANE_TYPE_PRIMARY)
-		mdp5_state->base.zpos = STAGE_BASE;
-	else
-		mdp5_state->base.zpos = STAGE0 + drm_plane_index(plane);
-	mdp5_state->base.normalized_zpos = mdp5_state->base.zpos;
-
 	__drm_atomic_helper_plane_reset(plane, &mdp5_state->base);
 }
 
Signature · 1 line
2.34.1
#23 lore raw

PATCH 13/23 drm/nouveau/kms: Remove redundant zpos initialisation

In reply to Maxime Ripard

The nouveau KMS driver will call drm_plane_create_zpos_property() with an init value depending on the plane purpose.

Since the initial value wasn't carried over in the state, the driver had to set it again in nv50_wndw_reset(). However, the helpers have been adjusted to set it properly at reset, so this is not needed anymore.

---
 drivers/gpu/drm/nouveau/dispnv50/wndw.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/nouveau/dispnv50/wndw.c +0 -2
index 133c8736426a..0c1a2ea0ed04 100644
@@ -635,8 +635,6 @@ nv50_wndw_reset(struct drm_plane *plane)
 		plane->funcs->atomic_destroy_state(plane, plane->state);
 
 	__drm_atomic_helper_plane_reset(plane, &asyw->state);
-	plane->state->zpos = nv50_wndw_zpos_default(plane);
-	plane->state->normalized_zpos = nv50_wndw_zpos_default(plane);
 }
 
 static void
Signature · 1 line
2.34.1
#24 lore raw

PATCH 14/23 drm/omap: plane: Fix zpos initial value mismatch

In reply to Maxime Ripard

While the omap_plane_init() function calls drm_plane_create_zpos_property() with an initial value of 0, omap_plane_reset() will force it to another value depending on the plane type.

Fix the discrepancy by setting the initial zpos value to the same value in the drm_plane_create_zpos_property() call.

---
 drivers/gpu/drm/omapdrm/omap_plane.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/omapdrm/omap_plane.c +11 -1
index b35205c4e979..e67baf9a942c 100644
@@ -533,6 +533,7 @@ struct drm_plane *omap_plane_init(struct drm_device *dev,
 	unsigned int num_planes = dispc_get_num_ovls(priv->dispc);
 	struct drm_plane *plane;
 	struct omap_plane *omap_plane;
+	unsigned int zpos;
 	int ret;
 	u32 nformats;
 	const u32 *formats;
@@ -564,7 +565,16 @@ struct drm_plane *omap_plane_init(struct drm_device *dev,
 	drm_plane_helper_add(plane, &omap_plane_helper_funcs);
 
 	omap_plane_install_properties(plane, &plane->base);
-	drm_plane_create_zpos_property(plane, 0, 0, num_planes - 1);
+
+	/*
+	 * Set the zpos default depending on whether we are a primary or overlay
+	 * plane.
+	 */
+	if (plane->type == DRM_PLANE_TYPE_PRIMARY)
+		zpos = 0;
+	else
+		zpos = omap_plane->id;
+	drm_plane_create_zpos_property(plane, zpos, 0, num_planes - 1);
 	drm_plane_create_alpha_property(plane);
 	drm_plane_create_blend_mode_property(plane, BIT(DRM_MODE_BLEND_PREMULTI) |
 					     BIT(DRM_MODE_BLEND_COVERAGE));
Signature · 1 line
2.34.1
#26 lore raw

PATCH 15/23 drm/omap: plane: Remove redundant zpos initialisation

In reply to Maxime Ripard

The omap KMS driver will call drm_plane_create_zpos_property() with an init value of the plane index and the plane type.

Since the initial value wasn't carried over in the state, the driver had to set it again in omap_plane_reset(). However, the helpers have been adjusted to set it properly at reset, so this is not needed anymore.

---
 drivers/gpu/drm/omapdrm/omap_plane.c | 7 -------
 1 file changed, 7 deletions(-)
drivers/gpu/drm/omapdrm/omap_plane.c +0 -7
index e67baf9a942c..d96bc929072a 100644
@@ -414,13 +414,6 @@ static void omap_plane_reset(struct drm_plane *plane)
 		return;
 
 	__drm_atomic_helper_plane_reset(plane, &omap_state->base);
-
-	/*
-	 * Set the zpos default depending on whether we are a primary or overlay
-	 * plane.
-	 */
-	plane->state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY
-			   ? 0 : omap_plane->id;
 	plane->state->color_encoding = DRM_COLOR_YCBCR_BT601;
 	plane->state->color_range = DRM_COLOR_YCBCR_FULL_RANGE;
 }
Signature · 1 line
2.34.1
#28 lore raw

PATCH 16/23 drm/rcar: plane: Remove redundant zpos initialisation

In reply to Maxime Ripard

The rcar-du KMS driver will call drm_plane_create_zpos_property() with an init value depending on the plane type.

Since the initial value wasn't carried over in the state, the driver had to set it again in rcar_du_plane_reset() and rcar_du_vsp_plane_reset(). However, the helpers have been adjusted to set it properly at reset, so this is not needed anymore.

Cc Kieran Bingham <[email protected]>
Cc Laurent Pinchart <[email protected]>
---
 drivers/gpu/drm/rcar-du/rcar_du_plane.c | 1 -
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c   | 1 -
 2 files changed, 2 deletions(-)
drivers/gpu/drm/rcar-du/rcar_du_plane.c +0 -1
index 862197be1e01..9dda5e06457d 100644
@@ -696,7 +696,6 @@ static void rcar_du_plane_reset(struct drm_plane *plane)
 	state->hwindex = -1;
 	state->source = RCAR_DU_PLANE_MEMORY;
 	state->colorkey = RCAR_DU_COLORKEY_NONE;
-	state->state.zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
 }
 
 static int rcar_du_plane_atomic_set_property(struct drm_plane *plane,
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +0 -1
index b7fc5b069cbc..719c60034952 100644
@@ -362,7 +362,6 @@ static void rcar_du_vsp_plane_reset(struct drm_plane *plane)
 		return;
 
 	__drm_atomic_helper_plane_reset(plane, &state->state);
-	state->state.zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
 }
 
 static const struct drm_plane_funcs rcar_du_vsp_plane_funcs = {
Signature · 1 line
2.34.1
#31 lore raw

PATCH 17/23 drm/sti: plane: Remove redundant zpos initialisation

In reply to Maxime Ripard

The sti KMS driver will call drm_plane_create_zpos_property() with an init value depending on the plane type.

Since the initial value wasn't carried over in the state, the driver had to set it again in sti_plane_reset() and rcar_du_vsp_plane_reset(). However, the helpers have been adjusted to set it properly at reset, so this is not needed anymore.

---
 drivers/gpu/drm/sti/sti_cursor.c | 2 +-
 drivers/gpu/drm/sti/sti_gdp.c    | 2 +-
 drivers/gpu/drm/sti/sti_hqvdp.c  | 2 +-
 drivers/gpu/drm/sti/sti_plane.c  | 6 ------
 drivers/gpu/drm/sti/sti_plane.h  | 1 -
 5 files changed, 3 insertions(+), 10 deletions(-)
drivers/gpu/drm/sti/sti_cursor.c +1 -1
index 1d6051b4f6fe..414c9973aa6d 100644
@@ -351,7 +351,7 @@ static const struct drm_plane_funcs sti_cursor_plane_helpers_funcs = {
 	.update_plane = drm_atomic_helper_update_plane,
 	.disable_plane = drm_atomic_helper_disable_plane,
 	.destroy = drm_plane_cleanup,
-	.reset = sti_plane_reset,
+	.reset = drm_atomic_helper_plane_reset,
 	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
 	.late_register = sti_cursor_late_register,
drivers/gpu/drm/sti/sti_gdp.c +1 -1
index d1a35d97bc45..3db3768a3241 100644
@@ -905,7 +905,7 @@ static const struct drm_plane_funcs sti_gdp_plane_helpers_funcs = {
 	.update_plane = drm_atomic_helper_update_plane,
 	.disable_plane = drm_atomic_helper_disable_plane,
 	.destroy = drm_plane_cleanup,
-	.reset = sti_plane_reset,
+	.reset = drm_atomic_helper_plane_reset,
 	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
 	.late_register = sti_gdp_late_register,
drivers/gpu/drm/sti/sti_hqvdp.c +1 -1
index 3c61ba8b43e0..2201a50353eb 100644
@@ -1283,7 +1283,7 @@ static const struct drm_plane_funcs sti_hqvdp_plane_helpers_funcs = {
 	.update_plane = drm_atomic_helper_update_plane,
 	.disable_plane = drm_atomic_helper_disable_plane,
 	.destroy = drm_plane_cleanup,
-	.reset = sti_plane_reset,
+	.reset = drm_atomic_helper_plane_reset,
 	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
 	.late_register = sti_hqvdp_late_register,
drivers/gpu/drm/sti/sti_plane.c +0 -6
index 3da4a46df2f2..173409cdb99e 100644
@@ -112,12 +112,6 @@ static int sti_plane_get_default_zpos(enum drm_plane_type type)
 	return 0;
 }
 
-void sti_plane_reset(struct drm_plane *plane)
-{
-	drm_atomic_helper_plane_reset(plane);
-	plane->state->zpos = sti_plane_get_default_zpos(plane->type);
-}
-
 static void sti_plane_attach_zorder_property(struct drm_plane *drm_plane,
 					     enum drm_plane_type type)
 {
drivers/gpu/drm/sti/sti_plane.h +0 -1
index 065ffffbfb4a..8e33e629d9b0 100644
@@ -81,5 +81,4 @@ void sti_plane_update_fps(struct sti_plane *plane,
 
 void sti_plane_init_property(struct sti_plane *plane,
 			     enum drm_plane_type type);
-void sti_plane_reset(struct drm_plane *plane);
 #endif
Signature · 1 line
2.34.1
#34 lore raw

PATCH 18/23 drm/sun4i: layer: Remove redundant zpos initialisation

In reply to Maxime Ripard

The sun4i KMS driver will call drm_plane_create_zpos_property() with an init value depending on the plane type.

Since the initial value wasn't carried over in the state, the driver had to set it again in sun4i_backend_layer_reset().
However, the helpers have been adjusted to set it properly at reset, so this is not needed anymore.

---
 drivers/gpu/drm/sun4i/sun4i_layer.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/gpu/drm/sun4i/sun4i_layer.c +7 -9
index 929e95f86b5b..6d43080791a0 100644
@@ -18,7 +18,6 @@
 
 static void sun4i_backend_layer_reset(struct drm_plane *plane)
 {
-	struct sun4i_layer *layer = plane_to_sun4i_layer(plane);
 	struct sun4i_layer_state *state;
 
 	if (plane->state) {
@@ -31,10 +30,8 @@ static void sun4i_backend_layer_reset(struct drm_plane *plane)
 	}
 
 	state = kzalloc(sizeof(*state), GFP_KERNEL);
-	if (state) {
+	if (state)
 		__drm_atomic_helper_plane_reset(plane, &state->state);
-		plane->state->zpos = layer->id;
-	}
 }
 
 static struct drm_plane_state *
@@ -192,7 +189,8 @@ static const uint64_t sun4i_layer_modifiers[] = {
 
 static struct sun4i_layer *sun4i_layer_init_one(struct drm_device *drm,
 						struct sun4i_backend *backend,
-						enum drm_plane_type type)
+						enum drm_plane_type type,
+						unsigned int id)
 {
 	const uint64_t *modifiers = sun4i_layer_modifiers;
 	const uint32_t *formats = sun4i_layer_formats;
@@ -204,6 +202,7 @@ static struct sun4i_layer *sun4i_layer_init_one(struct drm_device *drm,
 	if (!layer)
 		return ERR_PTR(-ENOMEM);
 
+	layer->id = id;
 	layer->backend = backend;
 
 	if (IS_ERR_OR_NULL(backend->frontend)) {
@@ -226,8 +225,8 @@ static struct sun4i_layer *sun4i_layer_init_one(struct drm_device *drm,
 			     &sun4i_backend_layer_helper_funcs);
 
 	drm_plane_create_alpha_property(&layer->plane);
-	drm_plane_create_zpos_property(&layer->plane, 0, 0,
-				       SUN4I_BACKEND_NUM_LAYERS - 1);
+	drm_plane_create_zpos_property(&layer->plane, layer->id,
+				       0, SUN4I_BACKEND_NUM_LAYERS - 1);
 
 	return layer;
 }
@@ -249,14 +248,13 @@ struct drm_plane **sun4i_layers_init(struct drm_device *drm,
 		enum drm_plane_type type = i ? DRM_PLANE_TYPE_OVERLAY : DRM_PLANE_TYPE_PRIMARY;
 		struct sun4i_layer *layer;
 
-		layer = sun4i_layer_init_one(drm, backend, type);
+		layer = sun4i_layer_init_one(drm, backend, type, i);
 		if (IS_ERR(layer)) {
 			dev_err(drm->dev, "Couldn't initialize %s plane\n",
 				i ? "overlay" : "primary");
 			return ERR_CAST(layer);
 		}
 
-		layer->id = i;
 		planes[i] = &layer->plane;
 	}
 
Signature · 1 line
2.34.1
#36 lore raw

PATCH 19/23 drm/object: Add default color encoding and range value at reset

In reply to Maxime Ripard

From: Dave Stevenson <[email protected]>

The drm_plane_create_color_properties() function asks for an initial value for the color encoding and range, and will set the associated plane state variable with that value if a state is present.

However, that function is usually called at a time where there's no state yet. Since the drm_plane_state reset helper doesn't take care of reading that value when it's called, it means that in most cases the initial value will be 0 (so DRM_COLOR_YCBCR_BT601 and DRM_COLOR_YCBCR_LIMITED_RANGE, respectively), or the drivers will have to work around it.

Let's add some code in __drm_atomic_helper_plane_state_reset() to get the initial encoding and range value if the property has been attached in order to fix this.

---
 drivers/gpu/drm/drm_atomic_state_helper.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/gpu/drm/drm_atomic_state_helper.c +14 -0
index 1412cee404ca..3b6d3bdbd099 100644
@@ -251,6 +251,20 @@ void __drm_atomic_helper_plane_state_reset(struct drm_plane_state *plane_state,
 	plane_state->alpha = DRM_BLEND_ALPHA_OPAQUE;
 	plane_state->pixel_blend_mode = DRM_MODE_BLEND_PREMULTI;
 
+	if (plane->color_encoding_property) {
+		if (!drm_object_property_get_default_value(&plane->base,
+							   plane->color_encoding_property,
+							   &val))
+			plane_state->color_encoding = val;
+	}
+
+	if (plane->color_range_property) {
+		if (!drm_object_property_get_default_value(&plane->base,
+							   plane->color_range_property,
+							   &val))
+			plane_state->color_range = val;
+	}
+
 	if (plane->zpos_property) {
 		if (!drm_object_property_get_default_value(&plane->base,
 							   plane->zpos_property,
Signature · 1 line
2.34.1
#38 lore raw

PATCH 20/23 drm/komeda: plane: Remove redundant color encoding and range initialisation

In reply to Maxime Ripard

The komeda KMS driver will call drm_plane_create_color_properties() with a default encoding and range values of BT601 and Limited Range, respectively.

Since the initial value wasn't carried over in the state, the driver had to set it again in komeda_plane_reset(). However, the helpers have been adjusted to set it properly at reset, so this is not needed anymore.

Cc Brian Starkey <[email protected]>
Cc "James (Qian) Wang" <[email protected]>
Cc Liviu Dudau <[email protected]>
Cc Mihail Atanassov <[email protected]>
---
 drivers/gpu/drm/arm/display/komeda/komeda_plane.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/arm/display/komeda/komeda_plane.c +1 -4
index 383bb2039bd4..541949f2d44a 100644
@@ -143,11 +143,8 @@ static void komeda_plane_reset(struct drm_plane *plane)
 	plane->state = NULL;
 
 	state = kzalloc(sizeof(*state), GFP_KERNEL);
-	if (state) {
+	if (state)
 		__drm_atomic_helper_plane_reset(plane, &state->base);
-		state->base.color_encoding = DRM_COLOR_YCBCR_BT601;
-		state->base.color_range = DRM_COLOR_YCBCR_LIMITED_RANGE;
-	}
 }
 
 static struct drm_plane_state *
Signature · 1 line
2.34.1
#39 lore raw

PATCH 21/23 drm/armada: overlay: Remove redundant color encoding and range initialisation

In reply to Maxime Ripard

The armada KMS driver will call drm_plane_create_color_properties() with a default encoding and range values of BT601 and Limited Range, respectively.

Since the initial value wasn't carried over in the state, the driver had to set it again in armada_overlay_reset(). However, the helpers have been adjusted to set it properly at reset, so this is not needed anymore.

---
 drivers/gpu/drm/armada/armada_overlay.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/armada/armada_overlay.c +0 -2
index 424250535fed..a25539039efd 100644
@@ -325,8 +325,6 @@ static void armada_overlay_reset(struct drm_plane *plane)
 		state->contrast = DEFAULT_CONTRAST;
 		state->saturation = DEFAULT_SATURATION;
 		__drm_atomic_helper_plane_reset(plane, &state->base.base);
-		state->base.base.color_encoding = DEFAULT_ENCODING;
-		state->base.base.color_range = DRM_COLOR_YCBCR_LIMITED_RANGE;
 	}
 }
 
Signature · 1 line
2.34.1
#40 lore raw

PATCH 22/23 drm/imx: ipuv3-plane: Remove redundant color encoding and range initialisation

In reply to Maxime Ripard

The imx KMS driver will call drm_plane_create_color_properties() with a default encoding and range values of BT601 and Limited Range, respectively.

Since the initial value wasn't carried over in the state, the driver had to set it again in ipu_plane_state_reset(). However, the helpers have been adjusted to set it properly at reset, so this is not needed anymore.

Cc NXP Linux Team <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Pengutronix Kernel Team <[email protected]>
Cc Philipp Zabel <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
---
 drivers/gpu/drm/imx/ipuv3-plane.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/imx/ipuv3-plane.c +1 -4
index 414bdf08d0b0..36b32e8806e3 100644
@@ -308,11 +308,8 @@ static void ipu_plane_state_reset(struct drm_plane *plane)
 
 	ipu_state = kzalloc(sizeof(*ipu_state), GFP_KERNEL);
 
-	if (ipu_state) {
+	if (ipu_state)
 		__drm_atomic_helper_plane_reset(plane, &ipu_state->base);
-		ipu_state->base.color_encoding = DRM_COLOR_YCBCR_BT601;
-		ipu_state->base.color_range = DRM_COLOR_YCBCR_LIMITED_RANGE;
-	}
 }
 
 static struct drm_plane_state *
Signature · 1 line
2.34.1
#41 lore raw

PATCH 23/23 drm/omap: plane: Remove redundant color encoding and range initialisation

In reply to Maxime Ripard

The omap KMS driver will call drm_plane_create_color_properties() with a default encoding and range values of BT601 and Full Range, respectively.

Since the initial value wasn't carried over in the state, the driver had to set it again in omap_plane_reset(). However, the helpers have been adjusted to set it properly at reset, so this is not needed anymore.

---
 drivers/gpu/drm/omapdrm/omap_plane.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/gpu/drm/omapdrm/omap_plane.c +0 -3
index d96bc929072a..b83d91ec030a 100644
@@ -403,7 +403,6 @@ void omap_plane_install_properties(struct drm_plane *plane,
 
 static void omap_plane_reset(struct drm_plane *plane)
 {
-	struct omap_plane *omap_plane = to_omap_plane(plane);
 	struct omap_plane_state *omap_state;
 
 	if (plane->state)
@@ -414,8 +413,6 @@ static void omap_plane_reset(struct drm_plane *plane)
 		return;
 
 	__drm_atomic_helper_plane_reset(plane, &omap_state->base);
-	plane->state->color_encoding = DRM_COLOR_YCBCR_BT601;
-	plane->state->color_range = DRM_COLOR_YCBCR_FULL_RANGE;
 }
 
 static struct drm_plane_state *
Signature · 1 line
2.34.1
maintainer
#8 lore raw

Re: [PATCH 05/23] drm/amd/display: Fix color encoding mismatch

In reply to Maxime Ripard
Quoted 7 lines · Maxime Ripard

The amdgpu KMS driver calls drm_plane_create_color_properties() with a default encoding set to BT709.

However, the core will ignore it and the driver doesn't force it in its plane state reset hook, so the initial value will be 0, which represents BT601.

Isn't this a core issue? Should __drm_atomic_helper_plane_state_reset reset all plane_state members to their properties' default values?

The amdgpu KMS driver currently doesn't respect the color_encoding property but I would expect that a call to drm_plane_create_color_properties with a default of BT709 means we're getting BT709 as color_encoding as part of atomic commits.

Harry

Quoted 28 lines

Fix the mismatch by using an initial value of BT601 in drm_plane_create_color_properties().

Cc Alex Deucher <[email protected]>
Cc "Christian König" <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Leo Li <[email protected]>
Cc "Pan, Xinhui" <[email protected]>
Cc Rodrigo Siqueira <[email protected]>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
index feccf2b555d2..86b27a355e90 100644
@@ -7914,7 +7914,7 @@ static int amdgpu_dm_plane_init(struct amdgpu_display_manager *dm,
 			BIT(DRM_COLOR_YCBCR_BT2020),
 			BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) |
 			BIT(DRM_COLOR_YCBCR_FULL_RANGE),
-			DRM_COLOR_YCBCR_BT709, DRM_COLOR_YCBCR_LIMITED_RANGE);
+			DRM_COLOR_YCBCR_BT601, DRM_COLOR_YCBCR_LIMITED_RANGE);
 	}
 
 	supported_rotations =
maintainer
#9 lore raw

Re: [PATCH 05/23] drm/amd/display: Fix color encoding mismatch

Quoted 4 lines · Harry Wentland
Quoted 3 lines · Maxime Ripard

The amdgpu KMS driver calls drm_plane_create_color_properties() with a default encoding set to BT709.

Quoted 8 lines
Quoted 4 lines

However, the core will ignore it and the driver doesn't force it in its plane state reset hook, so the initial value will be 0, which represents BT601.

Isn't this a core issue? Should __drm_atomic_helper_plane_state_reset reset all plane_state members to their properties' default values?

Ah, looks like that's exactly what you do in the later patches, which is perfect. With that, I don't think you'll need this patch anymore.

Harry

Quoted 36 lines

The amdgpu KMS driver currently doesn't respect the color_encoding property but I would expect that a call to drm_plane_create_color_properties with a default of BT709 means we're getting BT709 as color_encoding as part of atomic commits.

Harry

Quoted 28 lines

Fix the mismatch by using an initial value of BT601 in drm_plane_create_color_properties().

Cc Alex Deucher <[email protected]>
Cc "Christian König" <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Leo Li <[email protected]>
Cc "Pan, Xinhui" <[email protected]>
Cc Rodrigo Siqueira <[email protected]>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
index feccf2b555d2..86b27a355e90 100644
@@ -7914,7 +7914,7 @@ static int amdgpu_dm_plane_init(struct amdgpu_display_manager *dm,
 			BIT(DRM_COLOR_YCBCR_BT2020),
 			BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) |
 			BIT(DRM_COLOR_YCBCR_FULL_RANGE),
-			DRM_COLOR_YCBCR_BT709, DRM_COLOR_YCBCR_LIMITED_RANGE);
+			DRM_COLOR_YCBCR_BT601, DRM_COLOR_YCBCR_LIMITED_RANGE);
 	}
 
 	supported_rotations =
maintainer Reviewed-by on v1 7/23
#16 lore raw

Re: [PATCH 07/23] drm/object: Add default zpos value at reset

In reply to Maxime Ripard
Quoted 11 lines · Maxime Ripard

From: Dave Stevenson <[email protected]>

The drm_plane_create_zpos_property() function asks for an initial value, and will set the associated plane state variable with that value if a state is present.

However, that function is usually called at a time where there's no state yet. Since the drm_plane_state reset helper doesn't take care of reading that value when it's called, it means that in most cases the initial value will be 0, or the drivers will have to work around it.

Quoted 6 lines

Let's add some code in __drm_atomic_helper_plane_state_reset() to get the initial zpos value if the property has been attached in order to fix this.

Harry

Quoted 31 lines
---
 drivers/gpu/drm/drm_atomic_state_helper.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpu/drm/drm_atomic_state_helper.c +11 -0
index ddcf5c2c8e6a..1412cee404ca 100644
@@ -243,11 +243,22 @@ EXPORT_SYMBOL(drm_atomic_helper_crtc_destroy_state);
 void __drm_atomic_helper_plane_state_reset(struct drm_plane_state *plane_state,
 					   struct drm_plane *plane)
 {
+	u64 val;
+
 	plane_state->plane = plane;
 	plane_state->rotation = DRM_MODE_ROTATE_0;
 
 	plane_state->alpha = DRM_BLEND_ALPHA_OPAQUE;
 	plane_state->pixel_blend_mode = DRM_MODE_BLEND_PREMULTI;
+
+	if (plane->zpos_property) {
+		if (!drm_object_property_get_default_value(&plane->base,
+							   plane->zpos_property,
+							   &val)) {
+			plane_state->zpos = val;
+			plane_state->normalized_zpos = val;
+		}
+	}
 }
 EXPORT_SYMBOL(__drm_atomic_helper_plane_state_reset);
 
maintainer Reviewed-by on v1 19/23
#37 lore raw

Re: [PATCH 19/23] drm/object: Add default color encoding and range value at reset

In reply to Maxime Ripard
Quoted 13 lines · Maxime Ripard

From: Dave Stevenson <[email protected]>

The drm_plane_create_color_properties() function asks for an initial value for the color encoding and range, and will set the associated plane state variable with that value if a state is present.

However, that function is usually called at a time where there's no state yet. Since the drm_plane_state reset helper doesn't take care of reading that value when it's called, it means that in most cases the initial value will be 0 (so DRM_COLOR_YCBCR_BT601 and DRM_COLOR_YCBCR_LIMITED_RANGE, respectively), or the drivers will have to work around it.

Quoted 6 lines

Let's add some code in __drm_atomic_helper_plane_state_reset() to get the initial encoding and range value if the property has been attached in order to fix this.

Harry

Quoted 29 lines
---
 drivers/gpu/drm/drm_atomic_state_helper.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/gpu/drm/drm_atomic_state_helper.c +14 -0
index 1412cee404ca..3b6d3bdbd099 100644
@@ -251,6 +251,20 @@ void __drm_atomic_helper_plane_state_reset(struct drm_plane_state *plane_state,
 	plane_state->alpha = DRM_BLEND_ALPHA_OPAQUE;
 	plane_state->pixel_blend_mode = DRM_MODE_BLEND_PREMULTI;
 
+	if (plane->color_encoding_property) {
+		if (!drm_object_property_get_default_value(&plane->base,
+							   plane->color_encoding_property,
+							   &val))
+			plane_state->color_encoding = val;
+	}
+
+	if (plane->color_range_property) {
+		if (!drm_object_property_get_default_value(&plane->base,
+							   plane->color_range_property,
+							   &val))
+			plane_state->color_range = val;
+	}
+
 	if (plane->zpos_property) {
 		if (!drm_object_property_get_default_value(&plane->base,
 							   plane->zpos_property,
Reviewed-by on v1 4/23
#5 lore raw

Re: [PATCH 04/23] drm/msm/mdp5: Fix zpos initial value mismatch

In reply to Maxime Ripard
Quoted 8 lines · Maxime Ripard

While the mdp5_plane_install_properties() function calls drm_plane_create_zpos_property() with an initial value of 1, mdp5_plane_reset() will force it to another value depending on the plane type.

Fix the discrepancy by setting the initial zpos value to the same value in the drm_plane_create_zpos_property() call.

Could you please squash two msm/mdp5 patches into a single patch, making it clear that the code is moved.

Also please add:

Fixes 7d36db0be3b9 ("drm/msm/mdp5: switch to standard zpos property")

With that in place:

Quoted 41 lines
---
 drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c +8 -2
index c6b69afcbac8..d60982f4bd11 100644
@@ -48,6 +48,8 @@ static void mdp5_plane_destroy(struct drm_plane *plane)
 static void mdp5_plane_install_properties(struct drm_plane *plane,
                struct drm_mode_object *obj)
 {
+       unsigned int zpos;
+
        drm_plane_create_rotation_property(plane,
                                           DRM_MODE_ROTATE_0,
                                           DRM_MODE_ROTATE_0 |
@@ -59,7 +61,12 @@ static void mdp5_plane_install_properties(struct drm_plane *plane,
                        BIT(DRM_MODE_BLEND_PIXEL_NONE) |
                        BIT(DRM_MODE_BLEND_PREMULTI) |
                        BIT(DRM_MODE_BLEND_COVERAGE));
-       drm_plane_create_zpos_property(plane, 1, 1, 255);
+
+       if (plane->type == DRM_PLANE_TYPE_PRIMARY)
+               zpos = STAGE_BASE;
+       else
+               zpos = STAGE0 + drm_plane_index(plane);
+       drm_plane_create_zpos_property(plane, zpos, 1, 255);
 }
 
 static void
--

2.34.1

Signature · 2 lines
With best wishes
Dmitry
Reviewed-by on v1 6/23
#14 lore raw

Re: [PATCH 06/23] drm/object: Add drm_object_property_get_default_value() function

In reply to Maxime Ripard

Hi Maxime and Dave,

Thank you for the patch.

Quoted 6 lines · Maxime Ripard

From: Dave Stevenson <[email protected]>

Some functions to create properties (drm_plane_create_zpos_property or drm_plane_create_color_properties for example) will ask for a range of acceptable value and an initial one.

Quoted 6 lines

This initial value is then stored in the values array for that property.

Let's provide an helper to access this property.

Quoted 115 lines
---
 drivers/gpu/drm/drm_mode_object.c | 53 +++++++++++++++++++++++++------
 include/drm/drm_mode_object.h     |  7 ++++
 2 files changed, 50 insertions(+), 10 deletions(-)
drivers/gpu/drm/drm_mode_object.c +43 -10
index 86d9e907c0b2..ba1608effc0f 100644
@@ -297,11 +297,26 @@ int drm_object_property_set_value(struct drm_mode_object *obj,
 }
 EXPORT_SYMBOL(drm_object_property_set_value);
 
+static int __drm_object_property_get_prop_value(struct drm_mode_object *obj,
+						struct drm_property *property,
+						uint64_t *val)
+{
+	int i;
+
+	for (i = 0; i < obj->properties->count; i++) {
+		if (obj->properties->properties[i] == property) {
+			*val = obj->properties->values[i];
+			return 0;
+		}
+	}
+
+	return -EINVAL;
+}
+
 static int __drm_object_property_get_value(struct drm_mode_object *obj,
 					   struct drm_property *property,
 					   uint64_t *val)
 {
-	int i;
 
 	/* read-only properties bypass atomic mechanism and still store
 	 * their value in obj->properties->values[].. mostly to avoid
@@ -311,15 +326,7 @@ static int __drm_object_property_get_value(struct drm_mode_object *obj,
 			!(property->flags & DRM_MODE_PROP_IMMUTABLE))
 		return drm_atomic_get_property(obj, property, val);
 
-	for (i = 0; i < obj->properties->count; i++) {
-		if (obj->properties->properties[i] == property) {
-			*val = obj->properties->values[i];
-			return 0;
-		}
-
-	}
-
-	return -EINVAL;
+	return __drm_object_property_get_prop_value(obj, property, val);
 }
 
 /**
@@ -348,6 +355,32 @@ int drm_object_property_get_value(struct drm_mode_object *obj,
 }
 EXPORT_SYMBOL(drm_object_property_get_value);
 
+/**
+ * drm_object_property_get_default_value - retrieve the default value of a
+ * property when in atomic mode.
+ * @obj: drm mode object to get property value from
+ * @property: property to retrieve
+ * @val: storage for the property value
+ *
+ * This function retrieves the default state of the given property as passed in
+ * to drm_object_attach_property
+ *
+ * Only atomic drivers should call this function directly, as for non-atomic
+ * drivers it will return the current value.
+ *
+ * Returns:
+ * Zero on success, error code on failure.
+ */
+int drm_object_property_get_default_value(struct drm_mode_object *obj,
+					  struct drm_property *property,
+					  uint64_t *val)
+{
+	WARN_ON(!drm_drv_uses_atomic_modeset(property->dev));
+
+	return __drm_object_property_get_prop_value(obj, property, val);
+}
+EXPORT_SYMBOL(drm_object_property_get_default_value);
+
 /* helper for getconnector and getproperties ioctls */
 int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic,
 				   uint32_t __user *prop_ptr,
include/drm/drm_mode_object.h +7 -0
index c34a3e8030e1..912f1e415685 100644
@@ -98,6 +98,10 @@ struct drm_object_properties {
 	 * Hence atomic drivers should not use drm_object_property_set_value()
 	 * and drm_object_property_get_value() on mutable objects, i.e. those
 	 * without the DRM_MODE_PROP_IMMUTABLE flag set.
+	 *
+	 * For atomic drivers the default value of properties is stored in this
+	 * array, so drm_object_property_get_default_value can be used to
+	 * retrieve it.
 	 */
 	uint64_t values[DRM_OBJECT_MAX_PROPERTY];
 };
@@ -126,6 +130,9 @@ int drm_object_property_set_value(struct drm_mode_object *obj,
 int drm_object_property_get_value(struct drm_mode_object *obj,
 				  struct drm_property *property,
 				  uint64_t *value);
+int drm_object_property_get_default_value(struct drm_mode_object *obj,
+					  struct drm_property *property,
+					  uint64_t *val);
 
 void drm_object_attach_property(struct drm_mode_object *obj,
 				struct drm_property *property,
Signature · 1 line
2.34.1
Signature · 3 lines
Regards,

Laurent Pinchart
Reviewed-by on v1 7/23
#17 lore raw

Re: [PATCH 07/23] drm/object: Add default zpos value at reset

In reply to Maxime Ripard

Hi Maxime and Dave,

Thank you for the patch.

Quoted 11 lines · Maxime Ripard

From: Dave Stevenson <[email protected]>

The drm_plane_create_zpos_property() function asks for an initial value, and will set the associated plane state variable with that value if a state is present.

However, that function is usually called at a time where there's no state yet. Since the drm_plane_state reset helper doesn't take care of reading that value when it's called, it means that in most cases the initial value will be 0, or the drivers will have to work around it.

Quoted 6 lines

Let's add some code in __drm_atomic_helper_plane_state_reset() to get the initial zpos value if the property has been attached in order to fix this.

Looks reasonable.

Quoted 31 lines
---
 drivers/gpu/drm/drm_atomic_state_helper.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpu/drm/drm_atomic_state_helper.c +11 -0
index ddcf5c2c8e6a..1412cee404ca 100644
@@ -243,11 +243,22 @@ EXPORT_SYMBOL(drm_atomic_helper_crtc_destroy_state);
 void __drm_atomic_helper_plane_state_reset(struct drm_plane_state *plane_state,
 					   struct drm_plane *plane)
 {
+	u64 val;
+
 	plane_state->plane = plane;
 	plane_state->rotation = DRM_MODE_ROTATE_0;
 
 	plane_state->alpha = DRM_BLEND_ALPHA_OPAQUE;
 	plane_state->pixel_blend_mode = DRM_MODE_BLEND_PREMULTI;
+
+	if (plane->zpos_property) {
+		if (!drm_object_property_get_default_value(&plane->base,
+							   plane->zpos_property,
+							   &val)) {
+			plane_state->zpos = val;
+			plane_state->normalized_zpos = val;
+		}
+	}
 }
 EXPORT_SYMBOL(__drm_atomic_helper_plane_state_reset);
 
Signature · 3 lines
Regards,

Laurent Pinchart
Reviewed-by on v1 16/23
#29 lore raw

Re: [PATCH 16/23] drm/rcar: plane: Remove redundant zpos initialisation

In reply to Maxime Ripard

Hello Maxime,

Thank you for the patch.

Quoted 8 lines · Maxime Ripard

The rcar-du KMS driver will call drm_plane_create_zpos_property() with an init value depending on the plane type.

Since the initial value wasn't carried over in the state, the driver had to set it again in rcar_du_plane_reset() and rcar_du_vsp_plane_reset(). However, the helpers have been adjusted to set it properly at reset, so this is not needed anymore.

Quoted 4 lines
Cc Kieran Bingham <[email protected]>
Cc Laurent Pinchart <[email protected]>
Quoted 29 lines
---
 drivers/gpu/drm/rcar-du/rcar_du_plane.c | 1 -
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c   | 1 -
 2 files changed, 2 deletions(-)
drivers/gpu/drm/rcar-du/rcar_du_plane.c +0 -1
index 862197be1e01..9dda5e06457d 100644
@@ -696,7 +696,6 @@ static void rcar_du_plane_reset(struct drm_plane *plane)
 	state->hwindex = -1;
 	state->source = RCAR_DU_PLANE_MEMORY;
 	state->colorkey = RCAR_DU_COLORKEY_NONE;
-	state->state.zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
 }
 
 static int rcar_du_plane_atomic_set_property(struct drm_plane *plane,
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +0 -1
index b7fc5b069cbc..719c60034952 100644
@@ -362,7 +362,6 @@ static void rcar_du_vsp_plane_reset(struct drm_plane *plane)
 		return;
 
 	__drm_atomic_helper_plane_reset(plane, &state->state);
-	state->state.zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
 }
 
 static const struct drm_plane_funcs rcar_du_vsp_plane_funcs = {
Signature · 3 lines
Regards,

Laurent Pinchart
Reviewed-by on v1 16/23
#30 lore raw

Re: [PATCH 16/23] drm/rcar: plane: Remove redundant zpos initialisation

In reply to Maxime Ripard

Quoting Maxime Ripard (2022-02-07 16:35:08)

Quoted 7 lines

The rcar-du KMS driver will call drm_plane_create_zpos_property() with an init value depending on the plane type.

Since the initial value wasn't carried over in the state, the driver had to set it again in rcar_du_plane_reset() and rcar_du_vsp_plane_reset(). However, the helpers have been adjusted to set it properly at reset, so this is not needed anymore.

Sounds helpful ;-)

Quoted 4 lines
Cc Kieran Bingham <[email protected]>
Cc Laurent Pinchart <[email protected]>
Quoted 32 lines
---
 drivers/gpu/drm/rcar-du/rcar_du_plane.c | 1 -
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c   | 1 -
 2 files changed, 2 deletions(-)
drivers/gpu/drm/rcar-du/rcar_du_plane.c +0 -1
index 862197be1e01..9dda5e06457d 100644
@@ -696,7 +696,6 @@ static void rcar_du_plane_reset(struct drm_plane *plane)
        state->hwindex = -1;
        state->source = RCAR_DU_PLANE_MEMORY;
        state->colorkey = RCAR_DU_COLORKEY_NONE;
-       state->state.zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
 }
 
 static int rcar_du_plane_atomic_set_property(struct drm_plane *plane,
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +0 -1
index b7fc5b069cbc..719c60034952 100644
@@ -362,7 +362,6 @@ static void rcar_du_vsp_plane_reset(struct drm_plane *plane)
                return;
 
        __drm_atomic_helper_plane_reset(plane, &state->state);
-       state->state.zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
 }
 
 static const struct drm_plane_funcs rcar_du_vsp_plane_funcs = {
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 18/23
#35 lore raw

Re: [PATCH 18/23] drm/sun4i: layer: Remove redundant zpos initialisation

In reply to Maxime Ripard

Hi Maxime,

Dne ponedeljek, 07. februar 2022 ob 17:35:10 CET je Maxime Ripard napisal(a):

Quoted 8 lines

The sun4i KMS driver will call drm_plane_create_zpos_property() with an init value depending on the plane type.

Since the initial value wasn't carried over in the state, the driver had to set it again in sun4i_backend_layer_reset().
However, the helpers have been adjusted to set it properly at reset, so this is not needed anymore.

Quoted 5 lines

Best regards,
Jernej

maintainer Reviewed-by on v1 14/23
#25 lore raw

Re: [PATCH 14/23] drm/omap: plane: Fix zpos initial value mismatch

In reply to Maxime Ripard
Quoted 34 lines · Maxime Ripard

While the omap_plane_init() function calls drm_plane_create_zpos_property() with an initial value of 0, omap_plane_reset() will force it to another value depending on the plane type.

Fix the discrepancy by setting the initial zpos value to the same value in the drm_plane_create_zpos_property() call.

---
  drivers/gpu/drm/omapdrm/omap_plane.c | 12 +++++++++++-
  1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/omapdrm/omap_plane.c +4 -1
index b35205c4e979..e67baf9a942c 100644
@@ -533,6 +533,7 @@ struct drm_plane *omap_plane_init(struct drm_device *dev,
  	unsigned int num_planes = dispc_get_num_ovls(priv->dispc);
  	struct drm_plane *plane;
  	struct omap_plane *omap_plane;
+	unsigned int zpos;
  	int ret;
  	u32 nformats;
  	const u32 *formats;
@@ -564,7 +565,16 @@ struct drm_plane *omap_plane_init(struct drm_device *dev,
  	drm_plane_helper_add(plane, &omap_plane_helper_funcs);
 
  	omap_plane_install_properties(plane, &plane->base);
-	drm_plane_create_zpos_property(plane, 0, 0, num_planes - 1);
+
+	/*
+	 * Set the zpos default depending on whether we are a primary or overlay

drivers/gpu/drm/omapdrm/omap_plane.c struct drm_plane *omap_plane_init(struct drm_device *dev, · line 580

Quoted 10 lines
drivers/gpu/drm/omapdrm/omap_plane.c +7 -0
+	 * plane.
+	 */
+	if (plane->type == DRM_PLANE_TYPE_PRIMARY)
+		zpos = 0;
+	else
+		zpos = omap_plane->id;
+	drm_plane_create_zpos_property(plane, zpos, 0, num_planes - 1);
  	drm_plane_create_alpha_property(plane);
  	drm_plane_create_blend_mode_property(plane, BIT(DRM_MODE_BLEND_PREMULTI) |
  					     BIT(DRM_MODE_BLEND_COVERAGE));

Tomi

maintainer Reviewed-by on v1 15/23
#27 lore raw

Re: [PATCH 15/23] drm/omap: plane: Remove redundant zpos initialisation

In reply to Maxime Ripard
Quoted 21 lines · Maxime Ripard

The omap KMS driver will call drm_plane_create_zpos_property() with an init value of the plane index and the plane type.

Since the initial value wasn't carried over in the state, the driver had to set it again in omap_plane_reset(). However, the helpers have been adjusted to set it properly at reset, so this is not needed anymore.

---
  drivers/gpu/drm/omapdrm/omap_plane.c | 7 -------
  1 file changed, 7 deletions(-)
drivers/gpu/drm/omapdrm/omap_plane.c +0 -0
index e67baf9a942c..d96bc929072a 100644
@@ -414,13 +414,6 @@ static void omap_plane_reset(struct drm_plane *plane)
  		return;
 
  	__drm_atomic_helper_plane_reset(plane, &omap_state->base);

drivers/gpu/drm/omapdrm/omap_plane.c static void omap_plane_reset(struct drm_plane *plane) · line 419

Quoted 10 lines
drivers/gpu/drm/omapdrm/omap_plane.c +0 -7
-
-	/*
-	 * Set the zpos default depending on whether we are a primary or overlay
-	 * plane.
-	 */
-	plane->state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY
-			   ? 0 : omap_plane->id;
  	plane->state->color_encoding = DRM_COLOR_YCBCR_BT601;
  	plane->state->color_range = DRM_COLOR_YCBCR_FULL_RANGE;
  }

Tomi

maintainer Reviewed-by on v1 23/23
#42 lore raw

Re: [PATCH 23/23] drm/omap: plane: Remove redundant color encoding and range initialisation

In reply to Maxime Ripard
Quoted 27 lines · Maxime Ripard

The omap KMS driver will call drm_plane_create_color_properties() with a default encoding and range values of BT601 and Full Range, respectively.

Since the initial value wasn't carried over in the state, the driver had to set it again in omap_plane_reset(). However, the helpers have been adjusted to set it properly at reset, so this is not needed anymore.

---
  drivers/gpu/drm/omapdrm/omap_plane.c | 3 ---
  1 file changed, 3 deletions(-)
drivers/gpu/drm/omapdrm/omap_plane.c +0 -1
index d96bc929072a..b83d91ec030a 100644
@@ -403,7 +403,6 @@ void omap_plane_install_properties(struct drm_plane *plane,
 
  static void omap_plane_reset(struct drm_plane *plane)
  {
-	struct omap_plane *omap_plane = to_omap_plane(plane);
  	struct omap_plane_state *omap_state;
 
  	if (plane->state)

drivers/gpu/drm/omapdrm/omap_plane.c static void omap_plane_reset(struct drm_plane *plane) · line 418

Quoted 8 lines
drivers/gpu/drm/omapdrm/omap_plane.c +0 -2
@@ -414,8 +413,6 @@ static void omap_plane_reset(struct drm_plane *plane)
  		return;
 
  	__drm_atomic_helper_plane_reset(plane, &omap_state->base);
-	plane->state->color_encoding = DRM_COLOR_YCBCR_BT601;
-	plane->state->color_range = DRM_COLOR_YCBCR_FULL_RANGE;
  }
 
  static struct drm_plane_state *

Tomi

#10 lore raw

Re: [PATCH 05/23] drm/amd/display: Fix color encoding mismatch

In reply to Harry Wentland

Hi Harry,

Quoted 10 lines · Harry Wentland
Quoted 9 lines · Harry Wentland
Quoted 7 lines · Maxime Ripard

The amdgpu KMS driver calls drm_plane_create_color_properties() with a default encoding set to BT709.

However, the core will ignore it and the driver doesn't force it in its plane state reset hook, so the initial value will be 0, which represents BT601.

Quoted 6 lines
Quoted 3 lines

Isn't this a core issue? Should __drm_atomic_helper_plane_state_reset reset all plane_state members to their properties' default values?

Ah, looks like that's exactly what you do in the later patches, which is perfect. With that, I don't think you'll need this patch anymore.

Ok, I'll squash it into the patch that removes the reset code.

Thanks!
Maxime

#6 lore raw

Re: [PATCH 04/23] drm/msm/mdp5: Fix zpos initial value mismatch

In reply to Dmitry Baryshkov

Hi,

Quoted 7 lines · Dmitry Baryshkov
Quoted 6 lines · Maxime Ripard

While the mdp5_plane_install_properties() function calls drm_plane_create_zpos_property() with an initial value of 1, mdp5_plane_reset() will force it to another value depending on the plane type.

Quoted 8 lines
Quoted 2 lines

Fix the discrepancy by setting the initial zpos value to the same value in the drm_plane_create_zpos_property() call.

Could you please squash two msm/mdp5 patches into a single patch, making it clear that the code is moved.

Also please add:

Fixes 7d36db0be3b9 ("drm/msm/mdp5: switch to standard zpos property")

If we are to merge both patches, we can't have a fixes tag, since it relies on the other framework patches that won't get backported.

Maxime

Reviewed-by on v1 17/23
#32 lore raw

Re: [PATCH 17/23] drm/sti: plane: Remove redundant zpos initialisation

In reply to Maxime Ripard
Quoted 5 lines · Maxime Ripard

The sti KMS driver will call drm_plane_create_zpos_property() with an init value depending on the plane type.

Since the initial value wasn't carried over in the state, the driver had to set it again in sti_plane_reset() and rcar_du_vsp_plane_reset().

Hi Maxime,
and many thanks for your patches.

Great you added Alain as he is now the drm/sti maintainer (Maintainers file should be updated soon)

Minor typo in the commit message as rcar_du_vsp_plane_reset() is not part of drm/sti

Philippe :-)

Quoted 80 lines

However, the helpers have been adjusted to set it properly at reset, so this is not needed anymore.

---
  drivers/gpu/drm/sti/sti_cursor.c | 2 +-
  drivers/gpu/drm/sti/sti_gdp.c    | 2 +-
  drivers/gpu/drm/sti/sti_hqvdp.c  | 2 +-
  drivers/gpu/drm/sti/sti_plane.c  | 6 ------
  drivers/gpu/drm/sti/sti_plane.h  | 1 -
  5 files changed, 3 insertions(+), 10 deletions(-)
drivers/gpu/drm/sti/sti_cursor.c +1 -1
index 1d6051b4f6fe..414c9973aa6d 100644
@@ -351,7 +351,7 @@ static const struct drm_plane_funcs sti_cursor_plane_helpers_funcs = {
  	.update_plane = drm_atomic_helper_update_plane,
  	.disable_plane = drm_atomic_helper_disable_plane,
  	.destroy = drm_plane_cleanup,
-	.reset = sti_plane_reset,
+	.reset = drm_atomic_helper_plane_reset,
  	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
  	.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
  	.late_register = sti_cursor_late_register,
drivers/gpu/drm/sti/sti_gdp.c +1 -1
index d1a35d97bc45..3db3768a3241 100644
@@ -905,7 +905,7 @@ static const struct drm_plane_funcs sti_gdp_plane_helpers_funcs = {
  	.update_plane = drm_atomic_helper_update_plane,
  	.disable_plane = drm_atomic_helper_disable_plane,
  	.destroy = drm_plane_cleanup,
-	.reset = sti_plane_reset,
+	.reset = drm_atomic_helper_plane_reset,
  	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
  	.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
  	.late_register = sti_gdp_late_register,
drivers/gpu/drm/sti/sti_hqvdp.c +1 -1
index 3c61ba8b43e0..2201a50353eb 100644
@@ -1283,7 +1283,7 @@ static const struct drm_plane_funcs sti_hqvdp_plane_helpers_funcs = {
  	.update_plane = drm_atomic_helper_update_plane,
  	.disable_plane = drm_atomic_helper_disable_plane,
  	.destroy = drm_plane_cleanup,
-	.reset = sti_plane_reset,
+	.reset = drm_atomic_helper_plane_reset,
  	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
  	.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
  	.late_register = sti_hqvdp_late_register,
drivers/gpu/drm/sti/sti_plane.c +0 -6
index 3da4a46df2f2..173409cdb99e 100644
@@ -112,12 +112,6 @@ static int sti_plane_get_default_zpos(enum drm_plane_type type)
  	return 0;
  }
 
-void sti_plane_reset(struct drm_plane *plane)
-{
-	drm_atomic_helper_plane_reset(plane);
-	plane->state->zpos = sti_plane_get_default_zpos(plane->type);
-}
-
  static void sti_plane_attach_zorder_property(struct drm_plane *drm_plane,
  					     enum drm_plane_type type)
  {
drivers/gpu/drm/sti/sti_plane.h +0 -1
index 065ffffbfb4a..8e33e629d9b0 100644
@@ -81,5 +81,4 @@ void sti_plane_update_fps(struct sti_plane *plane,
 
  void sti_plane_init_property(struct sti_plane *plane,
  			     enum drm_plane_type type);
-void sti_plane_reset(struct drm_plane *plane);
  #endif
maintainer
#11 lore raw

Re: [PATCH 05/23] drm/amd/display: Fix color encoding mismatch

In reply to Maxime Ripard
Quoted 13 lines · Maxime Ripard

Hi Harry,

Quoted 10 lines · Harry Wentland
Quoted 9 lines · Harry Wentland
Quoted 7 lines · Maxime Ripard

The amdgpu KMS driver calls drm_plane_create_color_properties() with a default encoding set to BT709.

However, the core will ignore it and the driver doesn't force it in its plane state reset hook, so the initial value will be 0, which represents BT601.

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

Isn't this a core issue? Should __drm_atomic_helper_plane_state_reset reset all plane_state members to their properties' default values?

Ah, looks like that's exactly what you do in the later patches, which is perfect. With that, I don't think you'll need this patch anymore.

Ok, I'll squash it into the patch that removes the reset code.

I don't think that's right. I think we can just drop this patch. The amdgpu display driver is not doing BT601 by default.

Harry

Quoted 2 lines

Thanks!
Maxime

maintainer Reviewed-by on v1 17/23
#33 lore raw

Re: [PATCH 17/23] drm/sti: plane: Remove redundant zpos initialisation

In reply to Maxime Ripard

Hi,

thanks for the patch.

Alain

Quoted 87 lines · Maxime Ripard

The sti KMS driver will call drm_plane_create_zpos_property() with an init value depending on the plane type.

Since the initial value wasn't carried over in the state, the driver had to set it again in sti_plane_reset() and rcar_du_vsp_plane_reset(). However, the helpers have been adjusted to set it properly at reset, so this is not needed anymore.

---
 drivers/gpu/drm/sti/sti_cursor.c | 2 +-
 drivers/gpu/drm/sti/sti_gdp.c    | 2 +-
 drivers/gpu/drm/sti/sti_hqvdp.c  | 2 +-
 drivers/gpu/drm/sti/sti_plane.c  | 6 ------
 drivers/gpu/drm/sti/sti_plane.h  | 1 -
 5 files changed, 3 insertions(+), 10 deletions(-)
drivers/gpu/drm/sti/sti_cursor.c +1 -1
index 1d6051b4f6fe..414c9973aa6d 100644
@@ -351,7 +351,7 @@ static const struct drm_plane_funcs sti_cursor_plane_helpers_funcs = {
 	.update_plane = drm_atomic_helper_update_plane,
 	.disable_plane = drm_atomic_helper_disable_plane,
 	.destroy = drm_plane_cleanup,
-	.reset = sti_plane_reset,
+	.reset = drm_atomic_helper_plane_reset,
 	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
 	.late_register = sti_cursor_late_register,
drivers/gpu/drm/sti/sti_gdp.c +1 -1
index d1a35d97bc45..3db3768a3241 100644
@@ -905,7 +905,7 @@ static const struct drm_plane_funcs sti_gdp_plane_helpers_funcs = {
 	.update_plane = drm_atomic_helper_update_plane,
 	.disable_plane = drm_atomic_helper_disable_plane,
 	.destroy = drm_plane_cleanup,
-	.reset = sti_plane_reset,
+	.reset = drm_atomic_helper_plane_reset,
 	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
 	.late_register = sti_gdp_late_register,
drivers/gpu/drm/sti/sti_hqvdp.c +1 -1
index 3c61ba8b43e0..2201a50353eb 100644
@@ -1283,7 +1283,7 @@ static const struct drm_plane_funcs sti_hqvdp_plane_helpers_funcs = {
 	.update_plane = drm_atomic_helper_update_plane,
 	.disable_plane = drm_atomic_helper_disable_plane,
 	.destroy = drm_plane_cleanup,
-	.reset = sti_plane_reset,
+	.reset = drm_atomic_helper_plane_reset,
 	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
 	.late_register = sti_hqvdp_late_register,
drivers/gpu/drm/sti/sti_plane.c +0 -6
index 3da4a46df2f2..173409cdb99e 100644
@@ -112,12 +112,6 @@ static int sti_plane_get_default_zpos(enum drm_plane_type type)
 	return 0;
 }
 
-void sti_plane_reset(struct drm_plane *plane)
-{
-	drm_atomic_helper_plane_reset(plane);
-	plane->state->zpos = sti_plane_get_default_zpos(plane->type);
-}
-
 static void sti_plane_attach_zorder_property(struct drm_plane *drm_plane,
 					     enum drm_plane_type type)
 {
drivers/gpu/drm/sti/sti_plane.h +0 -1
index 065ffffbfb4a..8e33e629d9b0 100644
@@ -81,5 +81,4 @@ void sti_plane_update_fps(struct sti_plane *plane,
 
 void sti_plane_init_property(struct sti_plane *plane,
 			     enum drm_plane_type type);
-void sti_plane_reset(struct drm_plane *plane);
 #endif
Signature · 1 line
2.34.1
#12 lore raw

Re: [PATCH 05/23] drm/amd/display: Fix color encoding mismatch

In reply to Harry Wentland

Hi Harry,

Quoted 16 lines · Harry Wentland
Quoted 15 lines · Maxime Ripard
Quoted 14 lines · Harry Wentland
Quoted 12 lines · Harry Wentland
Quoted 7 lines · Maxime Ripard

The amdgpu KMS driver calls drm_plane_create_color_properties() with a default encoding set to BT709.

However, the core will ignore it and the driver doesn't force it in its plane state reset hook, so the initial value will be 0, which represents BT601.

Isn't this a core issue? Should __drm_atomic_helper_plane_state_reset reset all plane_state members to their properties' default values?

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Ah, looks like that's exactly what you do in the later patches, which is perfect. With that, I don't think you'll need this patch anymore.

Ok, I'll squash it into the patch that removes the reset code.

I don't think that's right. I think we can just drop this patch. The amdgpu display driver is not doing BT601 by default.

My understanding from the code currently in tree is that:

1) amdgpu_dm_plane_init() will call drm_plane_create_color_properties() with an initial value set to BT709.

2) dm_drm_plane_reset() will use kzalloc and then just rely on __drm_atomic_helper_plane_reset(), which will not set the color encoding at all. It's thus 0 in the initial state.

3) the drm_color_encoding enum will have BT601 associated to 0

So it does look like the default for amdgpu at the moment is BT601?

Maxime