2 * Copyright © 2015 Intel Corporation
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:
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
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.
25 * DOC: atomic modeset support
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.
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"
40 * intel_atomic_check - validate state object
42 * @state: state to validate
44 int intel_atomic_check(struct drm_device *dev,
45 struct drm_atomic_state *state)
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;
53 bool not_nuclear = false;
56 * FIXME: At the moment, we only support "nuclear pageflip" on a
57 * single CRTC. Cross-crtc updates will be added later.
59 for (i = 0; i < nplanes; i++) {
60 struct intel_plane *plane = to_intel_plane(state->planes[i]);
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");
73 * FIXME: We only handle planes for now; make sure there are no CRTC's
74 * or connectors involved.
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)
82 for (i = 0; i < nconnectors; i++)
83 if (state->connectors[i] != NULL)
87 DRM_DEBUG_KMS("i915 only supports atomic plane operations at the moment\n");
91 ret = drm_atomic_helper_check_planes(dev, state);
100 * intel_atomic_commit - commit validated state object
102 * @state: the top-level driver state object
103 * @async: asynchronous commit
105 * This function commits a top-level state object that has been validated
106 * with drm_atomic_helper_check().
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.
113 * Zero for success or -errno.
115 int intel_atomic_commit(struct drm_device *dev,
116 struct drm_atomic_state *state,
123 DRM_DEBUG_KMS("i915 does not yet support async commit\n");
127 ret = drm_atomic_helper_prepare_planes(dev, state);
131 /* Point of no return */
134 * FIXME: The proper sequence here will eventually be:
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);
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.
148 for (i = 0; i < dev->mode_config.num_total_plane; i++) {
149 struct drm_plane *plane = state->planes[i];
154 plane->state->state = state;
155 swap(state->plane_states[i], plane->state);
156 plane->state->state = NULL;
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);