Merge tag 'nfsd-4.3-2' of git://linux-nfs.org/~bfields/linux
[deliverable/linux.git] / drivers / gpu / drm / sti / sti_plane.c
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 */
8
9 #include <drm/drmP.h>
10 #include <drm/drm_fb_cma_helper.h>
11 #include <drm/drm_gem_cma_helper.h>
12
13 #include "sti_compositor.h"
14 #include "sti_drv.h"
15 #include "sti_plane.h"
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 const char *sti_plane_to_str(struct sti_plane *plane)
27 {
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>";
43 }
44 }
45 EXPORT_SYMBOL(sti_plane_to_str);
46
47 static void sti_plane_destroy(struct drm_plane *drm_plane)
48 {
49 DRM_DEBUG_DRIVER("\n");
50
51 drm_plane_helper_disable(drm_plane);
52 drm_plane_cleanup(drm_plane);
53 }
54
55 static int sti_plane_set_property(struct drm_plane *drm_plane,
56 struct drm_property *property,
57 uint64_t val)
58 {
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);
62
63 DRM_DEBUG_DRIVER("\n");
64
65 if (property == private->plane_zorder_property) {
66 plane->zorder = val;
67 return 0;
68 }
69
70 return -EINVAL;
71 }
72
73 static void sti_plane_attach_zorder_property(struct drm_plane *drm_plane)
74 {
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;
79
80 prop = private->plane_zorder_property;
81 if (!prop) {
82 prop = drm_property_create_range(dev, 0, "zpos", 1,
83 GAM_MIXER_NB_DEPTH_LEVEL);
84 if (!prop)
85 return;
86
87 private->plane_zorder_property = prop;
88 }
89
90 drm_object_attach_property(&drm_plane->base, prop, plane->zorder);
91 }
92
93 void sti_plane_init_property(struct sti_plane *plane,
94 enum drm_plane_type type)
95 {
96 unsigned int i;
97
98 for (i = 0; i < ARRAY_SIZE(sti_plane_default_zorder); i++)
99 if (sti_plane_default_zorder[i] == plane->desc)
100 break;
101
102 plane->zorder = i + 1;
103
104 if (type == DRM_PLANE_TYPE_OVERLAY)
105 sti_plane_attach_zorder_property(&plane->drm_plane);
106
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);
110 }
111 EXPORT_SYMBOL(sti_plane_init_property);
112
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,
121 };
122 EXPORT_SYMBOL(sti_plane_helpers_funcs);
This page took 0.034226 seconds and 5 git commands to generate.