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

drm/plane-helper: Export individual helpers

Export the individual plane helpers that make up the plane functions and
align the naming with other helpers. The plane helpers are for non-atomic
modesetting and exporting them will simplify a later conversion of drivers
to atomic modesetting.

With struct drm_plane_funcs removed from drm_plane_helper.h, also remove
the include statements. It only needs linux/types.h for uint32_t and a
number of forward declarations.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20220720083058.15371-6-tzimmermann@suse.de

+88 -33
+2 -1
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
··· 85 85 #include <drm/drm_vblank.h> 86 86 #include <drm/drm_audio_component.h> 87 87 #include <drm/drm_gem_atomic_helper.h> 88 + #include <drm/drm_plane_helper.h> 88 89 89 90 #include "ivsrcid/dcn/irqsrcs_dcn_1_0.h" 90 91 ··· 7718 7717 static const struct drm_plane_funcs dm_plane_funcs = { 7719 7718 .update_plane = drm_atomic_helper_update_plane, 7720 7719 .disable_plane = drm_atomic_helper_disable_plane, 7721 - .destroy = drm_primary_helper_destroy, 7720 + .destroy = drm_plane_helper_destroy, 7722 7721 .reset = dm_drm_plane_reset, 7723 7722 .atomic_duplicate_state = dm_drm_plane_duplicate_state, 7724 7723 .atomic_destroy_state = dm_drm_plane_destroy_state,
+1 -1
drivers/gpu/drm/armada/armada_plane.c
··· 288 288 static const struct drm_plane_funcs armada_primary_plane_funcs = { 289 289 .update_plane = drm_atomic_helper_update_plane, 290 290 .disable_plane = drm_atomic_helper_disable_plane, 291 - .destroy = drm_primary_helper_destroy, 291 + .destroy = drm_plane_helper_destroy, 292 292 .reset = armada_plane_reset, 293 293 .atomic_duplicate_state = armada_plane_duplicate_state, 294 294 .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
+7 -1
drivers/gpu/drm/drm_modeset_helper.c
··· 108 108 DRM_FORMAT_ARGB8888, 109 109 }; 110 110 111 + static const struct drm_plane_funcs primary_plane_funcs = { 112 + .update_plane = drm_plane_helper_update_primary, 113 + .disable_plane = drm_plane_helper_disable_primary, 114 + .destroy = drm_plane_helper_destroy, 115 + }; 116 + 111 117 static struct drm_plane *create_primary_plane(struct drm_device *dev) 112 118 { 113 119 struct drm_plane *primary; ··· 133 127 134 128 /* possible_crtc's will be filled in later by crtc_init */ 135 129 ret = drm_universal_plane_init(dev, primary, 0, 136 - &drm_primary_helper_funcs, 130 + &primary_plane_funcs, 137 131 safe_modeset_formats, 138 132 ARRAY_SIZE(safe_modeset_formats), 139 133 NULL,
+51 -19
drivers/gpu/drm/drm_plane_helper.c
··· 145 145 return 0; 146 146 } 147 147 148 - static int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc, 149 - struct drm_framebuffer *fb, 150 - int crtc_x, int crtc_y, 151 - unsigned int crtc_w, unsigned int crtc_h, 152 - uint32_t src_x, uint32_t src_y, 153 - uint32_t src_w, uint32_t src_h, 154 - struct drm_modeset_acquire_ctx *ctx) 148 + /** 149 + * drm_plane_helper_update_primary - Helper for updating primary planes 150 + * @plane: plane to update 151 + * @crtc: the plane's new CRTC 152 + * @fb: the plane's new framebuffer 153 + * @crtc_x: x coordinate within CRTC 154 + * @crtc_y: y coordinate within CRTC 155 + * @crtc_w: width coordinate within CRTC 156 + * @crtc_h: height coordinate within CRTC 157 + * @src_x: x coordinate within source 158 + * @src_y: y coordinate within source 159 + * @src_w: width coordinate within source 160 + * @src_h: height coordinate within source 161 + * @ctx: modeset locking context 162 + * 163 + * This helper validates the given parameters and updates the primary plane. 164 + * 165 + * This function is only useful for non-atomic modesetting. Don't use 166 + * it in new drivers. 167 + * 168 + * Returns: 169 + * Zero on success, or an errno code otherwise. 170 + */ 171 + int drm_plane_helper_update_primary(struct drm_plane *plane, struct drm_crtc *crtc, 172 + struct drm_framebuffer *fb, 173 + int crtc_x, int crtc_y, 174 + unsigned int crtc_w, unsigned int crtc_h, 175 + uint32_t src_x, uint32_t src_y, 176 + uint32_t src_w, uint32_t src_h, 177 + struct drm_modeset_acquire_ctx *ctx) 155 178 { 156 179 struct drm_mode_set set = { 157 180 .crtc = crtc, ··· 241 218 kfree(connector_list); 242 219 return ret; 243 220 } 221 + EXPORT_SYMBOL(drm_plane_helper_update_primary); 244 222 245 - static int drm_primary_helper_disable(struct drm_plane *plane, 246 - struct drm_modeset_acquire_ctx *ctx) 223 + /** 224 + * drm_plane_helper_disable_primary - Helper for disabling primary planes 225 + * @plane: plane to disable 226 + * @ctx: modeset locking context 227 + * 228 + * This helper returns an error when trying to disable the primary 229 + * plane. 230 + * 231 + * This function is only useful for non-atomic modesetting. Don't use 232 + * it in new drivers. 233 + * 234 + * Returns: 235 + * An errno code. 236 + */ 237 + int drm_plane_helper_disable_primary(struct drm_plane *plane, 238 + struct drm_modeset_acquire_ctx *ctx) 247 239 { 248 240 return -EINVAL; 249 241 } 242 + EXPORT_SYMBOL(drm_plane_helper_disable_primary); 250 243 251 244 /** 252 - * drm_primary_helper_destroy() - Helper for primary plane destruction 245 + * drm_plane_helper_destroy() - Helper for primary plane destruction 253 246 * @plane: plane to destroy 254 247 * 255 248 * Provides a default plane destroy handler for primary planes. This handler 256 249 * is called during CRTC destruction. We disable the primary plane, remove 257 250 * it from the DRM plane list, and deallocate the plane structure. 258 251 */ 259 - void drm_primary_helper_destroy(struct drm_plane *plane) 252 + void drm_plane_helper_destroy(struct drm_plane *plane) 260 253 { 261 254 drm_plane_cleanup(plane); 262 255 kfree(plane); 263 256 } 264 - EXPORT_SYMBOL(drm_primary_helper_destroy); 265 - 266 - const struct drm_plane_funcs drm_primary_helper_funcs = { 267 - .update_plane = drm_primary_helper_update, 268 - .disable_plane = drm_primary_helper_disable, 269 - .destroy = drm_primary_helper_destroy, 270 - }; 271 - EXPORT_SYMBOL(drm_primary_helper_funcs); 257 + EXPORT_SYMBOL(drm_plane_helper_destroy);
+7 -1
drivers/gpu/drm/nouveau/dispnv04/crtc.c
··· 1275 1275 DRM_FORMAT_XRGB1555, 1276 1276 }; 1277 1277 1278 + static const struct drm_plane_funcs nv04_primary_plane_funcs = { 1279 + .update_plane = drm_plane_helper_update_primary, 1280 + .disable_plane = drm_plane_helper_disable_primary, 1281 + .destroy = drm_plane_helper_destroy, 1282 + }; 1283 + 1278 1284 static struct drm_plane * 1279 1285 create_primary_plane(struct drm_device *dev) 1280 1286 { ··· 1295 1289 1296 1290 /* possible_crtc's will be filled in later by crtc_init */ 1297 1291 ret = drm_universal_plane_init(dev, primary, 0, 1298 - &drm_primary_helper_funcs, 1292 + &nv04_primary_plane_funcs, 1299 1293 modeset_formats, 1300 1294 ARRAY_SIZE(modeset_formats), NULL, 1301 1295 DRM_PLANE_TYPE_PRIMARY, NULL);
+2 -2
drivers/gpu/drm/qxl/qxl_display.c
··· 902 902 static const struct drm_plane_funcs qxl_cursor_plane_funcs = { 903 903 .update_plane = drm_atomic_helper_update_plane, 904 904 .disable_plane = drm_atomic_helper_disable_plane, 905 - .destroy = drm_primary_helper_destroy, 905 + .destroy = drm_plane_helper_destroy, 906 906 .reset = drm_atomic_helper_plane_reset, 907 907 .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, 908 908 .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, ··· 924 924 static const struct drm_plane_funcs qxl_primary_plane_funcs = { 925 925 .update_plane = drm_atomic_helper_update_plane, 926 926 .disable_plane = drm_atomic_helper_disable_plane, 927 - .destroy = drm_primary_helper_destroy, 927 + .destroy = drm_plane_helper_destroy, 928 928 .reset = drm_atomic_helper_plane_reset, 929 929 .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, 930 930 .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
+2 -2
drivers/gpu/drm/vboxvideo/vbox_mode.c
··· 477 477 static const struct drm_plane_funcs vbox_cursor_plane_funcs = { 478 478 .update_plane = drm_atomic_helper_update_plane, 479 479 .disable_plane = drm_atomic_helper_disable_plane, 480 - .destroy = drm_primary_helper_destroy, 480 + .destroy = drm_plane_helper_destroy, 481 481 DRM_GEM_SHADOW_PLANE_FUNCS, 482 482 }; 483 483 ··· 496 496 static const struct drm_plane_funcs vbox_primary_plane_funcs = { 497 497 .update_plane = drm_atomic_helper_update_plane, 498 498 .disable_plane = drm_atomic_helper_disable_plane, 499 - .destroy = drm_primary_helper_destroy, 499 + .destroy = drm_plane_helper_destroy, 500 500 .reset = drm_atomic_helper_plane_reset, 501 501 .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, 502 502 .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
+16 -6
include/drm/drm_plane_helper.h
··· 24 24 #ifndef DRM_PLANE_HELPER_H 25 25 #define DRM_PLANE_HELPER_H 26 26 27 - #include <drm/drm_rect.h> 28 - #include <drm/drm_crtc.h> 29 - #include <drm/drm_modeset_helper_vtables.h> 30 - #include <drm/drm_modeset_helper.h> 27 + #include <linux/types.h> 31 28 32 - void drm_primary_helper_destroy(struct drm_plane *plane); 33 - extern const struct drm_plane_funcs drm_primary_helper_funcs; 29 + struct drm_crtc; 30 + struct drm_framebuffer; 31 + struct drm_modeset_acquire_ctx; 32 + struct drm_plane; 33 + 34 + int drm_plane_helper_update_primary(struct drm_plane *plane, struct drm_crtc *crtc, 35 + struct drm_framebuffer *fb, 36 + int crtc_x, int crtc_y, 37 + unsigned int crtc_w, unsigned int crtc_h, 38 + uint32_t src_x, uint32_t src_y, 39 + uint32_t src_w, uint32_t src_h, 40 + struct drm_modeset_acquire_ctx *ctx); 41 + int drm_plane_helper_disable_primary(struct drm_plane *plane, 42 + struct drm_modeset_acquire_ctx *ctx); 43 + void drm_plane_helper_destroy(struct drm_plane *plane); 34 44 35 45 #endif