2 * Copyright (C) STMicroelectronics SA 2014
3 * Authors: Benjamin Gaignard <benjamin.gaignard@st.com>
4 * Fabien Dessenne <fabien.dessenne@st.com>
5 * for STMicroelectronics.
6 * License terms: GNU General Public License (GPL), version 2
10 #include <drm/drm_fb_cma_helper.h>
11 #include <drm/drm_gem_cma_helper.h>
13 #include "sti_compositor.h"
15 #include "sti_plane.h"
17 /* (Background) < GDP0 < GDP1 < HQVDP0 < GDP2 < GDP3 < (ForeGround) */
18 enum sti_plane_desc sti_plane_default_zorder[] = {
26 const char *sti_plane_to_str(struct sti_plane *plane)
28 switch (plane->desc) {
42 return "<UNKNOWN PLANE>";
45 EXPORT_SYMBOL(sti_plane_to_str);
47 static void sti_plane_destroy(struct drm_plane *drm_plane)
49 DRM_DEBUG_DRIVER("\n");
51 drm_plane_helper_disable(drm_plane);
52 drm_plane_cleanup(drm_plane);
55 static int sti_plane_set_property(struct drm_plane *drm_plane,
56 struct drm_property *property,
59 struct drm_device *dev = drm_plane->dev;
60 struct sti_private *private = dev->dev_private;
61 struct sti_plane *plane = to_sti_plane(drm_plane);
63 DRM_DEBUG_DRIVER("\n");
65 if (property == private->plane_zorder_property) {
73 static void sti_plane_attach_zorder_property(struct drm_plane *drm_plane)
75 struct drm_device *dev = drm_plane->dev;
76 struct sti_private *private = dev->dev_private;
77 struct sti_plane *plane = to_sti_plane(drm_plane);
78 struct drm_property *prop;
80 prop = private->plane_zorder_property;
82 prop = drm_property_create_range(dev, 0, "zpos", 1,
83 GAM_MIXER_NB_DEPTH_LEVEL);
87 private->plane_zorder_property = prop;
90 drm_object_attach_property(&drm_plane->base, prop, plane->zorder);
93 void sti_plane_init_property(struct sti_plane *plane,
94 enum drm_plane_type type)
98 for (i = 0; i < ARRAY_SIZE(sti_plane_default_zorder); i++)
99 if (sti_plane_default_zorder[i] == plane->desc)
102 plane->zorder = i + 1;
104 if (type == DRM_PLANE_TYPE_OVERLAY)
105 sti_plane_attach_zorder_property(&plane->drm_plane);
107 DRM_DEBUG_DRIVER("drm plane:%d mapped to %s with zorder:%d\n",
108 plane->drm_plane.base.id,
109 sti_plane_to_str(plane), plane->zorder);
111 EXPORT_SYMBOL(sti_plane_init_property);
113 struct drm_plane_funcs sti_plane_helpers_funcs = {
114 .update_plane = drm_atomic_helper_update_plane,
115 .disable_plane = drm_atomic_helper_disable_plane,
116 .destroy = sti_plane_destroy,
117 .set_property = sti_plane_set_property,
118 .reset = drm_atomic_helper_plane_reset,
119 .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
120 .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
122 EXPORT_SYMBOL(sti_plane_helpers_funcs);