Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'drm-for-v4.8-zpos' of git://people.freedesktop.org/~airlied/linux

Pull drm zpos property support from Dave Airlie:
"This tree was waiting on some media stuff I hadn't had time to get a
stable branchpoint off, so I just waited until it was all in your tree
first.

It's been around a bit on the list and shouldn't affect anything
outside adding the generic API and moving some ARM drivers to using
it"

* tag 'drm-for-v4.8-zpos' of git://people.freedesktop.org/~airlied/linux:
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

+333 -155
+1
Documentation/gpu/kms-properties.csv
··· 17 17 ,,“CRTC_H”,RANGE,"Min=0, Max=UINT_MAX",Plane,Scanout CRTC (destination) height (atomic) 18 18 ,,“FB_ID”,OBJECT,DRM_MODE_OBJECT_FB,Plane,Scanout framebuffer (atomic) 19 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 21 ,DVI-I,“subconnector”,ENUM,"{ “Unknown”, “DVI-D”, “DVI-A” }",Connector,TBD 21 22 ,,“select subconnector”,ENUM,"{ “Automatic”, “DVI-D”, “DVI-A” }",Connector,TBD 22 23 ,TV,“subconnector”,ENUM,"{ ""Unknown"", ""Composite"", ""SVIDEO"", ""Component"", ""SCART"" }",Connector,TBD
+1 -1
drivers/gpu/drm/Makefile
··· 24 24 drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_probe_helper.o \ 25 25 drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o \ 26 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 29 29 drm_kms_helper-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o 30 30 drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o
+4
drivers/gpu/drm/drm_atomic.c
··· 711 711 state->src_h = val; 712 712 } else if (property == config->rotation_property) { 713 713 state->rotation = val; 714 + } else if (property == plane->zpos_property) { 715 + state->zpos = val; 714 716 } else if (plane->funcs->atomic_set_property) { 715 717 return plane->funcs->atomic_set_property(plane, state, 716 718 property, val); ··· 769 767 *val = state->src_h; 770 768 } else if (property == config->rotation_property) { 771 769 *val = state->rotation; 770 + } else if (property == plane->zpos_property) { 771 + *val = state->zpos; 772 772 } else if (plane->funcs->atomic_get_property) { 773 773 return plane->funcs->atomic_get_property(plane, state, property, val); 774 774 } else {
+7
drivers/gpu/drm/drm_atomic_helper.c
··· 32 32 #include <drm/drm_atomic_helper.h> 33 33 #include <linux/fence.h> 34 34 35 + #include "drm_crtc_internal.h" 36 + 35 37 /** 36 38 * DOC: overview 37 39 * ··· 593 591 struct drm_plane *plane; 594 592 struct drm_plane_state *plane_state; 595 593 int i, ret = 0; 594 + 595 + ret = drm_atomic_helper_normalize_zpos(dev, state); 596 + if (ret) 597 + return ret; 596 598 597 599 for_each_plane_in_state(state, plane, plane_state, i) { 598 600 const struct drm_plane_helper_funcs *funcs; ··· 2961 2955 state->planes_changed = false; 2962 2956 state->connectors_changed = false; 2963 2957 state->color_mgmt_changed = false; 2958 + state->zpos_changed = false; 2964 2959 state->event = NULL; 2965 2960 } 2966 2961 EXPORT_SYMBOL(__drm_atomic_helper_crtc_duplicate_state);
+238
drivers/gpu/drm/drm_blend.c
··· 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 + */ 59 + int 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 + } 80 + EXPORT_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 + */ 96 + int 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 + } 117 + EXPORT_SYMBOL(drm_plane_create_zpos_immutable_property); 118 + 119 + static 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 + */ 144 + static 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 + 190 + done: 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 + */ 208 + int 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 + }
+4
drivers/gpu/drm/drm_crtc_internal.h
··· 128 128 129 129 int drm_modeset_register_all(struct drm_device *dev); 130 130 void drm_modeset_unregister_all(struct drm_device *dev); 131 + 132 + /* drm_blend.c */ 133 + int drm_atomic_helper_normalize_zpos(struct drm_device *dev, 134 + struct drm_atomic_state *state);
-2
drivers/gpu/drm/exynos/exynos_drm_drv.h
··· 64 64 struct exynos_drm_rect src; 65 65 unsigned int h_ratio; 66 66 unsigned int v_ratio; 67 - unsigned int zpos; 68 67 }; 69 68 70 69 static inline struct exynos_drm_plane_state * ··· 220 221 * this array is used to be aware of which crtc did it request vblank. 221 222 */ 222 223 struct drm_crtc *crtc[MAX_CRTC]; 223 - struct drm_property *plane_zpos_property; 224 224 225 225 struct device *dma_dev; 226 226 void *mapping;
+9 -58
drivers/gpu/drm/exynos/exynos_drm_plane.c
··· 139 139 140 140 exynos_state = kzalloc(sizeof(*exynos_state), GFP_KERNEL); 141 141 if (exynos_state) { 142 - exynos_state->zpos = exynos_plane->config->zpos; 143 142 plane->state = &exynos_state->base; 144 143 plane->state->plane = plane; 144 + plane->state->zpos = exynos_plane->config->zpos; 145 145 } 146 146 } 147 147 ··· 157 157 return NULL; 158 158 159 159 __drm_atomic_helper_plane_duplicate_state(plane, &copy->base); 160 - copy->zpos = exynos_state->zpos; 161 160 return &copy->base; 162 161 } 163 162 ··· 169 170 kfree(old_exynos_state); 170 171 } 171 172 172 - static int exynos_drm_plane_atomic_set_property(struct drm_plane *plane, 173 - struct drm_plane_state *state, 174 - struct drm_property *property, 175 - uint64_t val) 176 - { 177 - struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane); 178 - struct exynos_drm_plane_state *exynos_state = 179 - to_exynos_plane_state(state); 180 - struct exynos_drm_private *dev_priv = plane->dev->dev_private; 181 - const struct exynos_drm_plane_config *config = exynos_plane->config; 182 - 183 - if (property == dev_priv->plane_zpos_property && 184 - (config->capabilities & EXYNOS_DRM_PLANE_CAP_ZPOS)) 185 - exynos_state->zpos = val; 186 - else 187 - return -EINVAL; 188 - 189 - return 0; 190 - } 191 - 192 - static int exynos_drm_plane_atomic_get_property(struct drm_plane *plane, 193 - const struct drm_plane_state *state, 194 - struct drm_property *property, 195 - uint64_t *val) 196 - { 197 - const struct exynos_drm_plane_state *exynos_state = 198 - container_of(state, const struct exynos_drm_plane_state, base); 199 - struct exynos_drm_private *dev_priv = plane->dev->dev_private; 200 - 201 - if (property == dev_priv->plane_zpos_property) 202 - *val = exynos_state->zpos; 203 - else 204 - return -EINVAL; 205 - 206 - return 0; 207 - } 208 - 209 173 static struct drm_plane_funcs exynos_plane_funcs = { 210 174 .update_plane = drm_atomic_helper_update_plane, 211 175 .disable_plane = drm_atomic_helper_disable_plane, ··· 177 215 .reset = exynos_drm_plane_reset, 178 216 .atomic_duplicate_state = exynos_drm_plane_duplicate_state, 179 217 .atomic_destroy_state = exynos_drm_plane_destroy_state, 180 - .atomic_set_property = exynos_drm_plane_atomic_set_property, 181 - .atomic_get_property = exynos_drm_plane_atomic_get_property, 182 218 }; 183 219 184 220 static int ··· 264 304 }; 265 305 266 306 static void exynos_plane_attach_zpos_property(struct drm_plane *plane, 267 - unsigned int zpos) 307 + bool immutable) 268 308 { 269 - struct drm_device *dev = plane->dev; 270 - struct exynos_drm_private *dev_priv = dev->dev_private; 271 - struct drm_property *prop; 272 - 273 - prop = dev_priv->plane_zpos_property; 274 - if (!prop) { 275 - prop = drm_property_create_range(dev, 0, "zpos", 276 - 0, MAX_PLANE - 1); 277 - if (!prop) 278 - return; 279 - 280 - dev_priv->plane_zpos_property = prop; 281 - } 282 - 283 - drm_object_attach_property(&plane->base, prop, zpos); 309 + /* FIXME */ 310 + if (immutable) 311 + drm_plane_create_zpos_immutable_property(plane, 0); 312 + else 313 + drm_plane_create_zpos_property(plane, 0, 0, MAX_PLANE - 1); 284 314 } 285 315 286 316 int exynos_plane_init(struct drm_device *dev, ··· 296 346 exynos_plane->index = index; 297 347 exynos_plane->config = config; 298 348 299 - exynos_plane_attach_zpos_property(&exynos_plane->base, config->zpos); 349 + exynos_plane_attach_zpos_property(&exynos_plane->base, 350 + !(config->capabilities & EXYNOS_DRM_PLANE_CAP_ZPOS)); 300 351 301 352 return 0; 302 353 }
+4 -2
drivers/gpu/drm/exynos/exynos_mixer.c
··· 477 477 struct drm_display_mode *mode = &state->base.crtc->state->adjusted_mode; 478 478 struct mixer_resources *res = &ctx->mixer_res; 479 479 struct drm_framebuffer *fb = state->base.fb; 480 + unsigned int priority = state->base.normalized_zpos + 1; 480 481 unsigned long flags; 481 482 dma_addr_t luma_addr[2], chroma_addr[2]; 482 483 bool tiled_mode = false; ··· 562 561 563 562 mixer_cfg_scan(ctx, mode->vdisplay); 564 563 mixer_cfg_rgb_fmt(ctx, mode->vdisplay); 565 - mixer_cfg_layer(ctx, plane->index, state->zpos + 1, true); 564 + mixer_cfg_layer(ctx, plane->index, priority, true); 566 565 mixer_cfg_vp_blend(ctx); 567 566 mixer_run(ctx); 568 567 ··· 587 586 struct drm_display_mode *mode = &state->base.crtc->state->adjusted_mode; 588 587 struct mixer_resources *res = &ctx->mixer_res; 589 588 struct drm_framebuffer *fb = state->base.fb; 589 + unsigned int priority = state->base.normalized_zpos + 1; 590 590 unsigned long flags; 591 591 unsigned int win = plane->index; 592 592 unsigned int x_ratio = 0, y_ratio = 0; ··· 679 677 680 678 mixer_cfg_scan(ctx, mode->vdisplay); 681 679 mixer_cfg_rgb_fmt(ctx, mode->vdisplay); 682 - mixer_cfg_layer(ctx, win, state->zpos + 1, true); 680 + mixer_cfg_layer(ctx, win, priority, true); 683 681 mixer_cfg_gfx_blend(ctx, win, is_alpha_format(fb->pixel_format)); 684 682 685 683 /* layer update mandatory for mixer 16.0.33.0 */
+1 -1
drivers/gpu/drm/rcar-du/rcar_du_crtc.c
··· 196 196 197 197 static 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 202 202 static const struct rcar_du_format_info *
-1
drivers/gpu/drm/rcar-du/rcar_du_drv.h
··· 92 92 struct { 93 93 struct drm_property *alpha; 94 94 struct drm_property *colorkey; 95 - struct drm_property *zpos; 96 95 } props; 97 96 98 97 unsigned int dpad0_source;
-5
drivers/gpu/drm/rcar-du/rcar_du_kms.c
··· 527 527 if (rcdu->props.colorkey == NULL) 528 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 530 return 0; 536 531 } 537 532
+2 -7
drivers/gpu/drm/rcar-du/rcar_du_plane.c
··· 652 652 state->source = RCAR_DU_PLANE_MEMORY; 653 653 state->alpha = 255; 654 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 657 plane->state = &state->state; 658 658 plane->state->plane = plane; ··· 670 670 rstate->alpha = val; 671 671 else if (property == rcdu->props.colorkey) 672 672 rstate->colorkey = val; 673 - else if (property == rcdu->props.zpos) 674 - rstate->zpos = val; 675 673 else 676 674 return -EINVAL; 677 675 ··· 688 690 *val = rstate->alpha; 689 691 else if (property == rcdu->props.colorkey) 690 692 *val = rstate->colorkey; 691 - else if (property == rcdu->props.zpos) 692 - *val = rstate->zpos; 693 693 else 694 694 return -EINVAL; 695 695 ··· 759 763 drm_object_attach_property(&plane->plane.base, 760 764 rcdu->props.colorkey, 761 765 RCAR_DU_COLORKEY_NONE); 762 - drm_object_attach_property(&plane->plane.base, 763 - rcdu->props.zpos, 1); 766 + drm_plane_create_zpos_property(&plane->plane, 1, 1, 7); 764 767 } 765 768 766 769 return 0;
-2
drivers/gpu/drm/rcar-du/rcar_du_plane.h
··· 51 51 * @hwindex: 0-based hardware plane index, -1 means unused 52 52 * @alpha: value of the plane alpha property 53 53 * @colorkey: value of the plane colorkey property 54 - * @zpos: value of the plane zpos property 55 54 */ 56 55 struct rcar_du_plane_state { 57 56 struct drm_plane_state state; ··· 61 62 62 63 unsigned int alpha; 63 64 unsigned int colorkey; 64 - unsigned int zpos; 65 65 }; 66 66 67 67 static inline struct rcar_du_plane_state *
+5 -9
drivers/gpu/drm/rcar-du/rcar_du_vsp.c
··· 43 43 .src_y = 0, 44 44 .src_w = mode->hdisplay << 16, 45 45 .src_h = mode->vdisplay << 16, 46 + .zpos = 0, 46 47 }, 47 48 .format = rcar_du_format_info(DRM_FORMAT_ARGB8888), 48 49 .source = RCAR_DU_PLANE_VSPD1, 49 50 .alpha = 255, 50 51 .colorkey = 0, 51 - .zpos = 0, 52 52 }; 53 53 54 54 if (rcdu->info->gen >= 3) ··· 152 152 .pixelformat = 0, 153 153 .pitch = fb->pitches[0], 154 154 .alpha = state->alpha, 155 - .zpos = state->zpos, 155 + .zpos = state->state.zpos, 156 156 }; 157 157 unsigned int i; 158 158 ··· 267 267 return; 268 268 269 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 272 plane->state = &state->state; 273 273 plane->state->plane = plane; ··· 282 282 283 283 if (property == rcdu->props.alpha) 284 284 rstate->alpha = val; 285 - else if (property == rcdu->props.zpos) 286 - rstate->zpos = val; 287 285 else 288 286 return -EINVAL; 289 287 ··· 298 300 299 301 if (property == rcdu->props.alpha) 300 302 *val = rstate->alpha; 301 - else if (property == rcdu->props.zpos) 302 - *val = rstate->zpos; 303 303 else 304 304 return -EINVAL; 305 305 ··· 377 381 378 382 drm_object_attach_property(&plane->plane.base, 379 383 rcdu->props.alpha, 255); 380 - drm_object_attach_property(&plane->plane.base, 381 - rcdu->props.zpos, 1); 384 + drm_plane_create_zpos_property(&plane->plane, 1, 1, 385 + vsp->num_planes - 1); 382 386 } 383 387 384 388 return 0;
+2 -2
drivers/gpu/drm/sti/sti_cursor.c
··· 349 349 .update_plane = drm_atomic_helper_update_plane, 350 350 .disable_plane = drm_atomic_helper_disable_plane, 351 351 .destroy = sti_cursor_destroy, 352 - .set_property = sti_plane_set_property, 353 - .reset = drm_atomic_helper_plane_reset, 352 + .set_property = drm_atomic_helper_plane_set_property, 353 + .reset = sti_plane_reset, 354 354 .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, 355 355 .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, 356 356 .late_register = sti_cursor_late_register,
+2 -2
drivers/gpu/drm/sti/sti_gdp.c
··· 886 886 .update_plane = drm_atomic_helper_update_plane, 887 887 .disable_plane = drm_atomic_helper_disable_plane, 888 888 .destroy = sti_gdp_destroy, 889 - .set_property = sti_plane_set_property, 890 - .reset = drm_atomic_helper_plane_reset, 889 + .set_property = drm_atomic_helper_plane_set_property, 890 + .reset = sti_plane_reset, 891 891 .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, 892 892 .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, 893 893 .late_register = sti_gdp_late_register,
+2 -2
drivers/gpu/drm/sti/sti_hqvdp.c
··· 1254 1254 .update_plane = drm_atomic_helper_update_plane, 1255 1255 .disable_plane = drm_atomic_helper_disable_plane, 1256 1256 .destroy = sti_hqvdp_destroy, 1257 - .set_property = sti_plane_set_property, 1258 - .reset = drm_atomic_helper_plane_reset, 1257 + .set_property = drm_atomic_helper_plane_set_property, 1258 + .reset = sti_plane_reset, 1259 1259 .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, 1260 1260 .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, 1261 1261 .late_register = sti_hqvdp_late_register,
+3 -6
drivers/gpu/drm/sti/sti_mixer.c
··· 239 239 240 240 int 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 243 unsigned int i; 244 244 u32 mask, val; 245 - 246 - if ((depth < 1) || (depth > GAM_MIXER_NB_DEPTH_LEVEL)) 247 - return 1; 248 245 249 246 switch (plane->desc) { 250 247 case STI_GDP_0: ··· 275 278 break; 276 279 } 277 280 278 - mask |= GAM_DEPTH_MASK_ID << (3 * (depth - 1)); 279 - plane_id = plane_id << (3 * (depth - 1)); 281 + mask |= GAM_DEPTH_MASK_ID << (3 * depth); 282 + plane_id = plane_id << (3 * depth); 280 283 281 284 DRM_DEBUG_DRIVER("%s %s depth=%d\n", sti_mixer_to_str(mixer), 282 285 sti_plane_to_str(plane), depth);
+27 -49
drivers/gpu/drm/sti/sti_plane.c
··· 14 14 #include "sti_drv.h" 15 15 #include "sti_plane.h" 16 16 17 - /* (Background) < GDP0 < GDP1 < HQVDP0 < GDP2 < GDP3 < (ForeGround) */ 18 - enum 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 - 26 17 const char *sti_plane_to_str(struct sti_plane *plane) 27 18 { 28 19 switch (plane->desc) { ··· 87 96 plane->fps_info.fips_str); 88 97 } 89 98 90 - int sti_plane_set_property(struct drm_plane *drm_plane, 91 - struct drm_property *property, 92 - uint64_t val) 99 + static int sti_plane_get_default_zpos(enum drm_plane_type type) 93 100 { 94 - struct drm_device *dev = drm_plane->dev; 95 - struct sti_private *private = dev->dev_private; 96 - struct sti_plane *plane = to_sti_plane(drm_plane); 97 - 98 - DRM_DEBUG_DRIVER("\n"); 99 - 100 - if (property == private->plane_zorder_property) { 101 - plane->zorder = val; 101 + switch (type) { 102 + case DRM_PLANE_TYPE_PRIMARY: 102 103 return 0; 104 + case DRM_PLANE_TYPE_OVERLAY: 105 + return 1; 106 + case DRM_PLANE_TYPE_CURSOR: 107 + return 7; 103 108 } 104 - 105 - return -EINVAL; 109 + return 0; 106 110 } 107 111 108 - static void sti_plane_attach_zorder_property(struct drm_plane *drm_plane) 112 + void sti_plane_reset(struct drm_plane *plane) 109 113 { 110 - struct drm_device *dev = drm_plane->dev; 111 - struct sti_private *private = dev->dev_private; 112 - struct sti_plane *plane = to_sti_plane(drm_plane); 113 - struct drm_property *prop; 114 + drm_atomic_helper_plane_reset(plane); 115 + plane->state->zpos = sti_plane_get_default_zpos(plane->type); 116 + } 114 117 115 - prop = private->plane_zorder_property; 116 - if (!prop) { 117 - prop = drm_property_create_range(dev, 0, "zpos", 1, 118 - GAM_MIXER_NB_DEPTH_LEVEL); 119 - if (!prop) 120 - return; 118 + static void sti_plane_attach_zorder_property(struct drm_plane *drm_plane, 119 + enum drm_plane_type type) 120 + { 121 + int zpos = sti_plane_get_default_zpos(type); 121 122 122 - private->plane_zorder_property = prop; 123 + switch (type) { 124 + case DRM_PLANE_TYPE_PRIMARY: 125 + case DRM_PLANE_TYPE_OVERLAY: 126 + drm_plane_create_zpos_property(drm_plane, zpos, 0, 6); 127 + break; 128 + case DRM_PLANE_TYPE_CURSOR: 129 + drm_plane_create_zpos_immutable_property(drm_plane, zpos); 130 + break; 123 131 } 124 - 125 - drm_object_attach_property(&drm_plane->base, prop, plane->zorder); 126 132 } 127 133 128 134 void sti_plane_init_property(struct sti_plane *plane, 129 135 enum drm_plane_type type) 130 136 { 131 - unsigned int i; 137 + sti_plane_attach_zorder_property(&plane->drm_plane, type); 132 138 133 - for (i = 0; i < ARRAY_SIZE(sti_plane_default_zorder); i++) 134 - if (sti_plane_default_zorder[i] == plane->desc) 135 - break; 136 - 137 - plane->zorder = i + 1; 138 - 139 - if (type == DRM_PLANE_TYPE_OVERLAY) 140 - sti_plane_attach_zorder_property(&plane->drm_plane); 141 - 142 - DRM_DEBUG_DRIVER("drm plane:%d mapped to %s with zorder:%d\n", 143 - plane->drm_plane.base.id, 144 - sti_plane_to_str(plane), plane->zorder); 139 + DRM_DEBUG_DRIVER("drm plane:%d mapped to %s\n", 140 + plane->drm_plane.base.id, sti_plane_to_str(plane)); 145 141 }
+1 -6
drivers/gpu/drm/sti/sti_plane.h
··· 66 66 * @plane: drm plane it is bound to (if any) 67 67 * @desc: plane type & id 68 68 * @status: to know the status of the plane 69 - * @zorder: plane z-order 70 69 * @fps_info: frame per second info 71 70 */ 72 71 struct sti_plane { 73 72 struct drm_plane drm_plane; 74 73 enum sti_plane_desc desc; 75 74 enum sti_plane_status status; 76 - int zorder; 77 75 struct sti_fps_info fps_info; 78 76 }; 79 77 ··· 80 82 bool new_frame, 81 83 bool new_field); 82 84 83 - int sti_plane_set_property(struct drm_plane *drm_plane, 84 - struct drm_property *property, 85 - uint64_t val); 86 - 87 85 void sti_plane_init_property(struct sti_plane *plane, 88 86 enum drm_plane_type type); 87 + void sti_plane_reset(struct drm_plane *plane); 89 88 #endif
+20
include/drm/drm_crtc.h
··· 308 308 * @mode_changed: crtc_state->mode or crtc_state->enable has been changed 309 309 * @active_changed: crtc_state->active has been toggled. 310 310 * @connectors_changed: connectors to this crtc have been updated 311 + * @zpos_changed: zpos values of planes on this crtc have been updated 311 312 * @color_mgmt_changed: color management properties have changed (degamma or 312 313 * gamma LUT or CSC matrix) 313 314 * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes ··· 345 344 bool mode_changed : 1; 346 345 bool active_changed : 1; 347 346 bool connectors_changed : 1; 347 + bool zpos_changed : 1; 348 348 bool color_mgmt_changed : 1; 349 349 350 350 /* attached planes bitmask: ··· 1411 1409 * @src_w: width of visible portion of plane (in 16.16) 1412 1410 * @src_h: height of visible portion of plane (in 16.16) 1413 1411 * @rotation: rotation of the plane 1412 + * @zpos: priority of the given plane on crtc (optional) 1413 + * @normalized_zpos: normalized value of zpos: unique, range from 0 to N-1 1414 + * where N is the number of active planes for given crtc 1414 1415 * @state: backpointer to global drm_atomic_state 1415 1416 */ 1416 1417 struct drm_plane_state { ··· 1433 1428 1434 1429 /* Plane rotation */ 1435 1430 unsigned int rotation; 1431 + 1432 + /* Plane zpos */ 1433 + unsigned int zpos; 1434 + unsigned int normalized_zpos; 1436 1435 1437 1436 struct drm_atomic_state *state; 1438 1437 }; ··· 1697 1688 * @properties: property tracking for this plane 1698 1689 * @type: type of plane (overlay, primary, cursor) 1699 1690 * @state: current atomic state for this plane 1691 + * @zpos_property: zpos property for this plane 1700 1692 * @helper_private: mid-layer private data 1701 1693 */ 1702 1694 struct drm_plane { ··· 1742 1732 const struct drm_plane_helper_funcs *helper_private; 1743 1733 1744 1734 struct drm_plane_state *state; 1735 + 1736 + struct drm_property *zpos_property; 1745 1737 }; 1746 1738 1747 1739 /** ··· 2970 2958 uint degamma_lut_size, 2971 2959 bool has_ctm, 2972 2960 uint gamma_lut_size); 2961 + 2962 + int drm_plane_create_zpos_property(struct drm_plane *plane, 2963 + unsigned int zpos, 2964 + unsigned int min, unsigned int max); 2965 + 2966 + int drm_plane_create_zpos_immutable_property(struct drm_plane *plane, 2967 + unsigned int zpos); 2968 + 2973 2969 /* Helpers */ 2974 2970 struct drm_mode_object *drm_mode_object_find(struct drm_device *dev, 2975 2971 uint32_t id, uint32_t type);