summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/drm_atomic_helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/drm_atomic_helper.c')
-rw-r--r--drivers/gpu/drm/drm_atomic_helper.c90
1 files changed, 83 insertions, 7 deletions
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index aa885a614e27..86d3093c6c9b 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -32,6 +32,7 @@
#include <drm/drm_atomic_helper.h>
#include <linux/dma-fence.h>
+#include "drm_crtc_helper_internal.h"
#include "drm_crtc_internal.h"
/**
@@ -452,6 +453,69 @@ mode_fixup(struct drm_atomic_state *state)
return 0;
}
+static enum drm_mode_status mode_valid_path(struct drm_connector *connector,
+ struct drm_encoder *encoder,
+ struct drm_crtc *crtc,
+ struct drm_display_mode *mode)
+{
+ enum drm_mode_status ret;
+
+ ret = drm_encoder_mode_valid(encoder, mode);
+ if (ret != MODE_OK) {
+ DRM_DEBUG_ATOMIC("[ENCODER:%d:%s] mode_valid() failed\n",
+ encoder->base.id, encoder->name);
+ return ret;
+ }
+
+ ret = drm_bridge_mode_valid(encoder->bridge, mode);
+ if (ret != MODE_OK) {
+ DRM_DEBUG_ATOMIC("[BRIDGE] mode_valid() failed\n");
+ return ret;
+ }
+
+ ret = drm_crtc_mode_valid(crtc, mode);
+ if (ret != MODE_OK) {
+ DRM_DEBUG_ATOMIC("[CRTC:%d:%s] mode_valid() failed\n",
+ crtc->base.id, crtc->name);
+ return ret;
+ }
+
+ return ret;
+}
+
+static int
+mode_valid(struct drm_atomic_state *state)
+{
+ struct drm_connector_state *conn_state;
+ struct drm_connector *connector;
+ int i;
+
+ for_each_new_connector_in_state(state, connector, conn_state, i) {
+ struct drm_encoder *encoder = conn_state->best_encoder;
+ struct drm_crtc *crtc = conn_state->crtc;
+ struct drm_crtc_state *crtc_state;
+ enum drm_mode_status mode_status;
+ struct drm_display_mode *mode;
+
+ if (!crtc || !encoder)
+ continue;
+
+ crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
+ if (!crtc_state)
+ continue;
+ if (!crtc_state->mode_changed && !crtc_state->connectors_changed)
+ continue;
+
+ mode = &crtc_state->mode;
+
+ mode_status = mode_valid_path(connector, encoder, crtc, mode);
+ if (mode_status != MODE_OK)
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
/**
* drm_atomic_helper_check_modeset - validate state object for modeset changes
* @dev: DRM device
@@ -466,13 +530,15 @@ mode_fixup(struct drm_atomic_state *state)
* 2. &drm_connector_helper_funcs.atomic_check to validate the connector state.
* 3. If it's determined a modeset is needed then all connectors on the affected crtc
* crtc are added and &drm_connector_helper_funcs.atomic_check is run on them.
- * 4. &drm_bridge_funcs.mode_fixup is called on all encoder bridges.
- * 5. &drm_encoder_helper_funcs.atomic_check is called to validate any encoder state.
+ * 4. &drm_encoder_helper_funcs.mode_valid, &drm_bridge_funcs.mode_valid and
+ * &drm_crtc_helper_funcs.mode_valid are called on the affected components.
+ * 5. &drm_bridge_funcs.mode_fixup is called on all encoder bridges.
+ * 6. &drm_encoder_helper_funcs.atomic_check is called to validate any encoder state.
* This function is only called when the encoder will be part of a configured crtc,
* it must not be used for implementing connector property validation.
* If this function is NULL, &drm_atomic_encoder_helper_funcs.mode_fixup is called
* instead.
- * 6. &drm_crtc_helper_funcs.mode_fixup is called last, to fix up the mode with crtc constraints.
+ * 7. &drm_crtc_helper_funcs.mode_fixup is called last, to fix up the mode with crtc constraints.
*
* &drm_crtc_state.mode_changed is set when the input mode is changed.
* &drm_crtc_state.connectors_changed is set when a connector is added or
@@ -621,6 +687,10 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
return ret;
}
+ ret = mode_valid(state);
+ if (ret)
+ return ret;
+
return mode_fixup(state);
}
EXPORT_SYMBOL(drm_atomic_helper_check_modeset);
@@ -1076,8 +1146,8 @@ EXPORT_SYMBOL(drm_atomic_helper_commit_modeset_enables);
*
* Note that @pre_swap is needed since the point where we block for fences moves
* around depending upon whether an atomic commit is blocking or
- * non-blocking. For async commit all waiting needs to happen after
- * drm_atomic_helper_swap_state() is called, but for synchronous commits we want
+ * non-blocking. For non-blocking commit all waiting needs to happen after
+ * drm_atomic_helper_swap_state() is called, but for blocking commits we want
* to wait **before** we do anything that can't be easily rolled back. That is
* before we call drm_atomic_helper_swap_state().
*
@@ -2038,6 +2108,8 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,
struct drm_plane *plane;
struct drm_plane_state *old_plane_state, *new_plane_state;
struct drm_crtc_commit *commit;
+ void *obj, *obj_state;
+ const struct drm_private_state_funcs *funcs;
if (stall) {
for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
@@ -2098,6 +2170,9 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,
state->planes[i].state = old_plane_state;
plane->state = new_plane_state;
}
+
+ __for_each_private_obj(state, obj, obj_state, i, funcs)
+ funcs->swap_state(obj, &state->private_objs[i].obj_state);
}
EXPORT_SYMBOL(drm_atomic_helper_swap_state);
@@ -3231,7 +3306,7 @@ void drm_atomic_helper_plane_reset(struct drm_plane *plane)
if (plane->state) {
plane->state->plane = plane;
- plane->state->rotation = DRM_ROTATE_0;
+ plane->state->rotation = DRM_MODE_ROTATE_0;
}
}
EXPORT_SYMBOL(drm_atomic_helper_plane_reset);
@@ -3528,7 +3603,8 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_destroy_state);
*
* Implements support for legacy gamma correction table for drivers
* that support color management through the DEGAMMA_LUT/GAMMA_LUT
- * properties.
+ * properties. See drm_crtc_enable_color_mgmt() and the containing chapter for
+ * how the atomic color management and gamma tables work.
*/
int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
u16 *red, u16 *green, u16 *blue,