diff options
author | Matt Roper <matthew.d.roper@intel.com> | 2015-01-21 19:35:44 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2015-01-27 03:56:46 -0500 |
commit | 5ee67f1cf9d009ff6522d264a05d78f082952a4f (patch) | |
tree | e432860fa7c3f47aaa979957c9dfd6133f2ce79a /drivers | |
parent | a98b3431afcbc66986fcf375fa168df1d9d28bc0 (diff) |
drm/i915: Add main atomic entrypoints (v2)
Add the top-level atomic entrypoints for check/commit. These won't get
called yet; we still need to either enable the atomic ioctl or switch to
using the non-transitional atomic helpers for legacy operations.
v2:
- Use plane->pipe rather than plane->possible_crtcs while ensuring that
only a single CRTC is in use. Either way will work fine since i915
drm_plane's are always tied to a single CRTC, but plane->pipe is
slightly more intuitive. (Ander)
- Simplify crtc/connector checking logic. (Ander)
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ander Conselvan de Oliveira <conselvan2@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/i915/Makefile | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_atomic.c | 164 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_display.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_drv.h | 7 |
4 files changed, 174 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 16e3dc350274..c7e2ab59c85e 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile | |||
@@ -66,6 +66,7 @@ i915-y += dvo_ch7017.o \ | |||
66 | dvo_ns2501.o \ | 66 | dvo_ns2501.o \ |
67 | dvo_sil164.o \ | 67 | dvo_sil164.o \ |
68 | dvo_tfp410.o \ | 68 | dvo_tfp410.o \ |
69 | intel_atomic.o \ | ||
69 | intel_atomic_plane.o \ | 70 | intel_atomic_plane.o \ |
70 | intel_crt.o \ | 71 | intel_crt.o \ |
71 | intel_ddi.o \ | 72 | intel_ddi.o \ |
diff --git a/drivers/gpu/drm/i915/intel_atomic.c b/drivers/gpu/drm/i915/intel_atomic.c new file mode 100644 index 000000000000..5c31f54a3711 --- /dev/null +++ b/drivers/gpu/drm/i915/intel_atomic.c | |||
@@ -0,0 +1,164 @@ | |||
1 | /* | ||
2 | * Copyright © 2015 Intel Corporation | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice (including the next | ||
12 | * paragraph) shall be included in all copies or substantial portions of the | ||
13 | * Software. | ||
14 | * | ||
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
21 | * DEALINGS IN THE SOFTWARE. | ||
22 | */ | ||
23 | |||
24 | /** | ||
25 | * DOC: atomic modeset support | ||
26 | * | ||
27 | * The functions here implement the state management and hardware programming | ||
28 | * dispatch required by the atomic modeset infrastructure. | ||
29 | * See intel_atomic_plane.c for the plane-specific atomic functionality. | ||
30 | */ | ||
31 | |||
32 | #include <drm/drmP.h> | ||
33 | #include <drm/drm_atomic.h> | ||
34 | #include <drm/drm_atomic_helper.h> | ||
35 | #include <drm/drm_plane_helper.h> | ||
36 | #include "intel_drv.h" | ||
37 | |||
38 | |||
39 | /** | ||
40 | * intel_atomic_check - validate state object | ||
41 | * @dev: drm device | ||
42 | * @state: state to validate | ||
43 | */ | ||
44 | int intel_atomic_check(struct drm_device *dev, | ||
45 | struct drm_atomic_state *state) | ||
46 | { | ||
47 | int nplanes = dev->mode_config.num_total_plane; | ||
48 | int ncrtcs = dev->mode_config.num_crtc; | ||
49 | int nconnectors = dev->mode_config.num_connector; | ||
50 | enum pipe nuclear_pipe = INVALID_PIPE; | ||
51 | int ret; | ||
52 | int i; | ||
53 | bool not_nuclear = false; | ||
54 | |||
55 | /* | ||
56 | * FIXME: At the moment, we only support "nuclear pageflip" on a | ||
57 | * single CRTC. Cross-crtc updates will be added later. | ||
58 | */ | ||
59 | for (i = 0; i < nplanes; i++) { | ||
60 | struct intel_plane *plane = to_intel_plane(state->planes[i]); | ||
61 | if (!plane) | ||
62 | continue; | ||
63 | |||
64 | if (nuclear_pipe == INVALID_PIPE) { | ||
65 | nuclear_pipe = plane->pipe; | ||
66 | } else if (nuclear_pipe != plane->pipe) { | ||
67 | DRM_DEBUG_KMS("i915 only support atomic plane operations on a single CRTC at the moment\n"); | ||
68 | return -EINVAL; | ||
69 | } | ||
70 | } | ||
71 | |||
72 | /* | ||
73 | * FIXME: We only handle planes for now; make sure there are no CRTC's | ||
74 | * or connectors involved. | ||
75 | */ | ||
76 | state->allow_modeset = false; | ||
77 | for (i = 0; i < ncrtcs; i++) { | ||
78 | struct intel_crtc *crtc = to_intel_crtc(state->crtcs[i]); | ||
79 | if (crtc && crtc->pipe != nuclear_pipe) | ||
80 | not_nuclear = true; | ||
81 | } | ||
82 | for (i = 0; i < nconnectors; i++) | ||
83 | if (state->connectors[i] != NULL) | ||
84 | not_nuclear = true; | ||
85 | |||
86 | if (not_nuclear) { | ||
87 | DRM_DEBUG_KMS("i915 only supports atomic plane operations at the moment\n"); | ||
88 | return -EINVAL; | ||
89 | } | ||
90 | |||
91 | ret = drm_atomic_helper_check_planes(dev, state); | ||
92 | if (ret) | ||
93 | return ret; | ||
94 | |||
95 | return ret; | ||
96 | } | ||
97 | |||
98 | |||
99 | /** | ||
100 | * intel_atomic_commit - commit validated state object | ||
101 | * @dev: DRM device | ||
102 | * @state: the top-level driver state object | ||
103 | * @async: asynchronous commit | ||
104 | * | ||
105 | * This function commits a top-level state object that has been validated | ||
106 | * with drm_atomic_helper_check(). | ||
107 | * | ||
108 | * FIXME: Atomic modeset support for i915 is not yet complete. At the moment | ||
109 | * we can only handle plane-related operations and do not yet support | ||
110 | * asynchronous commit. | ||
111 | * | ||
112 | * RETURNS | ||
113 | * Zero for success or -errno. | ||
114 | */ | ||
115 | int intel_atomic_commit(struct drm_device *dev, | ||
116 | struct drm_atomic_state *state, | ||
117 | bool async) | ||
118 | { | ||
119 | int ret; | ||
120 | int i; | ||
121 | |||
122 | if (async) { | ||
123 | DRM_DEBUG_KMS("i915 does not yet support async commit\n"); | ||
124 | return -EINVAL; | ||
125 | } | ||
126 | |||
127 | ret = drm_atomic_helper_prepare_planes(dev, state); | ||
128 | if (ret) | ||
129 | return ret; | ||
130 | |||
131 | /* Point of no return */ | ||
132 | |||
133 | /* | ||
134 | * FIXME: The proper sequence here will eventually be: | ||
135 | * | ||
136 | * drm_atomic_helper_swap_state(dev, state) | ||
137 | * drm_atomic_helper_commit_pre_planes(dev, state); | ||
138 | * drm_atomic_helper_commit_planes(dev, state); | ||
139 | * drm_atomic_helper_commit_post_planes(dev, state); | ||
140 | * drm_atomic_helper_wait_for_vblanks(dev, state); | ||
141 | * drm_atomic_helper_cleanup_planes(dev, state); | ||
142 | * drm_atomic_state_free(state); | ||
143 | * | ||
144 | * once we have full atomic modeset. For now, just manually update | ||
145 | * plane states to avoid clobbering good states with dummy states | ||
146 | * while nuclear pageflipping. | ||
147 | */ | ||
148 | for (i = 0; i < dev->mode_config.num_total_plane; i++) { | ||
149 | struct drm_plane *plane = state->planes[i]; | ||
150 | |||
151 | if (!plane) | ||
152 | continue; | ||
153 | |||
154 | plane->state->state = state; | ||
155 | swap(state->plane_states[i], plane->state); | ||
156 | plane->state->state = NULL; | ||
157 | } | ||
158 | drm_atomic_helper_commit_planes(dev, state); | ||
159 | drm_atomic_helper_wait_for_vblanks(dev, state); | ||
160 | drm_atomic_helper_cleanup_planes(dev, state); | ||
161 | drm_atomic_state_free(state); | ||
162 | |||
163 | return 0; | ||
164 | } | ||
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 0cdcf9bf54c2..75b7ca1488e9 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -12752,6 +12752,8 @@ static inline void intel_fbdev_output_poll_changed(struct drm_device *dev) | |||
12752 | static const struct drm_mode_config_funcs intel_mode_funcs = { | 12752 | static const struct drm_mode_config_funcs intel_mode_funcs = { |
12753 | .fb_create = intel_user_framebuffer_create, | 12753 | .fb_create = intel_user_framebuffer_create, |
12754 | .output_poll_changed = intel_fbdev_output_poll_changed, | 12754 | .output_poll_changed = intel_fbdev_output_poll_changed, |
12755 | .atomic_check = intel_atomic_check, | ||
12756 | .atomic_commit = intel_atomic_commit, | ||
12755 | }; | 12757 | }; |
12756 | 12758 | ||
12757 | /* Set up chip specific display functions */ | 12759 | /* Set up chip specific display functions */ |
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 3d65e8ba4a6c..18f167b49575 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h | |||
@@ -1249,6 +1249,13 @@ void intel_pre_disable_primary(struct drm_crtc *crtc); | |||
1249 | void intel_tv_init(struct drm_device *dev); | 1249 | void intel_tv_init(struct drm_device *dev); |
1250 | 1250 | ||
1251 | /* intel_atomic.c */ | 1251 | /* intel_atomic.c */ |
1252 | int intel_atomic_check(struct drm_device *dev, | ||
1253 | struct drm_atomic_state *state); | ||
1254 | int intel_atomic_commit(struct drm_device *dev, | ||
1255 | struct drm_atomic_state *state, | ||
1256 | bool async); | ||
1257 | |||
1258 | /* intel_atomic_plane.c */ | ||
1252 | struct intel_plane_state *intel_create_plane_state(struct drm_plane *plane); | 1259 | struct intel_plane_state *intel_create_plane_state(struct drm_plane *plane); |
1253 | struct drm_plane_state *intel_plane_duplicate_state(struct drm_plane *plane); | 1260 | struct drm_plane_state *intel_plane_duplicate_state(struct drm_plane *plane); |
1254 | void intel_plane_destroy_state(struct drm_plane *plane, | 1261 | void intel_plane_destroy_state(struct drm_plane *plane, |