Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+175 -168
+168
drivers/gpu/drm/drm_atomic.c
··· 1179 1179 } 1180 1180 EXPORT_SYMBOL(drm_atomic_nonblocking_commit); 1181 1181 1182 + /* just used from drm-client and atomic-helper: */ 1183 + int __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 + } 1204 + EXPORT_SYMBOL(__drm_atomic_helper_disable_plane); 1205 + 1206 + static 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: */ 1275 + int __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 + 1341 + commit: 1342 + ret = update_output_state(state, set); 1343 + if (ret) 1344 + return ret; 1345 + 1346 + return 0; 1347 + } 1348 + EXPORT_SYMBOL(__drm_atomic_helper_set_config); 1349 + 1182 1350 void drm_atomic_print_state(const struct drm_atomic_state *state) 1183 1351 { 1184 1352 struct drm_printer p = drm_info_printer(state->dev->dev);
-164
drivers/gpu/drm/drm_atomic_helper.c
··· 2844 2844 } 2845 2845 EXPORT_SYMBOL(drm_atomic_helper_disable_plane); 2846 2846 2847 - /* just used from fb-helper and atomic-helper: */ 2848 - int __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 - 2870 - static 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 2848 * drm_atomic_helper_set_config - set a new config from userspace 2938 2849 * @set: mode set configuration ··· 2887 2976 return ret; 2888 2977 } 2889 2978 EXPORT_SYMBOL(drm_atomic_helper_set_config); 2890 - 2891 - /* just used from fb-helper and atomic-helper: */ 2892 - int __drm_atomic_helper_set_config(struct drm_mode_set *set, 2893 - struct drm_atomic_state *state) 2894 - { 2895 - struct drm_crtc_state *crtc_state; 2896 - struct drm_plane_state *primary_state; 2897 - struct drm_crtc *crtc = set->crtc; 2898 - int hdisplay, vdisplay; 2899 - int ret; 2900 - 2901 - crtc_state = drm_atomic_get_crtc_state(state, crtc); 2902 - if (IS_ERR(crtc_state)) 2903 - return PTR_ERR(crtc_state); 2904 - 2905 - primary_state = drm_atomic_get_plane_state(state, crtc->primary); 2906 - if (IS_ERR(primary_state)) 2907 - return PTR_ERR(primary_state); 2908 - 2909 - if (!set->mode) { 2910 - WARN_ON(set->fb); 2911 - WARN_ON(set->num_connectors); 2912 - 2913 - ret = drm_atomic_set_mode_for_crtc(crtc_state, NULL); 2914 - if (ret != 0) 2915 - return ret; 2916 - 2917 - crtc_state->active = false; 2918 - 2919 - ret = drm_atomic_set_crtc_for_plane(primary_state, NULL); 2920 - if (ret != 0) 2921 - return ret; 2922 - 2923 - drm_atomic_set_fb_for_plane(primary_state, NULL); 2924 - 2925 - goto commit; 2926 - } 2927 - 2928 - WARN_ON(!set->fb); 2929 - WARN_ON(!set->num_connectors); 2930 - 2931 - ret = drm_atomic_set_mode_for_crtc(crtc_state, set->mode); 2932 - if (ret != 0) 2933 - return ret; 2934 - 2935 - crtc_state->active = true; 2936 - 2937 - ret = drm_atomic_set_crtc_for_plane(primary_state, crtc); 2938 - if (ret != 0) 2939 - return ret; 2940 - 2941 - drm_mode_get_hv_timing(set->mode, &hdisplay, &vdisplay); 2942 - 2943 - drm_atomic_set_fb_for_plane(primary_state, set->fb); 2944 - primary_state->crtc_x = 0; 2945 - primary_state->crtc_y = 0; 2946 - primary_state->crtc_w = hdisplay; 2947 - primary_state->crtc_h = vdisplay; 2948 - primary_state->src_x = set->x << 16; 2949 - primary_state->src_y = set->y << 16; 2950 - if (drm_rotation_90_or_270(primary_state->rotation)) { 2951 - primary_state->src_w = vdisplay << 16; 2952 - primary_state->src_h = hdisplay << 16; 2953 - } else { 2954 - primary_state->src_w = hdisplay << 16; 2955 - primary_state->src_h = vdisplay << 16; 2956 - } 2957 - 2958 - commit: 2959 - ret = update_output_state(state, set); 2960 - if (ret) 2961 - return ret; 2962 - 2963 - return 0; 2964 - } 2965 2979 2966 2980 /** 2967 2981 * drm_atomic_helper_disable_all - disable all currently active outputs
+7
drivers/gpu/drm/drm_crtc_internal.h
··· 50 50 struct drm_mode_fb_cmd2; 51 51 struct drm_mode_fb_cmd; 52 52 struct drm_mode_object; 53 + struct drm_mode_set; 53 54 struct drm_plane; 55 + struct drm_plane_state; 54 56 struct drm_property; 55 57 struct edid; 56 58 struct kref; ··· 224 222 struct drm_minor; 225 223 int drm_atomic_debugfs_init(struct drm_minor *minor); 226 224 #endif 225 + 226 + int __drm_atomic_helper_disable_plane(struct drm_plane *plane, 227 + struct drm_plane_state *plane_state); 228 + int __drm_atomic_helper_set_config(struct drm_mode_set *set, 229 + struct drm_atomic_state *state); 227 230 228 231 void drm_atomic_print_state(const struct drm_atomic_state *state); 229 232
-4
include/drm/drm_atomic_helper.h
··· 117 117 struct drm_modeset_acquire_ctx *ctx); 118 118 int drm_atomic_helper_disable_plane(struct drm_plane *plane, 119 119 struct drm_modeset_acquire_ctx *ctx); 120 - int __drm_atomic_helper_disable_plane(struct drm_plane *plane, 121 - struct drm_plane_state *plane_state); 122 120 int drm_atomic_helper_set_config(struct drm_mode_set *set, 123 121 struct drm_modeset_acquire_ctx *ctx); 124 - int __drm_atomic_helper_set_config(struct drm_mode_set *set, 125 - struct drm_atomic_state *state); 126 122 127 123 int drm_atomic_helper_disable_all(struct drm_device *dev, 128 124 struct drm_modeset_acquire_ctx *ctx);