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>";
46 static void sti_plane_destroy(struct drm_plane
*drm_plane
)
48 DRM_DEBUG_DRIVER("\n");
50 drm_plane_helper_disable(drm_plane
);
51 drm_plane_cleanup(drm_plane
);
54 static int sti_plane_set_property(struct drm_plane
*drm_plane
,
55 struct drm_property
*property
,
58 struct drm_device
*dev
= drm_plane
->dev
;
59 struct sti_private
*private = dev
->dev_private
;
60 struct sti_plane
*plane
= to_sti_plane(drm_plane
);
62 DRM_DEBUG_DRIVER("\n");
64 if (property
== private->plane_zorder_property
) {
72 static void sti_plane_attach_zorder_property(struct drm_plane
*drm_plane
)
74 struct drm_device
*dev
= drm_plane
->dev
;
75 struct sti_private
*private = dev
->dev_private
;
76 struct sti_plane
*plane
= to_sti_plane(drm_plane
);
77 struct drm_property
*prop
;
79 prop
= private->plane_zorder_property
;
81 prop
= drm_property_create_range(dev
, 0, "zpos", 1,
82 GAM_MIXER_NB_DEPTH_LEVEL
);
86 private->plane_zorder_property
= prop
;
89 drm_object_attach_property(&drm_plane
->base
, prop
, plane
->zorder
);
92 void sti_plane_init_property(struct sti_plane
*plane
,
93 enum drm_plane_type type
)
97 for (i
= 0; i
< ARRAY_SIZE(sti_plane_default_zorder
); i
++)
98 if (sti_plane_default_zorder
[i
] == plane
->desc
)
101 plane
->zorder
= i
+ 1;
103 if (type
== DRM_PLANE_TYPE_OVERLAY
)
104 sti_plane_attach_zorder_property(&plane
->drm_plane
);
106 DRM_DEBUG_DRIVER("drm plane:%d mapped to %s with zorder:%d\n",
107 plane
->drm_plane
.base
.id
,
108 sti_plane_to_str(plane
), plane
->zorder
);
111 struct drm_plane_funcs sti_plane_helpers_funcs
= {
112 .update_plane
= drm_atomic_helper_update_plane
,
113 .disable_plane
= drm_atomic_helper_disable_plane
,
114 .destroy
= sti_plane_destroy
,
115 .set_property
= sti_plane_set_property
,
116 .reset
= drm_atomic_helper_plane_reset
,
117 .atomic_duplicate_state
= drm_atomic_helper_plane_duplicate_state
,
118 .atomic_destroy_state
= drm_atomic_helper_plane_destroy_state
,