drm/omap: Fix error handling path in 'omap_dmm_probe()'
[linux/fpc-iii.git] / drivers / gpu / drm / sti / sti_plane.c
blob2e5c751910c579b70f90836d9a7973bd2f086921
1 /*
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
7 */
9 #include <drm/drmP.h>
10 #include <drm/drm_fb_cma_helper.h>
11 #include <drm/drm_gem_cma_helper.h>
13 #include "sti_compositor.h"
14 #include "sti_drv.h"
15 #include "sti_plane.h"
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,
26 const char *sti_plane_to_str(struct sti_plane *plane)
28 switch (plane->desc) {
29 case STI_GDP_0:
30 return "GDP0";
31 case STI_GDP_1:
32 return "GDP1";
33 case STI_GDP_2:
34 return "GDP2";
35 case STI_GDP_3:
36 return "GDP3";
37 case STI_HQVDP_0:
38 return "HQVDP0";
39 case STI_CURSOR:
40 return "CURSOR";
41 default:
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,
56 uint64_t val)
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) {
65 plane->zorder = val;
66 return 0;
69 return -EINVAL;
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;
80 if (!prop) {
81 prop = drm_property_create_range(dev, 0, "zpos", 1,
82 GAM_MIXER_NB_DEPTH_LEVEL);
83 if (!prop)
84 return;
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)
95 unsigned int i;
97 for (i = 0; i < ARRAY_SIZE(sti_plane_default_zorder); i++)
98 if (sti_plane_default_zorder[i] == plane->desc)
99 break;
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,