Skip to contentSkip to conversation

Generic zpos property

PATCH Superseded Benjamin Gaignard 3 participants 8 messages Jun 13, 2016 – Jun 23, 2016

Subsystems (7)

v4 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v4 cover Generic zpos property

version 4:
make sure that normalized zpos value is stay in the defined property range and warn user if not.
Fix NULL pointer bug in rcar-du while setting zpos value. No changes in the other drivers.

version 3:
use kmalloc_array instead of kmalloc.
Correct normalize_zpos computation (comeback to Mareck original code)

version 2:
add a zpos property into drm_plane structure to simplify code. This allow to get/set zpos value in core and not in drivers code. Fix various remarks.

version 1:
refactor Marek's patches to have per plane zpos property instead of only one in core.

Benjamin Gaignard (3):
drm: add generic zpos property
drm: sti: use generic zpos for plane
drm: rcar: use generic code for managing zpos plane property

Marek Szyprowski (1):
drm/exynos: use generic code for managing zpos plane property

 Documentation/DocBook/gpu.tmpl            |  10 ++
 drivers/gpu/drm/Makefile                  |   2 +-
 drivers/gpu/drm/drm_atomic.c              |   4 +
 drivers/gpu/drm/drm_atomic_helper.c       |   6 +
 drivers/gpu/drm/drm_blend.c               | 230 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_crtc_internal.h       |   3 +
 drivers/gpu/drm/exynos/exynos_drm_drv.h   |   2 -
 drivers/gpu/drm/exynos/exynos_drm_plane.c |  67 ++-------
 drivers/gpu/drm/exynos/exynos_mixer.c     |   6 +-
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c    |   2 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.h     |   1 -
 drivers/gpu/drm/rcar-du/rcar_du_kms.c     |   5 -
 drivers/gpu/drm/rcar-du/rcar_du_plane.c   |   9 +-
 drivers/gpu/drm/rcar-du/rcar_du_plane.h   |   2 -
 drivers/gpu/drm/sti/sti_mixer.c           |   9 +-
 drivers/gpu/drm/sti/sti_plane.c           |  80 ++++-------
 drivers/gpu/drm/sti/sti_plane.h           |   2 -
 include/drm/drm_crtc.h                    |  30 ++++
 18 files changed, 331 insertions(+), 139 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_blend.c
Cc Inki Dae <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Ville Syrjala <[email protected]>
Cc Joonyoung Shim <[email protected]>
Cc Seung-Woo Kim <[email protected]>
Cc Andrzej Hajda <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Bartlomiej Zolnierkiewicz <[email protected]>
Cc Tobias Jakobi <[email protected]>
Cc Gustavo Padovan <[email protected]>
Cc Laurent Pinchart <[email protected]>
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH v4 1/4 drm: add generic zpos property

version 4:
- make sure that normalized zpos value is stay in the defined property range and warn user if not

This patch adds support for generic plane's zpos property property with well-defined semantics:
- added zpos properties to plane and plane state structures
- added helpers for normalizing zpos properties of given set of planes
- well defined semantics: planes are sorted by zpos values and then plane id value if zpos equals

Normalized zpos values are calculated automatically when generic muttable zpos property has been initialized. Drivers can simply use plane_state->normalized_zpos in their atomic_check and/or plane_update callbacks without any additional calls to DRM core.

Compare to Marek's original patch zpos property is now specific to each plane and no more to the core.
Normalize function take care of the range of per plane defined range before set normalized_zpos.

Cc Inki Dae <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Ville Syrjala <[email protected]>
Cc Joonyoung Shim <[email protected]>
Cc Seung-Woo Kim <[email protected]>
Cc Andrzej Hajda <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Bartlomiej Zolnierkiewicz <[email protected]>
Cc Tobias Jakobi <[email protected]>
Cc Gustavo Padovan <[email protected]>
Cc Laurent Pinchart <[email protected]>
---
 Documentation/DocBook/gpu.tmpl      |  10 ++
 drivers/gpu/drm/Makefile            |   2 +-
 drivers/gpu/drm/drm_atomic.c        |   4 +
 drivers/gpu/drm/drm_atomic_helper.c |   6 +
 drivers/gpu/drm/drm_blend.c         | 230 ++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_crtc_internal.h |   3 +
 include/drm/drm_crtc.h              |  30 +++++
 7 files changed, 284 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/drm_blend.c
Documentation/DocBook/gpu.tmpl +10 -0
index dac18b4..8baac27 100644
@@ -2146,6 +2146,16 @@ void intel_crt_init(struct drm_device *dev)
 		the underlying hardware).</td>
 	</tr>
 	<tr>
+	<td valign="top" > "zpos" </td>
+	<td valign="top" >RANGE</td>
+	<td valign="top" >Min= driver dependent, Max= driver dependent</td>
+	<td valign="top" >Plane</td>
+	<td valign="top" >Plane's 'z' position during blending operation (0 for background, highest for frontmost).
+		If two planes assigned to same CRTC have equal zpos values, the plane with higher plane
+		id is treated as closer to front. Can be IMMUTABLE if driver doesn't support changing
+		planes' order. Exact value range is driver dependent.</td>
+	</tr>
+	<tr>
 	<td rowspan="20" valign="top" >i915</td>
 	<td rowspan="2" valign="top" >Generic</td>
 	<td valign="top" >"Broadcast RGB"</td>
drivers/gpu/drm/Makefile +1 -1
index be43afb..dbec0ea 100644
@@ -2,7 +2,7 @@
 # Makefile for the drm device driver.  This driver provides support for the
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
 
-drm-y       :=	drm_auth.o drm_bufs.o drm_cache.o \
+drm-y       :=	drm_auth.o drm_bufs.o drm_blend.o drm_cache.o \
 		drm_context.o drm_dma.o \
 		drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \
 		drm_lock.o drm_memory.o drm_drv.o drm_vm.o \
drivers/gpu/drm/drm_atomic.c +4 -0
index 5e4b820..812b0f0 100644
@@ -690,6 +690,8 @@ int drm_atomic_plane_set_property(struct drm_plane *plane,
 		state->src_h = val;
 	} else if (property == config->rotation_property) {
 		state->rotation = val;
+	} else if (property == plane->zpos_property) {
+		state->zpos = val;
 	} else if (plane->funcs->atomic_set_property) {
 		return plane->funcs->atomic_set_property(plane, state,
 				property, val);
@@ -746,6 +748,8 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
 		*val = state->src_h;
 	} else if (property == config->rotation_property) {
 		*val = state->rotation;
+	} else if (property == plane->zpos_property) {
+		*val = state->zpos;
 	} else if (plane->funcs->atomic_get_property) {
 		return plane->funcs->atomic_get_property(plane, state, property, val);
 	} else {
drivers/gpu/drm/drm_atomic_helper.c +6 -0
index bb98d74..9fbe08c 100644
@@ -32,6 +32,8 @@
 #include <drm/drm_atomic_helper.h>
 #include <linux/fence.h>
 
+#include "drm_crtc_internal.h"
+
 /**
  * DOC: overview
  *
@@ -592,6 +594,10 @@ drm_atomic_helper_check_planes(struct drm_device *dev,
 	struct drm_plane_state *plane_state;
 	int i, ret = 0;
 
+	ret = drm_atomic_helper_normalize_zpos(dev, state);
+	if (ret)
+		return ret;
+
 	for_each_plane_in_state(state, plane, plane_state, i) {
 		const struct drm_plane_helper_funcs *funcs;
 
drivers/gpu/drm/drm_blend.c new file +230 -0

230 lines not on this page · raw message

drivers/gpu/drm/drm_crtc_internal.h +3 -0
index a78c138..37d9068 100644
@@ -42,3 +42,6 @@ int drm_atomic_get_property(struct drm_mode_object *obj,
 int drm_mode_atomic_ioctl(struct drm_device *dev,
 			  void *data, struct drm_file *file_priv);
 
+/* drm_blend.c */
+int drm_atomic_helper_normalize_zpos(struct drm_device *dev,
+				     struct drm_atomic_state *state);
include/drm/drm_crtc.h +30 -0
index 1a8d66c..11372e3 100644
@@ -307,6 +307,7 @@ struct drm_plane_helper_funcs;
  * @mode_changed: crtc_state->mode or crtc_state->enable has been changed
  * @active_changed: crtc_state->active has been toggled.
  * @connectors_changed: connectors to this crtc have been updated
+ * @zpos_changed: zpos values of planes on this crtc have been updated
  * @color_mgmt_changed: color management properties have changed (degamma or
  *	gamma LUT or CSC matrix)
  * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes
@@ -343,6 +344,7 @@ struct drm_crtc_state {
 	bool mode_changed : 1;
 	bool active_changed : 1;
 	bool connectors_changed : 1;
+	bool zpos_changed : 1;
 	bool color_mgmt_changed : 1;
 
 	/* attached planes bitmask:
@@ -1291,6 +1293,9 @@ struct drm_connector {
  * @src_w: width of visible portion of plane (in 16.16)
  * @src_h: height of visible portion of plane (in 16.16)
  * @rotation: rotation of the plane
+ * @zpos: priority of the given plane on crtc (optional)
+ * @normalized_zpos: normalized value of zpos: unique, range from 0 to N-1
+ *	 for given crtc
  * @state: backpointer to global drm_atomic_state
  */
 struct drm_plane_state {
@@ -1311,6 +1316,10 @@ struct drm_plane_state {
 	/* Plane rotation */
 	unsigned int rotation;
 
+	/* Plane zpos */
+	unsigned int zpos;
+	unsigned int normalized_zpos;
+
 	struct drm_atomic_state *state;
 };
 
@@ -1545,6 +1554,7 @@ enum drm_plane_type {
  * @properties: property tracking for this plane
  * @type: type of plane (overlay, primary, cursor)
  * @state: current atomic state for this plane
+ * @zpos_property: zpos property for this plane
  * @helper_private: mid-layer private data
  */
 struct drm_plane {
@@ -1586,6 +1596,8 @@ struct drm_plane {
 	const struct drm_plane_helper_funcs *helper_private;
 
 	struct drm_plane_state *state;
+
+	struct drm_property *zpos_property;
 };
 
 /**
@@ -2662,6 +2674,24 @@ extern void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
 				       uint degamma_lut_size,
 				       bool has_ctm,
 				       uint gamma_lut_size);
+
+int drm_plane_atomic_set_zpos_property(struct drm_plane *plane,
+				       struct drm_plane_state *state,
+				       struct drm_property *property,
+				       uint64_t val);
+
+int drm_plane_atomic_get_zpos_property(struct drm_plane *plane,
+				       const struct drm_plane_state *state,
+				       struct drm_property *property,
+				       uint64_t *val);
+
+int drm_plane_create_zpos_property(struct drm_plane *plane,
+				   unsigned int min, unsigned int max);
+
+int drm_plane_create_zpos_immutable_property(struct drm_plane *plane,
+					     unsigned int min,
+					     unsigned int max);
+
 /* Helpers */
 
 static inline struct drm_plane *drm_plane_find(struct drm_device *dev,
Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH v4 1/4] drm: add generic zpos property

Hi Benjamin,

Thank you for the patch.

Could you please reply to Ville's comment to v1 of this patch (posted on April the 25th) ?

Please also see below for additional comments.

Quoted 48 lines · On Monday 13 Jun 2016 11:21:23 Benjamin Gaignard wrote:

version 4:
- make sure that normalized zpos value is stay in the defined property range and warn user if not

This patch adds support for generic plane's zpos property property with well-defined semantics:
- added zpos properties to plane and plane state structures
- added helpers for normalizing zpos properties of given set of planes
- well defined semantics: planes are sorted by zpos values and then plane id value if zpos equals

Normalized zpos values are calculated automatically when generic muttable zpos property has been initialized. Drivers can simply use plane_state->normalized_zpos in their atomic_check and/or plane_update callbacks without any additional calls to DRM core.

Compare to Marek's original patch zpos property is now specific to each plane and no more to the core.
Normalize function take care of the range of per plane defined range before set normalized_zpos.

Cc Inki Dae <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Ville Syrjala <[email protected]>
Cc Joonyoung Shim <[email protected]>
Cc Seung-Woo Kim <[email protected]>
Cc Andrzej Hajda <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Bartlomiej Zolnierkiewicz <[email protected]>
Cc Tobias Jakobi <[email protected]>
Cc Gustavo Padovan <[email protected]>
Cc Laurent Pinchart <[email protected]>
---
 Documentation/DocBook/gpu.tmpl      |  10 ++
 drivers/gpu/drm/Makefile            |   2 +-
 drivers/gpu/drm/drm_atomic.c        |   4 +
 drivers/gpu/drm/drm_atomic_helper.c |   6 +
 drivers/gpu/drm/drm_blend.c         | 230 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_crtc_internal.h |   3 +
 include/drm/drm_crtc.h              |  30 +++++
 7 files changed, 284 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/drm_blend.c

[snip]

Quoted 6 lines
drivers/gpu/drm/drm_blend.c new file +0 -0
new file mode 100644
index 0000000..9a5361a
@@ -0,0 +1,230 @@

[snip]

Quoted 50 lines

+/**
+ * drm_atomic_helper_crtc_normalize_zpos - calculate normalized zpos values
+ * @crtc: crtc with planes, which have to be considered for normalization
+ * @crtc_state: new atomic state to apply
+ *
+ * This function checks new states of all planes assigned to given crtc and
+ * calculates normalized zpos value for them. Planes are compared first by their
+ * zpos values, then by plane id (if zpos equals). Plane with lowest zpos value
+ * is at the bottom. The plane_state->normalized_zpos is then filled with unique
+ * values from 0 to number of active planes in crtc minus one.
+ *
+ * RETURNS
+ * Zero for success or -errno
+ */

drivers/gpu/drm/drm_blend.c new file +33 -0
+int drm_atomic_helper_crtc_normalize_zpos(struct drm_crtc *crtc,
+					  struct drm_crtc_state *crtc_state)
+{
+	struct drm_atomic_state *state = crtc_state->state;
+	struct drm_device *dev = crtc->dev;
+	int total_planes = dev->mode_config.num_total_plane;
+	struct drm_plane_state **states;
+	struct drm_plane *plane;
+	int i, zpos, n = 0;
+	int ret = 0;
+
+	DRM_DEBUG_ATOMIC("[CRTC:%d:%s] calculating normalized zpos values\n",
+			 crtc->base.id, crtc->name);
+
+	states = kmalloc_array(total_planes, sizeof(*states), GFP_TEMPORARY);
+	if (!states)
+		return -ENOMEM;
+
+	/*
+	 * Normalization process might create new states for planes which
+	 * normalized_zpos has to be recalculated.
+	 */
+	drm_for_each_plane_mask(plane, dev, crtc_state->plane_mask) {
+		struct drm_plane_state *plane_state =
+			drm_atomic_get_plane_state(state, plane);
+		if (IS_ERR(plane_state)) {
+			ret = PTR_ERR(plane_state);
+			goto done;
+		}
+		states[n++] = plane_state;
+		DRM_DEBUG_ATOMIC("[PLANE:%d:%s] processing zpos value %d\n",
+				 plane->base.id, plane->name,
+				 plane_state->zpos);

drivers/gpu/drm/drm_blend.c line 173

Quoted 10 lines
drivers/gpu/drm/drm_blend.c new file +10 -0
+	}
+
+	sort(states, n, sizeof(*states), drm_atomic_state_zpos_cmp, NULL);
+
+	for (i = 0, zpos = 0; i < n; i++, zpos++) {
+		plane = states[i]->plane;
+
+		zpos = max_t(int, zpos, states[i]->zpos);
+
+		WARN_ON(zpos > plane->zpos_property->values[1]);

This crashes if the plane doesn't have a zpos property. The simplest fix is to write the check as

		WARN_ON(plane->zpos_property &&
			zpos > plane->zpos_property->values[1]);

but I wonder how we should handle drivers that instantiate a zpos property for a subdev of the planes only. For drivers that don't use zpos at all you could maybe avoid calling this function.

Additionally, this check is triggered with the rcar-du-drm driver when performing the following operations:

- Perform a mode set with the CRTC primary plane only (that plane doesn't have a zpos property)

- Add 7 overlay planes with zpos values 1 to 7 (their zpos property range is 1-7)

- Modify the zpos value of all overlay planes one by one to 7 to 1 (setting zpos 7 for plane 1 first, then zpos 6 for plane 2, ...)

I get normalized zpos values such as

[   84.892927] [PLANE:39:plane-8] normalized zpos value 9
[   85.899284] [PLANE:25:plane-0] normalized zpos value 0
[   85.904488] [PLANE:37:plane-7] normalized zpos value 2
[   85.909633] [PLANE:35:plane-6] normalized zpos value 3
[   85.914793] [PLANE:33:plane-5] normalized zpos value 4
[   85.919936] [PLANE:31:plane-4] normalized zpos value 5
[   85.925100] [PLANE:29:plane-3] normalized zpos value 6
[   85.930245] [PLANE:27:plane-2] normalized zpos value 7

(plane 25 is the primary plane, all other planes are the overlay planes, added in the order 27, 29, 31, 33, 35, 37, 37 in the sequence above)

Quoted 31 lines
drivers/gpu/drm/drm_blend.c new file +14 -0
+		states[i]->normalized_zpos = zpos;
+		DRM_DEBUG_ATOMIC("[PLANE:%d:%s] normalized zpos value %d\n",
+				 plane->base.id, plane->name, zpos);
+	}
+	crtc_state->zpos_changed = true;
+
+done:
+	kfree(states);
+	return ret;
+}
+EXPORT_SYMBOL(drm_atomic_helper_crtc_normalize_zpos);
+
+/**
+ * drm_atomic_helper_normalize_zpos - calculate normalized zpos values for

all + * crtcs
+ * @dev: DRM device
+ * @state: atomic state of DRM device
+ *
+ * This function calculates normalized zpos value for all modified planes in + * the provided atomic state of DRM device. For more information, see +
* drm_atomic_helper_crtc_normalize_zpos() function.
+ *
+ * RETURNS
+ * Zero for success or -errno
+ */

drivers/gpu/drm/drm_blend.c new file +6 -0
+int drm_atomic_helper_normalize_zpos(struct drm_device *dev,
+				     struct drm_atomic_state *state)
+{
+	struct drm_crtc *crtc;
+	struct drm_crtc_state *crtc_state;
+	struct drm_plane *plane;

drivers/gpu/drm/drm_blend.c

Quoted 10 lines
drivers/gpu/drm/drm_blend.c new file +10 -0
+	struct drm_plane_state *plane_state;
+	int i, ret = 0;
+
+	for_each_plane_in_state(state, plane, plane_state, i) {
+		crtc = plane_state->crtc;
+		if (!crtc)
+			continue;
+		if (plane->state->zpos != plane_state->zpos) {
+			crtc_state =
+				drm_atomic_get_existing_crtc_state(state, 

crtc);

drivers/gpu/drm/drm_blend.c

Quoted 9 lines
drivers/gpu/drm/drm_blend.c new file +9 -0
+			crtc_state->zpos_changed = true;
+		}
+	}
+
+	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+		if (crtc_state->plane_mask != crtc->state->plane_mask ||
+		    crtc_state->zpos_changed) {
+			ret = drm_atomic_helper_crtc_normalize_zpos(crtc,
+								    

crtc_state);

Quoted 7 lines
drivers/gpu/drm/drm_blend.c new file +7 -0
+			if (ret)
+				return ret;
+		}
+	}
+	return 0;
+}
+EXPORT_SYMBOL(drm_atomic_helper_normalize_zpos);
Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

Re: [PATCH v4 1/4] drm: add generic zpos property

2016-06-22 1:45 GMT+02:00 Laurent Pinchart <[email protected]>:

Quoted 7 lines

Hi Benjamin,

Thank you for the patch.

Could you please reply to Ville's comment to v1 of this patch (posted on April the 25th) ?

For each iteration of the patches we have swap between two solutions:
- have normalization done between 0 to N-1 without taking care of zpos property range
- take care of zpos property range while computing normalized zpos

First the solution is the most simple and the more robust so I will definitively go for it.

[snip]

Quoted 12 lines

drivers/gpu/drm/drm_blend.c line 173

Quoted 8 lines
drivers/gpu/drm/drm_blend.c new file +8 -0
+     sort(states, n, sizeof(*states), drm_atomic_state_zpos_cmp, NULL);
+
+     for (i = 0, zpos = 0; i < n; i++, zpos++) {
+             plane = states[i]->plane;
+
+             zpos = max_t(int, zpos, states[i]->zpos);
+
+             WARN_ON(zpos > plane->zpos_property->values[1]);

This crashes if the plane doesn't have a zpos property. The simplest fix is to write the check as

Quoted 2 lines
                WARN_ON(plane->zpos_property &&
                        zpos > plane->zpos_property->values[1]);

Thanks I will add that in v5

Quoted 4 lines

but I wonder how we should handle drivers that instantiate a zpos property for a subdev of the planes only. For drivers that don't use zpos at all you could maybe avoid calling this function.

I think it will be difficult to mix planes with and without zpos property. My suggestion is to use immutable zpos property for primary and cursor plane. drm_atomic_helper_crtc_normalize_zpos() is only called if plane zpos value change
so if driver don't use it normalization will not be done.

Quoted 23 lines

Additionally, this check is triggered with the rcar-du-drm driver when performing the following operations:

- Perform a mode set with the CRTC primary plane only (that plane doesn't have a zpos property)

- Add 7 overlay planes with zpos values 1 to 7 (their zpos property range is 1-7)

- Modify the zpos value of all overlay planes one by one to 7 to 1 (setting zpos 7 for plane 1 first, then zpos 6 for plane 2, ...)

I get normalized zpos values such as

[   84.892927] [PLANE:39:plane-8] normalized zpos value 9
[   85.899284] [PLANE:25:plane-0] normalized zpos value 0
[   85.904488] [PLANE:37:plane-7] normalized zpos value 2
[   85.909633] [PLANE:35:plane-6] normalized zpos value 3
[   85.914793] [PLANE:33:plane-5] normalized zpos value 4
[   85.919936] [PLANE:31:plane-4] normalized zpos value 5
[   85.925100] [PLANE:29:plane-3] normalized zpos value 6
[   85.930245] [PLANE:27:plane-2] normalized zpos value 7
Quoted 3 lines

(plane 25 is the primary plane, all other planes are the overlay planes, added in the order 27, 29, 31, 33, 35, 37, 37 in the sequence above)

I'm not able to reproduce you problem on my setup with one primary and two overlay.
When back to 0 to N-1 normalization algo you should see the problem anymore

[snip]

Quoted 5 lines

--
Regards,

Laurent Pinchart

Signature · 11 lines
Benjamin Gaignard

Graphic Working Group

Linaro.org │ Open source software for ARM SoCs

Follow Linaro: Facebook | Twitter | Blog
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw

PATCH v4 2/4 drm: sti: use generic zpos for plane

In reply to Benjamin Gaignard

remove private zpos property and use instead the generic new. zpos range is now fixed per plane type and normalized before being using in mixer.

Cc Inki Dae <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Ville Syrjala <[email protected]>
Cc Joonyoung Shim <[email protected]>
Cc Seung-Woo Kim <[email protected]>
Cc Andrzej Hajda <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Bartlomiej Zolnierkiewicz <[email protected]>
Cc Tobias Jakobi <[email protected]>
Cc Gustavo Padovan <[email protected]>
Cc Laurent Pinchart <[email protected]>
---
 drivers/gpu/drm/sti/sti_mixer.c |  9 ++---
 drivers/gpu/drm/sti/sti_plane.c | 80 +++++++++++++++--------------------------
 drivers/gpu/drm/sti/sti_plane.h |  2 --
 3 files changed, 31 insertions(+), 60 deletions(-)
drivers/gpu/drm/sti/sti_mixer.c +3 -6
index 6f86f2b..1e4a9f0 100644
@@ -239,13 +239,10 @@ static void sti_mixer_set_background_area(struct sti_mixer *mixer,
 
 int sti_mixer_set_plane_depth(struct sti_mixer *mixer, struct sti_plane *plane)
 {
-	int plane_id, depth = plane->zorder;
+	int plane_id, depth = plane->drm_plane.state->normalized_zpos;
 	unsigned int i;
 	u32 mask, val;
 
-	if ((depth < 1) || (depth > GAM_MIXER_NB_DEPTH_LEVEL))
-		return 1;
-
 	switch (plane->desc) {
 	case STI_GDP_0:
 		plane_id = GAM_DEPTH_GDP0_ID;
@@ -278,8 +275,8 @@ int sti_mixer_set_plane_depth(struct sti_mixer *mixer, struct sti_plane *plane)
 			break;
 	}
 
-	mask |= GAM_DEPTH_MASK_ID << (3 * (depth - 1));
-	plane_id = plane_id << (3 * (depth - 1));
+	mask |= GAM_DEPTH_MASK_ID << (3 * depth);
+	plane_id = plane_id << (3 * depth);
 
 	DRM_DEBUG_DRIVER("%s %s depth=%d\n", sti_mixer_to_str(mixer),
 			 sti_plane_to_str(plane), depth);
drivers/gpu/drm/sti/sti_plane.c +28 -52

112 lines not on this page · raw message

drivers/gpu/drm/sti/sti_plane.h +0 -2
index c50a3b9..2747773 100644
@@ -68,14 +68,12 @@ struct sti_fps_info {
  * @plane:              drm plane it is bound to (if any)
  * @desc:               plane type & id
  * @status:             to know the status of the plane
- * @zorder:             plane z-order
  * @fps_info:           frame per second info
  */
 struct sti_plane {
 	struct drm_plane drm_plane;
 	enum sti_plane_desc desc;
 	enum sti_plane_status status;
-	int zorder;
 	struct sti_fps_info fps_info;
 };
 
Signature · 1 line
1.9.1
#5 lore raw

PATCH v4 3/4 drm/exynos: use generic code for managing zpos plane property

In reply to Benjamin Gaignard

From: Marek Szyprowski <[email protected]>

This patch replaces zpos property handling custom code in Exynos DRM driver with calls to generic DRM code.

Cc Inki Dae <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Ville Syrjala <[email protected]>
Cc Joonyoung Shim <[email protected]>
Cc Seung-Woo Kim <[email protected]>
Cc Andrzej Hajda <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Bartlomiej Zolnierkiewicz <[email protected]>
Cc Tobias Jakobi <[email protected]>
Cc Gustavo Padovan <[email protected]>
Cc Laurent Pinchart <[email protected]>
---
 drivers/gpu/drm/exynos/exynos_drm_drv.h   |  2 -
 drivers/gpu/drm/exynos/exynos_drm_plane.c | 67 +++++--------------------------
 drivers/gpu/drm/exynos/exynos_mixer.c     |  6 ++-
 3 files changed, 13 insertions(+), 62 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_drv.h +0 -2
index cc33ec9..b34a7b9 100644
@@ -64,7 +64,6 @@ struct exynos_drm_plane_state {
 	struct exynos_drm_rect src;
 	unsigned int h_ratio;
 	unsigned int v_ratio;
-	unsigned int zpos;
 };
 
 static inline struct exynos_drm_plane_state *
@@ -221,7 +220,6 @@ struct exynos_drm_private {
 	 * this array is used to be aware of which crtc did it request vblank.
 	 */
 	struct drm_crtc *crtc[MAX_CRTC];
-	struct drm_property *plane_zpos_property;
 
 	struct device *dma_dev;
 	unsigned long da_start;
drivers/gpu/drm/exynos/exynos_drm_plane.c +9 -58

106 lines not on this page · raw message

drivers/gpu/drm/exynos/exynos_mixer.c +4 -2
index 74a4269..e1d47f9 100644
@@ -477,6 +477,7 @@ static void vp_video_buffer(struct mixer_context *ctx,
 	struct drm_display_mode *mode = &state->base.crtc->state->adjusted_mode;
 	struct mixer_resources *res = &ctx->mixer_res;
 	struct drm_framebuffer *fb = state->base.fb;
+	unsigned int priority = state->base.normalized_zpos + 1;
 	unsigned long flags;
 	dma_addr_t luma_addr[2], chroma_addr[2];
 	bool tiled_mode = false;
@@ -561,7 +562,7 @@ static void vp_video_buffer(struct mixer_context *ctx,
 
 	mixer_cfg_scan(ctx, mode->vdisplay);
 	mixer_cfg_rgb_fmt(ctx, mode->vdisplay);
-	mixer_cfg_layer(ctx, plane->index, state->zpos + 1, true);
+	mixer_cfg_layer(ctx, plane->index, priority, true);
 	mixer_cfg_vp_blend(ctx);
 	mixer_run(ctx);
 
@@ -586,6 +587,7 @@ static void mixer_graph_buffer(struct mixer_context *ctx,
 	struct drm_display_mode *mode = &state->base.crtc->state->adjusted_mode;
 	struct mixer_resources *res = &ctx->mixer_res;
 	struct drm_framebuffer *fb = state->base.fb;
+	unsigned int priority = state->base.normalized_zpos + 1;
 	unsigned long flags;
 	unsigned int win = plane->index;
 	unsigned int x_ratio = 0, y_ratio = 0;
@@ -677,7 +679,7 @@ static void mixer_graph_buffer(struct mixer_context *ctx,
 
 	mixer_cfg_scan(ctx, mode->vdisplay);
 	mixer_cfg_rgb_fmt(ctx, mode->vdisplay);
-	mixer_cfg_layer(ctx, win, state->zpos + 1, true);
+	mixer_cfg_layer(ctx, win, priority, true);
 	mixer_cfg_gfx_blend(ctx, win, is_alpha_format(fb->pixel_format));
 
 	/* layer update mandatory for mixer 16.0.33.0 */
Signature · 1 line
1.9.1
#6 lore raw

PATCH v4 4/4 drm: rcar: use generic code for managing zpos plane property

In reply to Benjamin Gaignard

version 4:
fix null pointer issue while setting zpos in plane reset function

This patch replaces zpos property handling custom code in rcar DRM driver with calls to generic DRM code.

Cc Daniel Vetter <[email protected]>
Cc Ville Syrjala <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc Marek Szyprowski <[email protected]>
---
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c  | 2 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.h   | 1 -
 drivers/gpu/drm/rcar-du/rcar_du_kms.c   | 5 -----
 drivers/gpu/drm/rcar-du/rcar_du_plane.c | 9 ++-------
 drivers/gpu/drm/rcar-du/rcar_du_plane.h | 2 --
 5 files changed, 3 insertions(+), 16 deletions(-)
drivers/gpu/drm/rcar-du/rcar_du_crtc.c +1 -1
index 0d8bdda..28d2cb6 100644
@@ -196,7 +196,7 @@ void rcar_du_crtc_route_output(struct drm_crtc *crtc,
 
 static unsigned int plane_zpos(struct rcar_du_plane *plane)
 {
-	return to_rcar_plane_state(plane->plane.state)->zpos;
+	return plane->plane.state->normalized_zpos;
 }
 
 static const struct rcar_du_format_info *
drivers/gpu/drm/rcar-du/rcar_du_drv.h +0 -1
index ed35467..c843c31 100644
@@ -92,7 +92,6 @@ struct rcar_du_device {
 	struct {
 		struct drm_property *alpha;
 		struct drm_property *colorkey;
-		struct drm_property *zpos;
 	} props;
 
 	unsigned int dpad0_source;
drivers/gpu/drm/rcar-du/rcar_du_kms.c +0 -5
index 86c109b..6a99959 100644
@@ -527,11 +527,6 @@ static int rcar_du_properties_init(struct rcar_du_device *rcdu)
 	if (rcdu->props.colorkey == NULL)
 		return -ENOMEM;
 
-	rcdu->props.zpos =
-		drm_property_create_range(rcdu->ddev, 0, "zpos", 1, 7);
-	if (rcdu->props.zpos == NULL)
-		return -ENOMEM;
-
 	return 0;
 }
 
drivers/gpu/drm/rcar-du/rcar_du_plane.c +2 -7
index bfe31ca..dc9bb96 100644
@@ -652,7 +652,7 @@ static void rcar_du_plane_reset(struct drm_plane *plane)
 	state->source = RCAR_DU_PLANE_MEMORY;
 	state->alpha = 255;
 	state->colorkey = RCAR_DU_COLORKEY_NONE;
-	state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
+	state->state.zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
 
 	plane->state = &state->state;
 	plane->state->plane = plane;
@@ -670,8 +670,6 @@ static int rcar_du_plane_atomic_set_property(struct drm_plane *plane,
 		rstate->alpha = val;
 	else if (property == rcdu->props.colorkey)
 		rstate->colorkey = val;
-	else if (property == rcdu->props.zpos)
-		rstate->zpos = val;
 	else
 		return -EINVAL;
 
@@ -690,8 +688,6 @@ static int rcar_du_plane_atomic_get_property(struct drm_plane *plane,
 		*val = rstate->alpha;
 	else if (property == rcdu->props.colorkey)
 		*val = rstate->colorkey;
-	else if (property == rcdu->props.zpos)
-		*val = rstate->zpos;
 	else
 		return -EINVAL;
 
@@ -763,8 +759,7 @@ int rcar_du_planes_init(struct rcar_du_group *rgrp)
 		drm_object_attach_property(&plane->plane.base,
 					   rcdu->props.colorkey,
 					   RCAR_DU_COLORKEY_NONE);
-		drm_object_attach_property(&plane->plane.base,
-					   rcdu->props.zpos, 1);
+		drm_plane_create_zpos_property(&plane->plane, 1, 7);
 	}
 
 	return 0;
drivers/gpu/drm/rcar-du/rcar_du_plane.h +0 -2
index b18b7b2..8b91dd3 100644
@@ -51,7 +51,6 @@ static inline struct rcar_du_plane *to_rcar_plane(struct drm_plane *plane)
  * @hwindex: 0-based hardware plane index, -1 means unused
  * @alpha: value of the plane alpha property
  * @colorkey: value of the plane colorkey property
- * @zpos: value of the plane zpos property
  */
 struct rcar_du_plane_state {
 	struct drm_plane_state state;
@@ -62,7 +61,6 @@ struct rcar_du_plane_state {
 
 	unsigned int alpha;
 	unsigned int colorkey;
-	unsigned int zpos;
 };
 
 static inline struct rcar_du_plane_state *
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#7 lore raw

PATCH 4/4 drm: rcar: use generic code for managing zpos plane property

From: Benjamin Gaignard <[email protected]>

version 4:
fix null pointer issue while setting zpos in plane reset function

This patch replaces zpos property handling custom code in rcar DRM driver with calls to generic DRM code.

---
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c  |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.h   |  1 -
 drivers/gpu/drm/rcar-du/rcar_du_kms.c   |  5 -----
 drivers/gpu/drm/rcar-du/rcar_du_plane.c |  9 ++-------
 drivers/gpu/drm/rcar-du/rcar_du_plane.h |  2 --
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c   | 13 ++++---------
 drivers/gpu/drm/rcar-du/rcar_du_vsp.h   |  2 --
 7 files changed, 7 insertions(+), 27 deletions(-)

Hi Benjamin,

(Trimming down the CC list of bit as most people are not interested in the rcar-du-drm details)

I've rebased your zpos series on top of

git://linuxtv.org/media_tree.git vsp1

that includes two patches for the rcar-du-drm driver that conflict with your series. The branch will be pushed as-is to Linus in v4.8 by Mauro, and can thus be merged by Dave in his tree. This patch is the result of the rebase.

I haven't added my Tested-by tag yet as patch 1/4 in your series causes issues with rcar-du-drm. I'll retest the whole series when a fix will be available.

drivers/gpu/drm/rcar-du/rcar_du_crtc.c +1 -1
index 0d8bdda736f9..28d2cb633c22 100644
@@ -196,7 +196,7 @@ void rcar_du_crtc_route_output(struct drm_crtc *crtc,
 
 static unsigned int plane_zpos(struct rcar_du_plane *plane)
 {
-	return to_rcar_plane_state(plane->plane.state)->zpos;
+	return plane->plane.state->normalized_zpos;
 }
 
 static const struct rcar_du_format_info *
drivers/gpu/drm/rcar-du/rcar_du_drv.h +0 -1
index ed35467d96cf..c843c3134498 100644
@@ -92,7 +92,6 @@ struct rcar_du_device {
 	struct {
 		struct drm_property *alpha;
 		struct drm_property *colorkey;
-		struct drm_property *zpos;
 	} props;
 
 	unsigned int dpad0_source;
drivers/gpu/drm/rcar-du/rcar_du_kms.c +0 -5
index 86c109b16876..6a99959ee76c 100644
@@ -527,11 +527,6 @@ static int rcar_du_properties_init(struct rcar_du_device *rcdu)
 	if (rcdu->props.colorkey == NULL)
 		return -ENOMEM;
 
-	rcdu->props.zpos =
-		drm_property_create_range(rcdu->ddev, 0, "zpos", 1, 7);
-	if (rcdu->props.zpos == NULL)
-		return -ENOMEM;
-
 	return 0;
 }
 
drivers/gpu/drm/rcar-du/rcar_du_plane.c +2 -7
index bfe31ca870cc..dc9bb96241af 100644
@@ -652,7 +652,7 @@ static void rcar_du_plane_reset(struct drm_plane *plane)
 	state->source = RCAR_DU_PLANE_MEMORY;
 	state->alpha = 255;
 	state->colorkey = RCAR_DU_COLORKEY_NONE;
-	state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
+	state->state.zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
 
 	plane->state = &state->state;
 	plane->state->plane = plane;
@@ -670,8 +670,6 @@ static int rcar_du_plane_atomic_set_property(struct drm_plane *plane,
 		rstate->alpha = val;
 	else if (property == rcdu->props.colorkey)
 		rstate->colorkey = val;
-	else if (property == rcdu->props.zpos)
-		rstate->zpos = val;
 	else
 		return -EINVAL;
 
@@ -690,8 +688,6 @@ static int rcar_du_plane_atomic_get_property(struct drm_plane *plane,
 		*val = rstate->alpha;
 	else if (property == rcdu->props.colorkey)
 		*val = rstate->colorkey;
-	else if (property == rcdu->props.zpos)
-		*val = rstate->zpos;
 	else
 		return -EINVAL;
 
@@ -763,8 +759,7 @@ int rcar_du_planes_init(struct rcar_du_group *rgrp)
 		drm_object_attach_property(&plane->plane.base,
 					   rcdu->props.colorkey,
 					   RCAR_DU_COLORKEY_NONE);
-		drm_object_attach_property(&plane->plane.base,
-					   rcdu->props.zpos, 1);
+		drm_plane_create_zpos_property(&plane->plane, 1, 7);
 	}
 
 	return 0;
drivers/gpu/drm/rcar-du/rcar_du_plane.h +0 -2
index b18b7b25dbfa..8b91dd3a46e4 100644
@@ -51,7 +51,6 @@ static inline struct rcar_du_plane *to_rcar_plane(struct drm_plane *plane)
  * @hwindex: 0-based hardware plane index, -1 means unused
  * @alpha: value of the plane alpha property
  * @colorkey: value of the plane colorkey property
- * @zpos: value of the plane zpos property
  */
 struct rcar_du_plane_state {
 	struct drm_plane_state state;
@@ -62,7 +61,6 @@ struct rcar_du_plane_state {
 
 	unsigned int alpha;
 	unsigned int colorkey;
-	unsigned int zpos;
 };
 
 static inline struct rcar_du_plane_state *
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +4 -9
index 6ac717f2056f..4255e820efca 100644
@@ -43,12 +43,12 @@ void rcar_du_vsp_enable(struct rcar_du_crtc *crtc)
 			.src_y = 0,
 			.src_w = mode->hdisplay << 16,
 			.src_h = mode->vdisplay << 16,
+			.zpos = 0,
 		},
 		.format = rcar_du_format_info(DRM_FORMAT_ARGB8888),
 		.source = RCAR_DU_PLANE_VSPD1,
 		.alpha = 255,
 		.colorkey = 0,
-		.zpos = 0,
 	};
 
 	if (rcdu->info->gen >= 3)
@@ -152,7 +152,7 @@ static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane)
 		.pixelformat = 0,
 		.pitch = fb->pitches[0],
 		.alpha = state->alpha,
-		.zpos = state->zpos,
+		.zpos = state->state.zpos,
 	};
 	unsigned int i;
 
@@ -267,7 +267,7 @@ static void rcar_du_vsp_plane_reset(struct drm_plane *plane)
 		return;
 
 	state->alpha = 255;
-	state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
+	state->state.zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
 
 	plane->state = &state->state;
 	plane->state->plane = plane;
@@ -282,8 +282,6 @@ static int rcar_du_vsp_plane_atomic_set_property(struct drm_plane *plane,
 
 	if (property == rcdu->props.alpha)
 		rstate->alpha = val;
-	else if (property == rcdu->props.zpos)
-		rstate->zpos = val;
 	else
 		return -EINVAL;
 
@@ -300,8 +298,6 @@ static int rcar_du_vsp_plane_atomic_get_property(struct drm_plane *plane,
 
 	if (property == rcdu->props.alpha)
 		*val = rstate->alpha;
-	else if (property == rcdu->props.zpos)
-		*val = rstate->zpos;
 	else
 		return -EINVAL;
 
@@ -381,8 +377,7 @@ int rcar_du_vsp_init(struct rcar_du_vsp *vsp)
 
 		drm_object_attach_property(&plane->plane.base,
 					   rcdu->props.alpha, 255);
-		drm_object_attach_property(&plane->plane.base,
-					   rcdu->props.zpos, 1);
+		drm_plane_create_zpos_property(&plane->plane, 1, 7);
 	}
 
 	return 0;
drivers/gpu/drm/rcar-du/rcar_du_vsp.h +0 -2
index 510dcc9c6816..df3bf3805c69 100644
@@ -44,7 +44,6 @@ static inline struct rcar_du_vsp_plane *to_rcar_vsp_plane(struct drm_plane *p)
  * @state: base DRM plane state
  * @format: information about the pixel format used by the plane
  * @alpha: value of the plane alpha property
- * @zpos: value of the plane zpos property
  */
 struct rcar_du_vsp_plane_state {
 	struct drm_plane_state state;
@@ -52,7 +51,6 @@ struct rcar_du_vsp_plane_state {
 	const struct rcar_du_format_info *format;
 
 	unsigned int alpha;
-	unsigned int zpos;
 };
 
 static inline struct rcar_du_vsp_plane_state *
Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel