aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2016-08-02 18:40:24 -0400
committerDave Airlie <airlied@redhat.com>2016-08-02 18:40:24 -0400
commit586efded6b8beb932e9a356f351b0c681503358f (patch)
tree1c9af56fa0d2c70bf93cf5a02429f4b5b7d11007
parentdfd2e9ab6a7db56a5f5bb55f71485a92613c8e11 (diff)
parent2fc4d838aaf2607216eda5ce9dba18fa14422a31 (diff)
Merge branch 'generic-zpos-v8' of http://git.linaro.org/people/benjamin.gaignard/kernel into drm-next
Merge generic ZPOS property support, this was backed up behind some other changes I didn't have a stable branch point for. Now they are merged to Linus tree this pull is just drm patches. * 'generic-zpos-v8' of http://git.linaro.org/people/benjamin.gaignard/kernel: drm: rcar: use generic code for managing zpos plane property drm/exynos: use generic code for managing zpos plane property drm: sti: use generic zpos for plane drm: add generic zpos property
-rw-r--r--Documentation/gpu/kms-properties.csv1
-rw-r--r--drivers/gpu/drm/Makefile2
-rw-r--r--drivers/gpu/drm/drm_atomic.c4
-rw-r--r--drivers/gpu/drm/drm_atomic_helper.c7
-rw-r--r--drivers/gpu/drm/drm_blend.c238
-rw-r--r--drivers/gpu/drm/drm_crtc_internal.h4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_drv.h2
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_plane.c67
-rw-r--r--drivers/gpu/drm/exynos/exynos_mixer.c6
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_crtc.c2
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_drv.h1
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_kms.c5
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_plane.c9
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_plane.h2
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_vsp.c14
-rw-r--r--drivers/gpu/drm/sti/sti_cursor.c4
-rw-r--r--drivers/gpu/drm/sti/sti_gdp.c4
-rw-r--r--drivers/gpu/drm/sti/sti_hqvdp.c4
-rw-r--r--drivers/gpu/drm/sti/sti_mixer.c9
-rw-r--r--drivers/gpu/drm/sti/sti_plane.c78
-rw-r--r--drivers/gpu/drm/sti/sti_plane.h7
-rw-r--r--include/drm/drm_crtc.h20
22 files changed, 334 insertions, 156 deletions
diff --git a/Documentation/gpu/kms-properties.csv b/Documentation/gpu/kms-properties.csv
index b6fcaf639c04..4c5ce3edcfd9 100644
--- a/Documentation/gpu/kms-properties.csv
+++ b/Documentation/gpu/kms-properties.csv
@@ -17,6 +17,7 @@ DRM,Generic,“rotation”,BITMASK,"{ 0, ""rotate-0"" }, { 1, ""rotate-90"" }, {
17,,“CRTC_H”,RANGE,"Min=0, Max=UINT_MAX",Plane,Scanout CRTC (destination) height (atomic) 17,,“CRTC_H”,RANGE,"Min=0, Max=UINT_MAX",Plane,Scanout CRTC (destination) height (atomic)
18,,“FB_ID”,OBJECT,DRM_MODE_OBJECT_FB,Plane,Scanout framebuffer (atomic) 18,,“FB_ID”,OBJECT,DRM_MODE_OBJECT_FB,Plane,Scanout framebuffer (atomic)
19,,“CRTC_ID”,OBJECT,DRM_MODE_OBJECT_CRTC,Plane,CRTC that plane is attached to (atomic) 19,,“CRTC_ID”,OBJECT,DRM_MODE_OBJECT_CRTC,Plane,CRTC that plane is attached to (atomic)
20,,“zpos”,RANGE,"Min=0, Max=UINT_MAX","Plane,Z-order of the plane.Planes with higher Z-order values are displayed on top, planes with identical Z-order values are display in an undefined order"
20,DVI-I,“subconnector”,ENUM,"{ “Unknown”, “DVI-D”, “DVI-A” }",Connector,TBD 21,DVI-I,“subconnector”,ENUM,"{ “Unknown”, “DVI-D”, “DVI-A” }",Connector,TBD
21,,“select subconnector”,ENUM,"{ “Automatic”, “DVI-D”, “DVI-A” }",Connector,TBD 22,,“select subconnector”,ENUM,"{ “Automatic”, “DVI-D”, “DVI-A” }",Connector,TBD
22,TV,“subconnector”,ENUM,"{ ""Unknown"", ""Composite"", ""SVIDEO"", ""Component"", ""SCART"" }",Connector,TBD 23,TV,“subconnector”,ENUM,"{ ""Unknown"", ""Composite"", ""SVIDEO"", ""Component"", ""SCART"" }",Connector,TBD
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index e3dba6f44a79..0238bf8bc8c3 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -24,7 +24,7 @@ drm-$(CONFIG_AGP) += drm_agpsupport.o
24drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_probe_helper.o \ 24drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_probe_helper.o \
25 drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o \ 25 drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o \
26 drm_kms_helper_common.o drm_dp_dual_mode_helper.o \ 26 drm_kms_helper_common.o drm_dp_dual_mode_helper.o \
27 drm_simple_kms_helper.o 27 drm_simple_kms_helper.o drm_blend.o
28 28
29drm_kms_helper-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o 29drm_kms_helper-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o
30drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o 30drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 8d2f111fa113..fa3930757972 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -711,6 +711,8 @@ int drm_atomic_plane_set_property(struct drm_plane *plane,
711 state->src_h = val; 711 state->src_h = val;
712 } else if (property == config->rotation_property) { 712 } else if (property == config->rotation_property) {
713 state->rotation = val; 713 state->rotation = val;
714 } else if (property == plane->zpos_property) {
715 state->zpos = val;
714 } else if (plane->funcs->atomic_set_property) { 716 } else if (plane->funcs->atomic_set_property) {
715 return plane->funcs->atomic_set_property(plane, state, 717 return plane->funcs->atomic_set_property(plane, state,
716 property, val); 718 property, val);
@@ -767,6 +769,8 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
767 *val = state->src_h; 769 *val = state->src_h;
768 } else if (property == config->rotation_property) { 770 } else if (property == config->rotation_property) {
769 *val = state->rotation; 771 *val = state->rotation;
772 } else if (property == plane->zpos_property) {
773 *val = state->zpos;
770 } else if (plane->funcs->atomic_get_property) { 774 } else if (plane->funcs->atomic_get_property) {
771 return plane->funcs->atomic_get_property(plane, state, property, val); 775 return plane->funcs->atomic_get_property(plane, state, property, val);
772 } else { 776 } else {
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index de7fddce3cef..20be86d89a20 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -32,6 +32,8 @@
32#include <drm/drm_atomic_helper.h> 32#include <drm/drm_atomic_helper.h>
33#include <linux/fence.h> 33#include <linux/fence.h>
34 34
35#include "drm_crtc_internal.h"
36
35/** 37/**
36 * DOC: overview 38 * DOC: overview
37 * 39 *
@@ -592,6 +594,10 @@ drm_atomic_helper_check_planes(struct drm_device *dev,
592 struct drm_plane_state *plane_state; 594 struct drm_plane_state *plane_state;
593 int i, ret = 0; 595 int i, ret = 0;
594 596
597 ret = drm_atomic_helper_normalize_zpos(dev, state);
598 if (ret)
599 return ret;
600
595 for_each_plane_in_state(state, plane, plane_state, i) { 601 for_each_plane_in_state(state, plane, plane_state, i) {
596 const struct drm_plane_helper_funcs *funcs; 602 const struct drm_plane_helper_funcs *funcs;
597 603
@@ -2955,6 +2961,7 @@ void __drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc,
2955 state->planes_changed = false; 2961 state->planes_changed = false;
2956 state->connectors_changed = false; 2962 state->connectors_changed = false;
2957 state->color_mgmt_changed = false; 2963 state->color_mgmt_changed = false;
2964 state->zpos_changed = false;
2958 state->event = NULL; 2965 state->event = NULL;
2959} 2966}
2960EXPORT_SYMBOL(__drm_atomic_helper_crtc_duplicate_state); 2967EXPORT_SYMBOL(__drm_atomic_helper_crtc_duplicate_state);
diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c
new file mode 100644
index 000000000000..f3c0942bd756
--- /dev/null
+++ b/drivers/gpu/drm/drm_blend.c
@@ -0,0 +1,238 @@
1/*
2 * Copyright (C) 2016 Samsung Electronics Co.Ltd
3 * Authors:
4 * Marek Szyprowski <m.szyprowski@samsung.com>
5 *
6 * DRM core plane blending related functions
7 *
8 * Permission to use, copy, modify, distribute, and sell this software and its
9 * documentation for any purpose is hereby granted without fee, provided that
10 * the above copyright notice appear in all copies and that both that copyright
11 * notice and this permission notice appear in supporting documentation, and
12 * that the name of the copyright holders not be used in advertising or
13 * publicity pertaining to distribution of the software without specific,
14 * written prior permission. The copyright holders make no representations
15 * about the suitability of this software for any purpose. It is provided "as
16 * is" without express or implied warranty.
17 *
18 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
19 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
20 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
21 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
22 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
23 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24 * OF THIS SOFTWARE.
25 */
26#include <drm/drmP.h>
27#include <drm/drm_atomic.h>
28#include <drm/drm_crtc.h>
29#include <linux/export.h>
30#include <linux/slab.h>
31#include <linux/sort.h>
32
33#include "drm_internal.h"
34
35/**
36 * drm_plane_create_zpos_property - create mutable zpos property
37 * @plane: drm plane
38 * @zpos: initial value of zpos property
39 * @min: minimal possible value of zpos property
40 * @max: maximal possible value of zpos property
41 *
42 * This function initializes generic mutable zpos property and enables support
43 * for it in drm core. Drivers can then attach this property to planes to enable
44 * support for configurable planes arrangement during blending operation.
45 * Once mutable zpos property has been enabled, the DRM core will automatically
46 * calculate drm_plane_state->normalized_zpos values. Usually min should be set
47 * to 0 and max to maximal number of planes for given crtc - 1.
48 *
49 * If zpos of some planes cannot be changed (like fixed background or
50 * cursor/topmost planes), driver should adjust min/max values and assign those
51 * planes immutable zpos property with lower or higher values (for more
52 * information, see drm_mode_create_zpos_immutable_property() function). In such
53 * case driver should also assign proper initial zpos values for all planes in
54 * its plane_reset() callback, so the planes will be always sorted properly.
55 *
56 * Returns:
57 * Zero on success, negative errno on failure.
58 */
59int drm_plane_create_zpos_property(struct drm_plane *plane,
60 unsigned int zpos,
61 unsigned int min, unsigned int max)
62{
63 struct drm_property *prop;
64
65 prop = drm_property_create_range(plane->dev, 0, "zpos", min, max);
66 if (!prop)
67 return -ENOMEM;
68
69 drm_object_attach_property(&plane->base, prop, zpos);
70
71 plane->zpos_property = prop;
72
73 if (plane->state) {
74 plane->state->zpos = zpos;
75 plane->state->normalized_zpos = zpos;
76 }
77
78 return 0;
79}
80EXPORT_SYMBOL(drm_plane_create_zpos_property);
81
82/**
83 * drm_plane_create_zpos_immutable_property - create immuttable zpos property
84 * @plane: drm plane
85 * @zpos: value of zpos property
86 *
87 * This function initializes generic immutable zpos property and enables
88 * support for it in drm core. Using this property driver lets userspace
89 * to get the arrangement of the planes for blending operation and notifies
90 * it that the hardware (or driver) doesn't support changing of the planes'
91 * order.
92 *
93 * Returns:
94 * Zero on success, negative errno on failure.
95 */
96int drm_plane_create_zpos_immutable_property(struct drm_plane *plane,
97 unsigned int zpos)
98{
99 struct drm_property *prop;
100
101 prop = drm_property_create_range(plane->dev, DRM_MODE_PROP_IMMUTABLE,
102 "zpos", zpos, zpos);
103 if (!prop)
104 return -ENOMEM;
105
106 drm_object_attach_property(&plane->base, prop, zpos);
107
108 plane->zpos_property = prop;
109
110 if (plane->state) {
111 plane->state->zpos = zpos;
112 plane->state->normalized_zpos = zpos;
113 }
114
115 return 0;
116}
117EXPORT_SYMBOL(drm_plane_create_zpos_immutable_property);
118
119static int drm_atomic_state_zpos_cmp(const void *a, const void *b)
120{
121 const struct drm_plane_state *sa = *(struct drm_plane_state **)a;
122 const struct drm_plane_state *sb = *(struct drm_plane_state **)b;
123
124 if (sa->zpos != sb->zpos)
125 return sa->zpos - sb->zpos;
126 else
127 return sa->plane->base.id - sb->plane->base.id;
128}
129
130/**
131 * drm_atomic_helper_crtc_normalize_zpos - calculate normalized zpos values
132 * @crtc: crtc with planes, which have to be considered for normalization
133 * @crtc_state: new atomic state to apply
134 *
135 * This function checks new states of all planes assigned to given crtc and
136 * calculates normalized zpos value for them. Planes are compared first by their
137 * zpos values, then by plane id (if zpos equals). Plane with lowest zpos value
138 * is at the bottom. The plane_state->normalized_zpos is then filled with unique
139 * values from 0 to number of active planes in crtc minus one.
140 *
141 * RETURNS
142 * Zero for success or -errno
143 */
144static int drm_atomic_helper_crtc_normalize_zpos(struct drm_crtc *crtc,
145 struct drm_crtc_state *crtc_state)
146{
147 struct drm_atomic_state *state = crtc_state->state;
148 struct drm_device *dev = crtc->dev;
149 int total_planes = dev->mode_config.num_total_plane;
150 struct drm_plane_state **states;
151 struct drm_plane *plane;
152 int i, n = 0;
153 int ret = 0;
154
155 DRM_DEBUG_ATOMIC("[CRTC:%d:%s] calculating normalized zpos values\n",
156 crtc->base.id, crtc->name);
157
158 states = kmalloc_array(total_planes, sizeof(*states), GFP_TEMPORARY);
159 if (!states)
160 return -ENOMEM;
161
162 /*
163 * Normalization process might create new states for planes which
164 * normalized_zpos has to be recalculated.
165 */
166 drm_for_each_plane_mask(plane, dev, crtc_state->plane_mask) {
167 struct drm_plane_state *plane_state =
168 drm_atomic_get_plane_state(state, plane);
169 if (IS_ERR(plane_state)) {
170 ret = PTR_ERR(plane_state);
171 goto done;
172 }
173 states[n++] = plane_state;
174 DRM_DEBUG_ATOMIC("[PLANE:%d:%s] processing zpos value %d\n",
175 plane->base.id, plane->name,
176 plane_state->zpos);
177 }
178
179 sort(states, n, sizeof(*states), drm_atomic_state_zpos_cmp, NULL);
180
181 for (i = 0; i < n; i++) {
182 plane = states[i]->plane;
183
184 states[i]->normalized_zpos = i;
185 DRM_DEBUG_ATOMIC("[PLANE:%d:%s] normalized zpos value %d\n",
186 plane->base.id, plane->name, i);
187 }
188 crtc_state->zpos_changed = true;
189
190done:
191 kfree(states);
192 return ret;
193}
194
195/**
196 * drm_atomic_helper_normalize_zpos - calculate normalized zpos values for all
197 * crtcs
198 * @dev: DRM device
199 * @state: atomic state of DRM device
200 *
201 * This function calculates normalized zpos value for all modified planes in
202 * the provided atomic state of DRM device. For more information, see
203 * drm_atomic_helper_crtc_normalize_zpos() function.
204 *
205 * RETURNS
206 * Zero for success or -errno
207 */
208int drm_atomic_helper_normalize_zpos(struct drm_device *dev,
209 struct drm_atomic_state *state)
210{
211 struct drm_crtc *crtc;
212 struct drm_crtc_state *crtc_state;
213 struct drm_plane *plane;
214 struct drm_plane_state *plane_state;
215 int i, ret = 0;
216
217 for_each_plane_in_state(state, plane, plane_state, i) {
218 crtc = plane_state->crtc;
219 if (!crtc)
220 continue;
221 if (plane->state->zpos != plane_state->zpos) {
222 crtc_state =
223 drm_atomic_get_existing_crtc_state(state, crtc);
224 crtc_state->zpos_changed = true;
225 }
226 }
227
228 for_each_crtc_in_state(state, crtc, crtc_state, i) {
229 if (crtc_state->plane_mask != crtc->state->plane_mask ||
230 crtc_state->zpos_changed) {
231 ret = drm_atomic_helper_crtc_normalize_zpos(crtc,
232 crtc_state);
233 if (ret)
234 return ret;
235 }
236 }
237 return 0;
238}
diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h
index 47a500b90fd7..0c34e6d906d1 100644
--- a/drivers/gpu/drm/drm_crtc_internal.h
+++ b/drivers/gpu/drm/drm_crtc_internal.h
@@ -128,3 +128,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
128 128
129int drm_modeset_register_all(struct drm_device *dev); 129int drm_modeset_register_all(struct drm_device *dev);
130void drm_modeset_unregister_all(struct drm_device *dev); 130void drm_modeset_unregister_all(struct drm_device *dev);
131
132/* drm_blend.c */
133int drm_atomic_helper_normalize_zpos(struct drm_device *dev,
134 struct drm_atomic_state *state);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index b39d521f093d..7f1a49d5bdbe 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -64,7 +64,6 @@ struct exynos_drm_plane_state {
64 struct exynos_drm_rect src; 64 struct exynos_drm_rect src;
65 unsigned int h_ratio; 65 unsigned int h_ratio;
66 unsigned int v_ratio; 66 unsigned int v_ratio;
67 unsigned int zpos;
68}; 67};
69 68
70static inline struct exynos_drm_plane_state * 69static inline struct exynos_drm_plane_state *
@@ -221,7 +220,6 @@ struct exynos_drm_private {
221 * this array is used to be aware of which crtc did it request vblank. 220 * this array is used to be aware of which crtc did it request vblank.
222 */ 221 */
223 struct drm_crtc *crtc[MAX_CRTC]; 222 struct drm_crtc *crtc[MAX_CRTC];
224 struct drm_property *plane_zpos_property;
225 223
226 struct device *dma_dev; 224 struct device *dma_dev;
227 void *mapping; 225 void *mapping;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c
index 77f12c00abf9..7f32419b25ea 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_plane.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c
@@ -139,9 +139,9 @@ static void exynos_drm_plane_reset(struct drm_plane *plane)
139 139
140 exynos_state = kzalloc(sizeof(*exynos_state), GFP_KERNEL); 140 exynos_state = kzalloc(sizeof(*exynos_state), GFP_KERNEL);
141 if (exynos_state) { 141 if (exynos_state) {
142 exynos_state->zpos = exynos_plane->config->zpos;
143 plane->state = &exynos_state->base; 142 plane->state = &exynos_state->base;
144 plane->state->plane = plane; 143 plane->state->plane = plane;
144 plane->state->zpos = exynos_plane->config->zpos;
145 } 145 }
146} 146}
147 147
@@ -157,7 +157,6 @@ exynos_drm_plane_duplicate_state(struct drm_plane *plane)
157 return NULL; 157 return NULL;
158 158
159 __drm_atomic_helper_plane_duplicate_state(plane, &copy->base); 159 __drm_atomic_helper_plane_duplicate_state(plane, &copy->base);
160 copy->zpos = exynos_state->zpos;
161 return &copy->base; 160 return &copy->base;
162} 161}
163 162
@@ -170,43 +169,6 @@ static void exynos_drm_plane_destroy_state(struct drm_plane *plane,
170 kfree(old_exynos_state); 169 kfree(old_exynos_state);
171} 170}
172 171
173static int exynos_drm_plane_atomic_set_property(struct drm_plane *plane,
174 struct drm_plane_state *state,
175 struct drm_property *property,
176 uint64_t val)
177{
178 struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane);
179 struct exynos_drm_plane_state *exynos_state =
180 to_exynos_plane_state(state);
181 struct exynos_drm_private *dev_priv = plane->dev->dev_private;
182 const struct exynos_drm_plane_config *config = exynos_plane->config;
183
184 if (property == dev_priv->plane_zpos_property &&
185 (config->capabilities & EXYNOS_DRM_PLANE_CAP_ZPOS))
186 exynos_state->zpos = val;
187 else
188 return -EINVAL;
189
190 return 0;
191}
192
193static int exynos_drm_plane_atomic_get_property(struct drm_plane *plane,
194 const struct drm_plane_state *state,
195 struct drm_property *property,
196 uint64_t *val)
197{
198 const struct exynos_drm_plane_state *exynos_state =
199 container_of(state, const struct exynos_drm_plane_state, base);
200 struct exynos_drm_private *dev_priv = plane->dev->dev_private;
201
202 if (property == dev_priv->plane_zpos_property)
203 *val = exynos_state->zpos;
204 else
205 return -EINVAL;
206
207 return 0;
208}
209
210static struct drm_plane_funcs exynos_plane_funcs = { 172static struct drm_plane_funcs exynos_plane_funcs = {
211 .update_plane = drm_atomic_helper_update_plane, 173 .update_plane = drm_atomic_helper_update_plane,
212 .disable_plane = drm_atomic_helper_disable_plane, 174 .disable_plane = drm_atomic_helper_disable_plane,
@@ -215,8 +177,6 @@ static struct drm_plane_funcs exynos_plane_funcs = {
215 .reset = exynos_drm_plane_reset, 177 .reset = exynos_drm_plane_reset,
216 .atomic_duplicate_state = exynos_drm_plane_duplicate_state, 178 .atomic_duplicate_state = exynos_drm_plane_duplicate_state,
217 .atomic_destroy_state = exynos_drm_plane_destroy_state, 179 .atomic_destroy_state = exynos_drm_plane_destroy_state,
218 .atomic_set_property = exynos_drm_plane_atomic_set_property,
219 .atomic_get_property = exynos_drm_plane_atomic_get_property,
220}; 180};
221 181
222static int 182static int
@@ -304,23 +264,13 @@ static const struct drm_plane_helper_funcs plane_helper_funcs = {
304}; 264};
305 265
306static void exynos_plane_attach_zpos_property(struct drm_plane *plane, 266static void exynos_plane_attach_zpos_property(struct drm_plane *plane,
307 unsigned int zpos) 267 bool immutable)
308{ 268{
309 struct drm_device *dev = plane->dev; 269 /* FIXME */
310 struct exynos_drm_private *dev_priv = dev->dev_private; 270 if (immutable)
311 struct drm_property *prop; 271 drm_plane_create_zpos_immutable_property(plane, 0);
312 272 else
313 prop = dev_priv->plane_zpos_property; 273 drm_plane_create_zpos_property(plane, 0, 0, MAX_PLANE - 1);
314 if (!prop) {
315 prop = drm_property_create_range(dev, 0, "zpos",
316 0, MAX_PLANE - 1);
317 if (!prop)
318 return;
319
320 dev_priv->plane_zpos_property = prop;
321 }
322
323 drm_object_attach_property(&plane->base, prop, zpos);
324} 274}
325 275
326int exynos_plane_init(struct drm_device *dev, 276int exynos_plane_init(struct drm_device *dev,
@@ -346,7 +296,8 @@ int exynos_plane_init(struct drm_device *dev,
346 exynos_plane->index = index; 296 exynos_plane->index = index;
347 exynos_plane->config = config; 297 exynos_plane->config = config;
348 298
349 exynos_plane_attach_zpos_property(&exynos_plane->base, config->zpos); 299 exynos_plane_attach_zpos_property(&exynos_plane->base,
300 !(config->capabilities & EXYNOS_DRM_PLANE_CAP_ZPOS));
350 301
351 return 0; 302 return 0;
352} 303}
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index 74a4269cc1b0..e1d47f9435fc 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -477,6 +477,7 @@ static void vp_video_buffer(struct mixer_context *ctx,
477 struct drm_display_mode *mode = &state->base.crtc->state->adjusted_mode; 477 struct drm_display_mode *mode = &state->base.crtc->state->adjusted_mode;
478 struct mixer_resources *res = &ctx->mixer_res; 478 struct mixer_resources *res = &ctx->mixer_res;
479 struct drm_framebuffer *fb = state->base.fb; 479 struct drm_framebuffer *fb = state->base.fb;
480 unsigned int priority = state->base.normalized_zpos + 1;
480 unsigned long flags; 481 unsigned long flags;
481 dma_addr_t luma_addr[2], chroma_addr[2]; 482 dma_addr_t luma_addr[2], chroma_addr[2];
482 bool tiled_mode = false; 483 bool tiled_mode = false;
@@ -561,7 +562,7 @@ static void vp_video_buffer(struct mixer_context *ctx,
561 562
562 mixer_cfg_scan(ctx, mode->vdisplay); 563 mixer_cfg_scan(ctx, mode->vdisplay);
563 mixer_cfg_rgb_fmt(ctx, mode->vdisplay); 564 mixer_cfg_rgb_fmt(ctx, mode->vdisplay);
564 mixer_cfg_layer(ctx, plane->index, state->zpos + 1, true); 565 mixer_cfg_layer(ctx, plane->index, priority, true);
565 mixer_cfg_vp_blend(ctx); 566 mixer_cfg_vp_blend(ctx);
566 mixer_run(ctx); 567 mixer_run(ctx);
567 568
@@ -586,6 +587,7 @@ static void mixer_graph_buffer(struct mixer_context *ctx,
586 struct drm_display_mode *mode = &state->base.crtc->state->adjusted_mode; 587 struct drm_display_mode *mode = &state->base.crtc->state->adjusted_mode;
587 struct mixer_resources *res = &ctx->mixer_res; 588 struct mixer_resources *res = &ctx->mixer_res;
588 struct drm_framebuffer *fb = state->base.fb; 589 struct drm_framebuffer *fb = state->base.fb;
590 unsigned int priority = state->base.normalized_zpos + 1;
589 unsigned long flags; 591 unsigned long flags;
590 unsigned int win = plane->index; 592 unsigned int win = plane->index;
591 unsigned int x_ratio = 0, y_ratio = 0; 593 unsigned int x_ratio = 0, y_ratio = 0;
@@ -677,7 +679,7 @@ static void mixer_graph_buffer(struct mixer_context *ctx,
677 679
678 mixer_cfg_scan(ctx, mode->vdisplay); 680 mixer_cfg_scan(ctx, mode->vdisplay);
679 mixer_cfg_rgb_fmt(ctx, mode->vdisplay); 681 mixer_cfg_rgb_fmt(ctx, mode->vdisplay);
680 mixer_cfg_layer(ctx, win, state->zpos + 1, true); 682 mixer_cfg_layer(ctx, win, priority, true);
681 mixer_cfg_gfx_blend(ctx, win, is_alpha_format(fb->pixel_format)); 683 mixer_cfg_gfx_blend(ctx, win, is_alpha_format(fb->pixel_format));
682 684
683 /* layer update mandatory for mixer 16.0.33.0 */ 685 /* layer update mandatory for mixer 16.0.33.0 */
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index e39fcef2e033..7316fc7fa0bd 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -196,7 +196,7 @@ void rcar_du_crtc_route_output(struct drm_crtc *crtc,
196 196
197static unsigned int plane_zpos(struct rcar_du_plane *plane) 197static unsigned int plane_zpos(struct rcar_du_plane *plane)
198{ 198{
199 return to_rcar_plane_state(plane->plane.state)->zpos; 199 return plane->plane.state->normalized_zpos;
200} 200}
201 201
202static const struct rcar_du_format_info * 202static const struct rcar_du_format_info *
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.h b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
index ed35467d96cf..c843c3134498 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.h
@@ -92,7 +92,6 @@ struct rcar_du_device {
92 struct { 92 struct {
93 struct drm_property *alpha; 93 struct drm_property *alpha;
94 struct drm_property *colorkey; 94 struct drm_property *colorkey;
95 struct drm_property *zpos;
96 } props; 95 } props;
97 96
98 unsigned int dpad0_source; 97 unsigned int dpad0_source;
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index 6bb032d8ac6b..f03eb55318c1 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -527,11 +527,6 @@ static int rcar_du_properties_init(struct rcar_du_device *rcdu)
527 if (rcdu->props.colorkey == NULL) 527 if (rcdu->props.colorkey == NULL)
528 return -ENOMEM; 528 return -ENOMEM;
529 529
530 rcdu->props.zpos =
531 drm_property_create_range(rcdu->ddev, 0, "zpos", 1, 7);
532 if (rcdu->props.zpos == NULL)
533 return -ENOMEM;
534
535 return 0; 530 return 0;
536} 531}
537 532
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
index bfe31ca870cc..a74f8ed8ca2e 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
@@ -652,7 +652,7 @@ static void rcar_du_plane_reset(struct drm_plane *plane)
652 state->source = RCAR_DU_PLANE_MEMORY; 652 state->source = RCAR_DU_PLANE_MEMORY;
653 state->alpha = 255; 653 state->alpha = 255;
654 state->colorkey = RCAR_DU_COLORKEY_NONE; 654 state->colorkey = RCAR_DU_COLORKEY_NONE;
655 state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1; 655 state->state.zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
656 656
657 plane->state = &state->state; 657 plane->state = &state->state;
658 plane->state->plane = plane; 658 plane->state->plane = plane;
@@ -670,8 +670,6 @@ static int rcar_du_plane_atomic_set_property(struct drm_plane *plane,
670 rstate->alpha = val; 670 rstate->alpha = val;
671 else if (property == rcdu->props.colorkey) 671 else if (property == rcdu->props.colorkey)
672 rstate->colorkey = val; 672 rstate->colorkey = val;
673 else if (property == rcdu->props.zpos)
674 rstate->zpos = val;
675 else 673 else
676 return -EINVAL; 674 return -EINVAL;
677 675
@@ -690,8 +688,6 @@ static int rcar_du_plane_atomic_get_property(struct drm_plane *plane,
690 *val = rstate->alpha; 688 *val = rstate->alpha;
691 else if (property == rcdu->props.colorkey) 689 else if (property == rcdu->props.colorkey)
692 *val = rstate->colorkey; 690 *val = rstate->colorkey;
693 else if (property == rcdu->props.zpos)
694 *val = rstate->zpos;
695 else 691 else
696 return -EINVAL; 692 return -EINVAL;
697 693
@@ -763,8 +759,7 @@ int rcar_du_planes_init(struct rcar_du_group *rgrp)
763 drm_object_attach_property(&plane->plane.base, 759 drm_object_attach_property(&plane->plane.base,
764 rcdu->props.colorkey, 760 rcdu->props.colorkey,
765 RCAR_DU_COLORKEY_NONE); 761 RCAR_DU_COLORKEY_NONE);
766 drm_object_attach_property(&plane->plane.base, 762 drm_plane_create_zpos_property(&plane->plane, 1, 1, 7);
767 rcdu->props.zpos, 1);
768 } 763 }
769 764
770 return 0; 765 return 0;
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.h b/drivers/gpu/drm/rcar-du/rcar_du_plane.h
index b18b7b25dbfa..8b91dd3a46e4 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_plane.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.h
@@ -51,7 +51,6 @@ static inline struct rcar_du_plane *to_rcar_plane(struct drm_plane *plane)
51 * @hwindex: 0-based hardware plane index, -1 means unused 51 * @hwindex: 0-based hardware plane index, -1 means unused
52 * @alpha: value of the plane alpha property 52 * @alpha: value of the plane alpha property
53 * @colorkey: value of the plane colorkey property 53 * @colorkey: value of the plane colorkey property
54 * @zpos: value of the plane zpos property
55 */ 54 */
56struct rcar_du_plane_state { 55struct rcar_du_plane_state {
57 struct drm_plane_state state; 56 struct drm_plane_state state;
@@ -62,7 +61,6 @@ struct rcar_du_plane_state {
62 61
63 unsigned int alpha; 62 unsigned int alpha;
64 unsigned int colorkey; 63 unsigned int colorkey;
65 unsigned int zpos;
66}; 64};
67 65
68static inline struct rcar_du_plane_state * 66static inline struct rcar_du_plane_state *
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
index 6ac717f2056f..83ebd162f3ef 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
@@ -43,12 +43,12 @@ void rcar_du_vsp_enable(struct rcar_du_crtc *crtc)
43 .src_y = 0, 43 .src_y = 0,
44 .src_w = mode->hdisplay << 16, 44 .src_w = mode->hdisplay << 16,
45 .src_h = mode->vdisplay << 16, 45 .src_h = mode->vdisplay << 16,
46 .zpos = 0,
46 }, 47 },
47 .format = rcar_du_format_info(DRM_FORMAT_ARGB8888), 48 .format = rcar_du_format_info(DRM_FORMAT_ARGB8888),
48 .source = RCAR_DU_PLANE_VSPD1, 49 .source = RCAR_DU_PLANE_VSPD1,
49 .alpha = 255, 50 .alpha = 255,
50 .colorkey = 0, 51 .colorkey = 0,
51 .zpos = 0,
52 }; 52 };
53 53
54 if (rcdu->info->gen >= 3) 54 if (rcdu->info->gen >= 3)
@@ -152,7 +152,7 @@ static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane)
152 .pixelformat = 0, 152 .pixelformat = 0,
153 .pitch = fb->pitches[0], 153 .pitch = fb->pitches[0],
154 .alpha = state->alpha, 154 .alpha = state->alpha,
155 .zpos = state->zpos, 155 .zpos = state->state.zpos,
156 }; 156 };
157 unsigned int i; 157 unsigned int i;
158 158
@@ -267,7 +267,7 @@ static void rcar_du_vsp_plane_reset(struct drm_plane *plane)
267 return; 267 return;
268 268
269 state->alpha = 255; 269 state->alpha = 255;
270 state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1; 270 state->state.zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
271 271
272 plane->state = &state->state; 272 plane->state = &state->state;
273 plane->state->plane = plane; 273 plane->state->plane = plane;
@@ -282,8 +282,6 @@ static int rcar_du_vsp_plane_atomic_set_property(struct drm_plane *plane,
282 282
283 if (property == rcdu->props.alpha) 283 if (property == rcdu->props.alpha)
284 rstate->alpha = val; 284 rstate->alpha = val;
285 else if (property == rcdu->props.zpos)
286 rstate->zpos = val;
287 else 285 else
288 return -EINVAL; 286 return -EINVAL;
289 287
@@ -300,8 +298,6 @@ static int rcar_du_vsp_plane_atomic_get_property(struct drm_plane *plane,
300 298
301 if (property == rcdu->props.alpha) 299 if (property == rcdu->props.alpha)
302 *val = rstate->alpha; 300 *val = rstate->alpha;
303 else if (property == rcdu->props.zpos)
304 *val = rstate->zpos;
305 else 301 else
306 return -EINVAL; 302 return -EINVAL;
307 303
@@ -381,8 +377,8 @@ int rcar_du_vsp_init(struct rcar_du_vsp *vsp)
381 377
382 drm_object_attach_property(&plane->plane.base, 378 drm_object_attach_property(&plane->plane.base,
383 rcdu->props.alpha, 255); 379 rcdu->props.alpha, 255);
384 drm_object_attach_property(&plane->plane.base, 380 drm_plane_create_zpos_property(&plane->plane, 1, 1,
385 rcdu->props.zpos, 1); 381 vsp->num_planes - 1);
386 } 382 }
387 383
388 return 0; 384 return 0;
diff --git a/drivers/gpu/drm/sti/sti_cursor.c b/drivers/gpu/drm/sti/sti_cursor.c
index a263bbba4119..3b53f7f2e3fc 100644
--- a/drivers/gpu/drm/sti/sti_cursor.c
+++ b/drivers/gpu/drm/sti/sti_cursor.c
@@ -349,8 +349,8 @@ struct drm_plane_funcs sti_cursor_plane_helpers_funcs = {
349 .update_plane = drm_atomic_helper_update_plane, 349 .update_plane = drm_atomic_helper_update_plane,
350 .disable_plane = drm_atomic_helper_disable_plane, 350 .disable_plane = drm_atomic_helper_disable_plane,
351 .destroy = sti_cursor_destroy, 351 .destroy = sti_cursor_destroy,
352 .set_property = sti_plane_set_property, 352 .set_property = drm_atomic_helper_plane_set_property,
353 .reset = drm_atomic_helper_plane_reset, 353 .reset = sti_plane_reset,
354 .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, 354 .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
355 .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, 355 .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
356 .late_register = sti_cursor_late_register, 356 .late_register = sti_cursor_late_register,
diff --git a/drivers/gpu/drm/sti/sti_gdp.c b/drivers/gpu/drm/sti/sti_gdp.c
index bf63086a3dc8..b8d942ca45e8 100644
--- a/drivers/gpu/drm/sti/sti_gdp.c
+++ b/drivers/gpu/drm/sti/sti_gdp.c
@@ -886,8 +886,8 @@ struct drm_plane_funcs sti_gdp_plane_helpers_funcs = {
886 .update_plane = drm_atomic_helper_update_plane, 886 .update_plane = drm_atomic_helper_update_plane,
887 .disable_plane = drm_atomic_helper_disable_plane, 887 .disable_plane = drm_atomic_helper_disable_plane,
888 .destroy = sti_gdp_destroy, 888 .destroy = sti_gdp_destroy,
889 .set_property = sti_plane_set_property, 889 .set_property = drm_atomic_helper_plane_set_property,
890 .reset = drm_atomic_helper_plane_reset, 890 .reset = sti_plane_reset,
891 .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, 891 .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
892 .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, 892 .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
893 .late_register = sti_gdp_late_register, 893 .late_register = sti_gdp_late_register,
diff --git a/drivers/gpu/drm/sti/sti_hqvdp.c b/drivers/gpu/drm/sti/sti_hqvdp.c
index b03232247966..b5ee783e3e7c 100644
--- a/drivers/gpu/drm/sti/sti_hqvdp.c
+++ b/drivers/gpu/drm/sti/sti_hqvdp.c
@@ -1254,8 +1254,8 @@ struct drm_plane_funcs sti_hqvdp_plane_helpers_funcs = {
1254 .update_plane = drm_atomic_helper_update_plane, 1254 .update_plane = drm_atomic_helper_update_plane,
1255 .disable_plane = drm_atomic_helper_disable_plane, 1255 .disable_plane = drm_atomic_helper_disable_plane,
1256 .destroy = sti_hqvdp_destroy, 1256 .destroy = sti_hqvdp_destroy,
1257 .set_property = sti_plane_set_property, 1257 .set_property = drm_atomic_helper_plane_set_property,
1258 .reset = drm_atomic_helper_plane_reset, 1258 .reset = sti_plane_reset,
1259 .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, 1259 .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
1260 .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, 1260 .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
1261 .late_register = sti_hqvdp_late_register, 1261 .late_register = sti_hqvdp_late_register,
diff --git a/drivers/gpu/drm/sti/sti_mixer.c b/drivers/gpu/drm/sti/sti_mixer.c
index 1885c7ab5a8b..7d9aea805eab 100644
--- a/drivers/gpu/drm/sti/sti_mixer.c
+++ b/drivers/gpu/drm/sti/sti_mixer.c
@@ -239,13 +239,10 @@ static void sti_mixer_set_background_area(struct sti_mixer *mixer,
239 239
240int sti_mixer_set_plane_depth(struct sti_mixer *mixer, struct sti_plane *plane) 240int sti_mixer_set_plane_depth(struct sti_mixer *mixer, struct sti_plane *plane)
241{ 241{
242 int plane_id, depth = plane->zorder; 242 int plane_id, depth = plane->drm_plane.state->normalized_zpos;
243 unsigned int i; 243 unsigned int i;
244 u32 mask, val; 244 u32 mask, val;
245 245
246 if ((depth < 1) || (depth > GAM_MIXER_NB_DEPTH_LEVEL))
247 return 1;
248
249 switch (plane->desc) { 246 switch (plane->desc) {
250 case STI_GDP_0: 247 case STI_GDP_0:
251 plane_id = GAM_DEPTH_GDP0_ID; 248 plane_id = GAM_DEPTH_GDP0_ID;
@@ -278,8 +275,8 @@ int sti_mixer_set_plane_depth(struct sti_mixer *mixer, struct sti_plane *plane)
278 break; 275 break;
279 } 276 }
280 277
281 mask |= GAM_DEPTH_MASK_ID << (3 * (depth - 1)); 278 mask |= GAM_DEPTH_MASK_ID << (3 * depth);
282 plane_id = plane_id << (3 * (depth - 1)); 279 plane_id = plane_id << (3 * depth);
283 280
284 DRM_DEBUG_DRIVER("%s %s depth=%d\n", sti_mixer_to_str(mixer), 281 DRM_DEBUG_DRIVER("%s %s depth=%d\n", sti_mixer_to_str(mixer),
285 sti_plane_to_str(plane), depth); 282 sti_plane_to_str(plane), depth);
diff --git a/drivers/gpu/drm/sti/sti_plane.c b/drivers/gpu/drm/sti/sti_plane.c
index 0cf3335ef37c..ca4b3719a64a 100644
--- a/drivers/gpu/drm/sti/sti_plane.c
+++ b/drivers/gpu/drm/sti/sti_plane.c
@@ -14,15 +14,6 @@
14#include "sti_drv.h" 14#include "sti_drv.h"
15#include "sti_plane.h" 15#include "sti_plane.h"
16 16
17/* (Background) < GDP0 < GDP1 < HQVDP0 < GDP2 < GDP3 < (ForeGround) */
18enum sti_plane_desc sti_plane_default_zorder[] = {
19 STI_GDP_0,
20 STI_GDP_1,
21 STI_HQVDP_0,
22 STI_GDP_2,
23 STI_GDP_3,
24};
25
26const char *sti_plane_to_str(struct sti_plane *plane) 17const char *sti_plane_to_str(struct sti_plane *plane)
27{ 18{
28 switch (plane->desc) { 19 switch (plane->desc) {
@@ -96,59 +87,46 @@ void sti_plane_update_fps(struct sti_plane *plane,
96 plane->fps_info.fips_str); 87 plane->fps_info.fips_str);
97} 88}
98 89
99int sti_plane_set_property(struct drm_plane *drm_plane, 90static int sti_plane_get_default_zpos(enum drm_plane_type type)
100 struct drm_property *property,
101 uint64_t val)
102{ 91{
103 struct drm_device *dev = drm_plane->dev; 92 switch (type) {
104 struct sti_private *private = dev->dev_private; 93 case DRM_PLANE_TYPE_PRIMARY:
105 struct sti_plane *plane = to_sti_plane(drm_plane);
106
107 DRM_DEBUG_DRIVER("\n");
108
109 if (property == private->plane_zorder_property) {
110 plane->zorder = val;
111 return 0; 94 return 0;
95 case DRM_PLANE_TYPE_OVERLAY:
96 return 1;
97 case DRM_PLANE_TYPE_CURSOR:
98 return 7;
112 } 99 }
100 return 0;
101}
113 102
114 return -EINVAL; 103void sti_plane_reset(struct drm_plane *plane)
104{
105 drm_atomic_helper_plane_reset(plane);
106 plane->state->zpos = sti_plane_get_default_zpos(plane->type);
115} 107}
116 108
117static void sti_plane_attach_zorder_property(struct drm_plane *drm_plane) 109static void sti_plane_attach_zorder_property(struct drm_plane *drm_plane,
110 enum drm_plane_type type)
118{ 111{
119 struct drm_device *dev = drm_plane->dev; 112 int zpos = sti_plane_get_default_zpos(type);
120 struct sti_private *private = dev->dev_private; 113
121 struct sti_plane *plane = to_sti_plane(drm_plane); 114 switch (type) {
122 struct drm_property *prop; 115 case DRM_PLANE_TYPE_PRIMARY:
123 116 case DRM_PLANE_TYPE_OVERLAY:
124 prop = private->plane_zorder_property; 117 drm_plane_create_zpos_property(drm_plane, zpos, 0, 6);
125 if (!prop) { 118 break;
126 prop = drm_property_create_range(dev, 0, "zpos", 1, 119 case DRM_PLANE_TYPE_CURSOR:
127 GAM_MIXER_NB_DEPTH_LEVEL); 120 drm_plane_create_zpos_immutable_property(drm_plane, zpos);
128 if (!prop) 121 break;
129 return;
130
131 private->plane_zorder_property = prop;
132 } 122 }
133
134 drm_object_attach_property(&drm_plane->base, prop, plane->zorder);
135} 123}
136 124
137void sti_plane_init_property(struct sti_plane *plane, 125void sti_plane_init_property(struct sti_plane *plane,
138 enum drm_plane_type type) 126 enum drm_plane_type type)
139{ 127{
140 unsigned int i; 128 sti_plane_attach_zorder_property(&plane->drm_plane, type);
141
142 for (i = 0; i < ARRAY_SIZE(sti_plane_default_zorder); i++)
143 if (sti_plane_default_zorder[i] == plane->desc)
144 break;
145
146 plane->zorder = i + 1;
147
148 if (type == DRM_PLANE_TYPE_OVERLAY)
149 sti_plane_attach_zorder_property(&plane->drm_plane);
150 129
151 DRM_DEBUG_DRIVER("drm plane:%d mapped to %s with zorder:%d\n", 130 DRM_DEBUG_DRIVER("drm plane:%d mapped to %s\n",
152 plane->drm_plane.base.id, 131 plane->drm_plane.base.id, sti_plane_to_str(plane));
153 sti_plane_to_str(plane), plane->zorder);
154} 132}
diff --git a/drivers/gpu/drm/sti/sti_plane.h b/drivers/gpu/drm/sti/sti_plane.h
index e0ea1dd3bb88..ce3e8d6c88bb 100644
--- a/drivers/gpu/drm/sti/sti_plane.h
+++ b/drivers/gpu/drm/sti/sti_plane.h
@@ -66,14 +66,12 @@ struct sti_fps_info {
66 * @plane: drm plane it is bound to (if any) 66 * @plane: drm plane it is bound to (if any)
67 * @desc: plane type & id 67 * @desc: plane type & id
68 * @status: to know the status of the plane 68 * @status: to know the status of the plane
69 * @zorder: plane z-order
70 * @fps_info: frame per second info 69 * @fps_info: frame per second info
71 */ 70 */
72struct sti_plane { 71struct sti_plane {
73 struct drm_plane drm_plane; 72 struct drm_plane drm_plane;
74 enum sti_plane_desc desc; 73 enum sti_plane_desc desc;
75 enum sti_plane_status status; 74 enum sti_plane_status status;
76 int zorder;
77 struct sti_fps_info fps_info; 75 struct sti_fps_info fps_info;
78}; 76};
79 77
@@ -82,10 +80,7 @@ void sti_plane_update_fps(struct sti_plane *plane,
82 bool new_frame, 80 bool new_frame,
83 bool new_field); 81 bool new_field);
84 82
85int sti_plane_set_property(struct drm_plane *drm_plane,
86 struct drm_property *property,
87 uint64_t val);
88
89void sti_plane_init_property(struct sti_plane *plane, 83void sti_plane_init_property(struct sti_plane *plane,
90 enum drm_plane_type type); 84 enum drm_plane_type type);
85void sti_plane_reset(struct drm_plane *plane);
91#endif 86#endif
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 3edeaf88ebc0..44e070800b6d 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -308,6 +308,7 @@ struct drm_plane_helper_funcs;
308 * @mode_changed: crtc_state->mode or crtc_state->enable has been changed 308 * @mode_changed: crtc_state->mode or crtc_state->enable has been changed
309 * @active_changed: crtc_state->active has been toggled. 309 * @active_changed: crtc_state->active has been toggled.
310 * @connectors_changed: connectors to this crtc have been updated 310 * @connectors_changed: connectors to this crtc have been updated
311 * @zpos_changed: zpos values of planes on this crtc have been updated
311 * @color_mgmt_changed: color management properties have changed (degamma or 312 * @color_mgmt_changed: color management properties have changed (degamma or
312 * gamma LUT or CSC matrix) 313 * gamma LUT or CSC matrix)
313 * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes 314 * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes
@@ -344,6 +345,7 @@ struct drm_crtc_state {
344 bool mode_changed : 1; 345 bool mode_changed : 1;
345 bool active_changed : 1; 346 bool active_changed : 1;
346 bool connectors_changed : 1; 347 bool connectors_changed : 1;
348 bool zpos_changed : 1;
347 bool color_mgmt_changed : 1; 349 bool color_mgmt_changed : 1;
348 350
349 /* attached planes bitmask: 351 /* attached planes bitmask:
@@ -1409,6 +1411,9 @@ struct drm_connector {
1409 * @src_w: width of visible portion of plane (in 16.16) 1411 * @src_w: width of visible portion of plane (in 16.16)
1410 * @src_h: height of visible portion of plane (in 16.16) 1412 * @src_h: height of visible portion of plane (in 16.16)
1411 * @rotation: rotation of the plane 1413 * @rotation: rotation of the plane
1414 * @zpos: priority of the given plane on crtc (optional)
1415 * @normalized_zpos: normalized value of zpos: unique, range from 0 to N-1
1416 * where N is the number of active planes for given crtc
1412 * @state: backpointer to global drm_atomic_state 1417 * @state: backpointer to global drm_atomic_state
1413 */ 1418 */
1414struct drm_plane_state { 1419struct drm_plane_state {
@@ -1429,6 +1434,10 @@ struct drm_plane_state {
1429 /* Plane rotation */ 1434 /* Plane rotation */
1430 unsigned int rotation; 1435 unsigned int rotation;
1431 1436
1437 /* Plane zpos */
1438 unsigned int zpos;
1439 unsigned int normalized_zpos;
1440
1432 struct drm_atomic_state *state; 1441 struct drm_atomic_state *state;
1433}; 1442};
1434 1443
@@ -1688,6 +1697,7 @@ enum drm_plane_type {
1688 * @properties: property tracking for this plane 1697 * @properties: property tracking for this plane
1689 * @type: type of plane (overlay, primary, cursor) 1698 * @type: type of plane (overlay, primary, cursor)
1690 * @state: current atomic state for this plane 1699 * @state: current atomic state for this plane
1700 * @zpos_property: zpos property for this plane
1691 * @helper_private: mid-layer private data 1701 * @helper_private: mid-layer private data
1692 */ 1702 */
1693struct drm_plane { 1703struct drm_plane {
@@ -1732,6 +1742,8 @@ struct drm_plane {
1732 const struct drm_plane_helper_funcs *helper_private; 1742 const struct drm_plane_helper_funcs *helper_private;
1733 1743
1734 struct drm_plane_state *state; 1744 struct drm_plane_state *state;
1745
1746 struct drm_property *zpos_property;
1735}; 1747};
1736 1748
1737/** 1749/**
@@ -2958,6 +2970,14 @@ extern void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
2958 uint degamma_lut_size, 2970 uint degamma_lut_size,
2959 bool has_ctm, 2971 bool has_ctm,
2960 uint gamma_lut_size); 2972 uint gamma_lut_size);
2973
2974int drm_plane_create_zpos_property(struct drm_plane *plane,
2975 unsigned int zpos,
2976 unsigned int min, unsigned int max);
2977
2978int drm_plane_create_zpos_immutable_property(struct drm_plane *plane,
2979 unsigned int zpos);
2980
2961/* Helpers */ 2981/* Helpers */
2962struct drm_mode_object *drm_mode_object_find(struct drm_device *dev, 2982struct drm_mode_object *drm_mode_object_find(struct drm_device *dev,
2963 uint32_t id, uint32_t type); 2983 uint32_t id, uint32_t type);