aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2016-03-03 04:17:39 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2016-03-08 05:04:34 -0500
commit40616a26d1c68e4c80e2358a02297ba492f4cc17 (patch)
treeb262d6688cfda2df82d8509cb2648aedd764f596
parentff19b7867fcaa00638018e116c63aba75c4b07ba (diff)
drm/atomic: Handle encoder stealing from set_config better.
Instead of failing with -EINVAL when conflicting encoders are found, the legacy set_config will disable other connectors when encoders conflict. With the previous commit this becomes a lot easier to implement. set_config only adds connectors to the state that are modified, and because of the previous commit that calls add_affected_connectors only on set->crtc it means any connector not part of the modeset can be stolen from. We disable the connector in that case, and possibly the crtc if required. Atomic modeset itself still doesn't allow encoder stealing, the results would be too unpredictable. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/1456996662-8704-5-git-send-email-maarten.lankhorst@linux.intel.com
-rw-r--r--drivers/gpu/drm/drm_atomic_helper.c69
-rw-r--r--include/drm/drm_crtc.h2
2 files changed, 71 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 32f6f57fc66e..9fab9860999b 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -86,6 +86,68 @@ drm_atomic_helper_plane_changed(struct drm_atomic_state *state,
86 } 86 }
87} 87}
88 88
89static int disable_conflicting_connectors(struct drm_atomic_state *state)
90{
91 struct drm_connector_state *conn_state;
92 struct drm_connector *connector;
93 struct drm_encoder *encoder;
94 unsigned encoder_mask = 0;
95 int i, ret;
96
97 for_each_connector_in_state(state, connector, conn_state, i) {
98 const struct drm_connector_helper_funcs *funcs = connector->helper_private;
99 struct drm_encoder *new_encoder;
100
101 if (!conn_state->crtc)
102 continue;
103
104 if (funcs->atomic_best_encoder)
105 new_encoder = funcs->atomic_best_encoder(connector, conn_state);
106 else
107 new_encoder = funcs->best_encoder(connector);
108
109 if (new_encoder)
110 encoder_mask |= 1 << drm_encoder_index(new_encoder);
111 }
112
113 drm_for_each_connector(connector, state->dev) {
114 struct drm_crtc_state *crtc_state;
115
116 if (drm_atomic_get_existing_connector_state(state, connector))
117 continue;
118
119 encoder = connector->state->best_encoder;
120 if (!encoder || !(encoder_mask & (1 << drm_encoder_index(encoder))))
121 continue;
122
123 conn_state = drm_atomic_get_connector_state(state, connector);
124 if (IS_ERR(conn_state))
125 return PTR_ERR(conn_state);
126
127 DRM_DEBUG_ATOMIC("[ENCODER:%d:%s] in use on [CRTC:%d:%s], disabling [CONNECTOR:%d:%s]\n",
128 encoder->base.id, encoder->name,
129 conn_state->crtc->base.id, conn_state->crtc->name,
130 connector->base.id, connector->name);
131
132 crtc_state = drm_atomic_get_existing_crtc_state(state, conn_state->crtc);
133
134 ret = drm_atomic_set_crtc_for_connector(conn_state, NULL);
135 if (ret)
136 return ret;
137
138 if (!crtc_state->connector_mask) {
139 ret = drm_atomic_set_mode_prop_for_crtc(crtc_state,
140 NULL);
141 if (ret < 0)
142 return ret;
143
144 crtc_state->active = false;
145 }
146 }
147
148 return 0;
149}
150
89static bool 151static bool
90check_pending_encoder_assignment(struct drm_atomic_state *state, 152check_pending_encoder_assignment(struct drm_atomic_state *state,
91 struct drm_encoder *new_encoder) 153 struct drm_encoder *new_encoder)
@@ -448,6 +510,12 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
448 } 510 }
449 } 511 }
450 512
513 if (state->legacy_set_config) {
514 ret = disable_conflicting_connectors(state);
515 if (ret)
516 return ret;
517 }
518
451 for_each_connector_in_state(state, connector, connector_state, i) { 519 for_each_connector_in_state(state, connector, connector_state, i) {
452 /* 520 /*
453 * This only sets crtc->mode_changed for routing changes, 521 * This only sets crtc->mode_changed for routing changes,
@@ -1796,6 +1864,7 @@ int drm_atomic_helper_set_config(struct drm_mode_set *set)
1796 if (!state) 1864 if (!state)
1797 return -ENOMEM; 1865 return -ENOMEM;
1798 1866
1867 state->legacy_set_config = true;
1799 state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc); 1868 state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);
1800retry: 1869retry:
1801 ret = __drm_atomic_helper_set_config(set, state); 1870 ret = __drm_atomic_helper_set_config(set, state);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 8c7fb3d0f9d0..75b28deeaf24 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -1676,6 +1676,7 @@ struct drm_bridge {
1676 * @dev: parent DRM device 1676 * @dev: parent DRM device
1677 * @allow_modeset: allow full modeset 1677 * @allow_modeset: allow full modeset
1678 * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics 1678 * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics
1679 * @legacy_set_config: Disable conflicting encoders instead of failing with -EINVAL.
1679 * @planes: pointer to array of plane pointers 1680 * @planes: pointer to array of plane pointers
1680 * @plane_states: pointer to array of plane states pointers 1681 * @plane_states: pointer to array of plane states pointers
1681 * @crtcs: pointer to array of CRTC pointers 1682 * @crtcs: pointer to array of CRTC pointers
@@ -1689,6 +1690,7 @@ struct drm_atomic_state {
1689 struct drm_device *dev; 1690 struct drm_device *dev;
1690 bool allow_modeset : 1; 1691 bool allow_modeset : 1;
1691 bool legacy_cursor_update : 1; 1692 bool legacy_cursor_update : 1;
1693 bool legacy_set_config : 1;
1692 struct drm_plane **planes; 1694 struct drm_plane **planes;
1693 struct drm_plane_state **plane_states; 1695 struct drm_plane_state **plane_states;
1694 struct drm_crtc **crtcs; 1696 struct drm_crtc **crtcs;