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
);
167 * intel_connector_atomic_get_property - fetch connector property value
168 * @connector: connector to fetch property for
169 * @state: state containing the property value
170 * @property: property to look up
171 * @val: pointer to write property value into
173 * The DRM core does not store shadow copies of properties for
174 * atomic-capable drivers. This entrypoint is used to fetch
175 * the current value of a driver-specific connector property.
178 intel_connector_atomic_get_property(struct drm_connector
*connector
,
179 const struct drm_connector_state
*state
,
180 struct drm_property
*property
,
186 * TODO: We only have atomic modeset for planes at the moment, so the
187 * crtc/connector code isn't quite ready yet. Until it's ready,
188 * continue to look up all property values in the DRM's shadow copy
189 * in obj->properties->values[].
191 * When the crtc/connector state work matures, this function should
192 * be updated to read the values out of the state structure instead.
194 for (i
= 0; i
< connector
->base
.properties
->count
; i
++) {
195 if (connector
->base
.properties
->properties
[i
] == property
) {
196 *val
= connector
->base
.properties
->values
[i
];
205 * intel_crtc_duplicate_state - duplicate crtc state
208 * Allocates and returns a copy of the crtc state (both common and
209 * Intel-specific) for the specified crtc.
211 * Returns: The newly allocated crtc state, or NULL on failure.
213 struct drm_crtc_state
*
214 intel_crtc_duplicate_state(struct drm_crtc
*crtc
)
216 struct intel_crtc
*intel_crtc
= to_intel_crtc(crtc
);
218 if (WARN_ON(!intel_crtc
->config
))
219 return kzalloc(sizeof(*intel_crtc
->config
), GFP_KERNEL
);
221 return kmemdup(intel_crtc
->config
, sizeof(*intel_crtc
->config
),
226 * intel_crtc_destroy_state - destroy crtc state
229 * Destroys the crtc state (both common and Intel-specific) for the
233 intel_crtc_destroy_state(struct drm_crtc
*crtc
,
234 struct drm_crtc_state
*state
)
236 drm_atomic_helper_crtc_destroy_state(crtc
, state
);
This page took 0.043382 seconds and 6 git commands to generate.