summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoralf Trønnes <noralf@tronnes.org>2019-05-31 10:01:10 -0400
committerNoralf Trønnes <noralf@tronnes.org>2019-06-08 10:46:37 -0400
commitdf73789514554761ebdd87f2426938696a2442a2 (patch)
tree7b3a3ede0ab2ecb482cce455967e7b8285aed0bd
parentd99004d7201aa653658ff2390d6e516567c96ebc (diff)
drm/atomic: Move __drm_atomic_helper_disable_plane/set_config()
Prepare for moving drm_fb_helper modesetting code to drm_client. drm_client will be linked to drm.ko, so move __drm_atomic_helper_disable_plane() and __drm_atomic_helper_set_config() out of drm_kms_helper.ko. While at it, fix two checkpatch complaints: - WARNING: Block comments use a trailing */ on a separate line - CHECK: Alignment should match open parenthesis v7: Declare drm_mode_set and drm_plane_state Signed-off-by: Noralf Trønnes <noralf@tronnes.org> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190531140117.37751-2-noralf@tronnes.org
-rw-r--r--drivers/gpu/drm/drm_atomic.c168
-rw-r--r--drivers/gpu/drm/drm_atomic_helper.c164
-rw-r--r--drivers/gpu/drm/drm_crtc_internal.h7
-rw-r--r--include/drm/drm_atomic_helper.h4
4 files changed, 175 insertions, 168 deletions
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index b640e77184e5..169f06d7c5ce 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -1179,6 +1179,174 @@ int drm_atomic_nonblocking_commit(struct drm_atomic_state *state)
1179} 1179}
1180EXPORT_SYMBOL(drm_atomic_nonblocking_commit); 1180EXPORT_SYMBOL(drm_atomic_nonblocking_commit);
1181 1181
1182/* just used from drm-client and atomic-helper: */
1183int __drm_atomic_helper_disable_plane(struct drm_plane *plane,
1184 struct drm_plane_state *plane_state)
1185{
1186 int ret;
1187
1188 ret = drm_atomic_set_crtc_for_plane(plane_state, NULL);
1189 if (ret != 0)
1190 return ret;
1191
1192 drm_atomic_set_fb_for_plane(plane_state, NULL);
1193 plane_state->crtc_x = 0;
1194 plane_state->crtc_y = 0;
1195 plane_state->crtc_w = 0;
1196 plane_state->crtc_h = 0;
1197 plane_state->src_x = 0;
1198 plane_state->src_y = 0;
1199 plane_state->src_w = 0;
1200 plane_state->src_h = 0;
1201
1202 return 0;
1203}
1204EXPORT_SYMBOL(__drm_atomic_helper_disable_plane);
1205
1206static int update_output_state(struct drm_atomic_state *state,
1207 struct drm_mode_set *set)
1208{
1209 struct drm_device *dev = set->crtc->dev;
1210 struct drm_crtc *crtc;
1211 struct drm_crtc_state *new_crtc_state;
1212 struct drm_connector *connector;
1213 struct drm_connector_state *new_conn_state;
1214 int ret, i;
1215
1216 ret = drm_modeset_lock(&dev->mode_config.connection_mutex,
1217 state->acquire_ctx);
1218 if (ret)
1219 return ret;
1220
1221 /* First disable all connectors on the target crtc. */
1222 ret = drm_atomic_add_affected_connectors(state, set->crtc);
1223 if (ret)
1224 return ret;
1225
1226 for_each_new_connector_in_state(state, connector, new_conn_state, i) {
1227 if (new_conn_state->crtc == set->crtc) {
1228 ret = drm_atomic_set_crtc_for_connector(new_conn_state,
1229 NULL);
1230 if (ret)
1231 return ret;
1232
1233 /* Make sure legacy setCrtc always re-trains */
1234 new_conn_state->link_status = DRM_LINK_STATUS_GOOD;
1235 }
1236 }
1237
1238 /* Then set all connectors from set->connectors on the target crtc */
1239 for (i = 0; i < set->num_connectors; i++) {
1240 new_conn_state = drm_atomic_get_connector_state(state,
1241 set->connectors[i]);
1242 if (IS_ERR(new_conn_state))
1243 return PTR_ERR(new_conn_state);
1244
1245 ret = drm_atomic_set_crtc_for_connector(new_conn_state,
1246 set->crtc);
1247 if (ret)
1248 return ret;
1249 }
1250
1251 for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
1252 /*
1253 * Don't update ->enable for the CRTC in the set_config request,
1254 * since a mismatch would indicate a bug in the upper layers.
1255 * The actual modeset code later on will catch any
1256 * inconsistencies here.
1257 */
1258 if (crtc == set->crtc)
1259 continue;
1260
1261 if (!new_crtc_state->connector_mask) {
1262 ret = drm_atomic_set_mode_prop_for_crtc(new_crtc_state,
1263 NULL);
1264 if (ret < 0)
1265 return ret;
1266
1267 new_crtc_state->active = false;
1268 }
1269 }
1270
1271 return 0;
1272}
1273
1274/* just used from drm-client and atomic-helper: */
1275int __drm_atomic_helper_set_config(struct drm_mode_set *set,
1276 struct drm_atomic_state *state)
1277{
1278 struct drm_crtc_state *crtc_state;
1279 struct drm_plane_state *primary_state;
1280 struct drm_crtc *crtc = set->crtc;
1281 int hdisplay, vdisplay;
1282 int ret;
1283
1284 crtc_state = drm_atomic_get_crtc_state(state, crtc);
1285 if (IS_ERR(crtc_state))
1286 return PTR_ERR(crtc_state);
1287
1288 primary_state = drm_atomic_get_plane_state(state, crtc->primary);
1289 if (IS_ERR(primary_state))
1290 return PTR_ERR(primary_state);
1291
1292 if (!set->mode) {
1293 WARN_ON(set->fb);
1294 WARN_ON(set->num_connectors);
1295
1296 ret = drm_atomic_set_mode_for_crtc(crtc_state, NULL);
1297 if (ret != 0)
1298 return ret;
1299
1300 crtc_state->active = false;
1301
1302 ret = drm_atomic_set_crtc_for_plane(primary_state, NULL);
1303 if (ret != 0)
1304 return ret;
1305
1306 drm_atomic_set_fb_for_plane(primary_state, NULL);
1307
1308 goto commit;
1309 }
1310
1311 WARN_ON(!set->fb);
1312 WARN_ON(!set->num_connectors);
1313
1314 ret = drm_atomic_set_mode_for_crtc(crtc_state, set->mode);
1315 if (ret != 0)
1316 return ret;
1317
1318 crtc_state->active = true;
1319
1320 ret = drm_atomic_set_crtc_for_plane(primary_state, crtc);
1321 if (ret != 0)
1322 return ret;
1323
1324 drm_mode_get_hv_timing(set->mode, &hdisplay, &vdisplay);
1325
1326 drm_atomic_set_fb_for_plane(primary_state, set->fb);
1327 primary_state->crtc_x = 0;
1328 primary_state->crtc_y = 0;
1329 primary_state->crtc_w = hdisplay;
1330 primary_state->crtc_h = vdisplay;
1331 primary_state->src_x = set->x << 16;
1332 primary_state->src_y = set->y << 16;
1333 if (drm_rotation_90_or_270(primary_state->rotation)) {
1334 primary_state->src_w = vdisplay << 16;
1335 primary_state->src_h = hdisplay << 16;
1336 } else {
1337 primary_state->src_w = hdisplay << 16;
1338 primary_state->src_h = vdisplay << 16;
1339 }
1340
1341commit:
1342 ret = update_output_state(state, set);
1343 if (ret)
1344 return ret;
1345
1346 return 0;
1347}
1348EXPORT_SYMBOL(__drm_atomic_helper_set_config);
1349
1182void drm_atomic_print_state(const struct drm_atomic_state *state) 1350void drm_atomic_print_state(const struct drm_atomic_state *state)
1183{ 1351{
1184 struct drm_printer p = drm_info_printer(state->dev->dev); 1352 struct drm_printer p = drm_info_printer(state->dev->dev);
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index acf993cb8e52..0fc63d682245 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -2844,95 +2844,6 @@ fail:
2844} 2844}
2845EXPORT_SYMBOL(drm_atomic_helper_disable_plane); 2845EXPORT_SYMBOL(drm_atomic_helper_disable_plane);
2846 2846
2847/* just used from fb-helper and atomic-helper: */
2848int __drm_atomic_helper_disable_plane(struct drm_plane *plane,
2849 struct drm_plane_state *plane_state)
2850{
2851 int ret;
2852
2853 ret = drm_atomic_set_crtc_for_plane(plane_state, NULL);
2854 if (ret != 0)
2855 return ret;
2856
2857 drm_atomic_set_fb_for_plane(plane_state, NULL);
2858 plane_state->crtc_x = 0;
2859 plane_state->crtc_y = 0;
2860 plane_state->crtc_w = 0;
2861 plane_state->crtc_h = 0;
2862 plane_state->src_x = 0;
2863 plane_state->src_y = 0;
2864 plane_state->src_w = 0;
2865 plane_state->src_h = 0;
2866
2867 return 0;
2868}
2869
2870static int update_output_state(struct drm_atomic_state *state,
2871 struct drm_mode_set *set)
2872{
2873 struct drm_device *dev = set->crtc->dev;
2874 struct drm_crtc *crtc;
2875 struct drm_crtc_state *new_crtc_state;
2876 struct drm_connector *connector;
2877 struct drm_connector_state *new_conn_state;
2878 int ret, i;
2879
2880 ret = drm_modeset_lock(&dev->mode_config.connection_mutex,
2881 state->acquire_ctx);
2882 if (ret)
2883 return ret;
2884
2885 /* First disable all connectors on the target crtc. */
2886 ret = drm_atomic_add_affected_connectors(state, set->crtc);
2887 if (ret)
2888 return ret;
2889
2890 for_each_new_connector_in_state(state, connector, new_conn_state, i) {
2891 if (new_conn_state->crtc == set->crtc) {
2892 ret = drm_atomic_set_crtc_for_connector(new_conn_state,
2893 NULL);
2894 if (ret)
2895 return ret;
2896
2897 /* Make sure legacy setCrtc always re-trains */
2898 new_conn_state->link_status = DRM_LINK_STATUS_GOOD;
2899 }
2900 }
2901
2902 /* Then set all connectors from set->connectors on the target crtc */
2903 for (i = 0; i < set->num_connectors; i++) {
2904 new_conn_state = drm_atomic_get_connector_state(state,
2905 set->connectors[i]);
2906 if (IS_ERR(new_conn_state))
2907 return PTR_ERR(new_conn_state);
2908
2909 ret = drm_atomic_set_crtc_for_connector(new_conn_state,
2910 set->crtc);
2911 if (ret)
2912 return ret;
2913 }
2914
2915 for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
2916 /* Don't update ->enable for the CRTC in the set_config request,
2917 * since a mismatch would indicate a bug in the upper layers.
2918 * The actual modeset code later on will catch any
2919 * inconsistencies here. */
2920 if (crtc == set->crtc)
2921 continue;
2922
2923 if (!new_crtc_state->connector_mask) {
2924 ret = drm_atomic_set_mode_prop_for_crtc(new_crtc_state,
2925 NULL);
2926 if (ret < 0)
2927 return ret;
2928
2929 new_crtc_state->active = false;
2930 }
2931 }
2932
2933 return 0;
2934}
2935
2936/** 2847/**
2937 * drm_atomic_helper_set_config - set a new config from userspace 2848 * drm_atomic_helper_set_config - set a new config from userspace
2938 * @set: mode set configuration 2849 * @set: mode set configuration
@@ -2977,81 +2888,6 @@ fail:
2977} 2888}
2978EXPORT_SYMBOL(drm_atomic_helper_set_config); 2889EXPORT_SYMBOL(drm_atomic_helper_set_config);
2979 2890
2980/* just used from fb-helper and atomic-helper: */
2981int __drm_atomic_helper_set_config(struct drm_mode_set *set,
2982 struct drm_atomic_state *state)
2983{
2984 struct drm_crtc_state *crtc_state;
2985 struct drm_plane_state *primary_state;
2986 struct drm_crtc *crtc = set->crtc;
2987 int hdisplay, vdisplay;
2988 int ret;
2989
2990 crtc_state = drm_atomic_get_crtc_state(state, crtc);
2991 if (IS_ERR(crtc_state))
2992 return PTR_ERR(crtc_state);
2993
2994 primary_state = drm_atomic_get_plane_state(state, crtc->primary);
2995 if (IS_ERR(primary_state))
2996 return PTR_ERR(primary_state);
2997
2998 if (!set->mode) {
2999 WARN_ON(set->fb);
3000 WARN_ON(set->num_connectors);
3001
3002 ret = drm_atomic_set_mode_for_crtc(crtc_state, NULL);
3003 if (ret != 0)
3004 return ret;
3005
3006 crtc_state->active = false;
3007
3008 ret = drm_atomic_set_crtc_for_plane(primary_state, NULL);
3009 if (ret != 0)
3010 return ret;
3011
3012 drm_atomic_set_fb_for_plane(primary_state, NULL);
3013
3014 goto commit;
3015 }
3016
3017 WARN_ON(!set->fb);
3018 WARN_ON(!set->num_connectors);
3019
3020 ret = drm_atomic_set_mode_for_crtc(crtc_state, set->mode);
3021 if (ret != 0)
3022 return ret;
3023
3024 crtc_state->active = true;
3025
3026 ret = drm_atomic_set_crtc_for_plane(primary_state, crtc);
3027 if (ret != 0)
3028 return ret;
3029
3030 drm_mode_get_hv_timing(set->mode, &hdisplay, &vdisplay);
3031
3032 drm_atomic_set_fb_for_plane(primary_state, set->fb);
3033 primary_state->crtc_x = 0;
3034 primary_state->crtc_y = 0;
3035 primary_state->crtc_w = hdisplay;
3036 primary_state->crtc_h = vdisplay;
3037 primary_state->src_x = set->x << 16;
3038 primary_state->src_y = set->y << 16;
3039 if (drm_rotation_90_or_270(primary_state->rotation)) {
3040 primary_state->src_w = vdisplay << 16;
3041 primary_state->src_h = hdisplay << 16;
3042 } else {
3043 primary_state->src_w = hdisplay << 16;
3044 primary_state->src_h = vdisplay << 16;
3045 }
3046
3047commit:
3048 ret = update_output_state(state, set);
3049 if (ret)
3050 return ret;
3051
3052 return 0;
3053}
3054
3055/** 2891/**
3056 * drm_atomic_helper_disable_all - disable all currently active outputs 2892 * drm_atomic_helper_disable_all - disable all currently active outputs
3057 * @dev: DRM device 2893 * @dev: DRM device
diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h
index c78a44fad13d..c7d5e4c21423 100644
--- a/drivers/gpu/drm/drm_crtc_internal.h
+++ b/drivers/gpu/drm/drm_crtc_internal.h
@@ -50,7 +50,9 @@ struct drm_mode_create_dumb;
50struct drm_mode_fb_cmd2; 50struct drm_mode_fb_cmd2;
51struct drm_mode_fb_cmd; 51struct drm_mode_fb_cmd;
52struct drm_mode_object; 52struct drm_mode_object;
53struct drm_mode_set;
53struct drm_plane; 54struct drm_plane;
55struct drm_plane_state;
54struct drm_property; 56struct drm_property;
55struct edid; 57struct edid;
56struct kref; 58struct kref;
@@ -223,6 +225,11 @@ struct drm_minor;
223int drm_atomic_debugfs_init(struct drm_minor *minor); 225int drm_atomic_debugfs_init(struct drm_minor *minor);
224#endif 226#endif
225 227
228int __drm_atomic_helper_disable_plane(struct drm_plane *plane,
229 struct drm_plane_state *plane_state);
230int __drm_atomic_helper_set_config(struct drm_mode_set *set,
231 struct drm_atomic_state *state);
232
226void drm_atomic_print_state(const struct drm_atomic_state *state); 233void drm_atomic_print_state(const struct drm_atomic_state *state);
227 234
228/* drm_atomic_uapi.c */ 235/* drm_atomic_uapi.c */
diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
index 58214be3bf3d..bf4e07141d81 100644
--- a/include/drm/drm_atomic_helper.h
+++ b/include/drm/drm_atomic_helper.h
@@ -117,12 +117,8 @@ int drm_atomic_helper_update_plane(struct drm_plane *plane,
117 struct drm_modeset_acquire_ctx *ctx); 117 struct drm_modeset_acquire_ctx *ctx);
118int drm_atomic_helper_disable_plane(struct drm_plane *plane, 118int drm_atomic_helper_disable_plane(struct drm_plane *plane,
119 struct drm_modeset_acquire_ctx *ctx); 119 struct drm_modeset_acquire_ctx *ctx);
120int __drm_atomic_helper_disable_plane(struct drm_plane *plane,
121 struct drm_plane_state *plane_state);
122int drm_atomic_helper_set_config(struct drm_mode_set *set, 120int drm_atomic_helper_set_config(struct drm_mode_set *set,
123 struct drm_modeset_acquire_ctx *ctx); 121 struct drm_modeset_acquire_ctx *ctx);
124int __drm_atomic_helper_set_config(struct drm_mode_set *set,
125 struct drm_atomic_state *state);
126 122
127int drm_atomic_helper_disable_all(struct drm_device *dev, 123int drm_atomic_helper_disable_all(struct drm_device *dev,
128 struct drm_modeset_acquire_ctx *ctx); 124 struct drm_modeset_acquire_ctx *ctx);