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

drm/atomic-helper: Add helper drm_atomic_helper_check_crtc_state()

Add drm_atomic_helper_check_crtc_state(), which contains tests common
to many CRTCs. The first added test verifies that an enabled CRTC has
at least one enabled primary plane.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220617103226.25617-2-tzimmermann@suse.de

+57
+55
drivers/gpu/drm/drm_atomic_helper.c
··· 878 878 EXPORT_SYMBOL(drm_atomic_helper_check_plane_state); 879 879 880 880 /** 881 + * drm_atomic_helper_check_crtc_state() - Check CRTC state for validity 882 + * @crtc_state: CRTC state to check 883 + * @can_disable_primary_planes: can the CRTC be enabled without a primary plane? 884 + * 885 + * Checks that a desired CRTC update is valid. Drivers that provide 886 + * their own CRTC handling rather than helper-provided implementations may 887 + * still wish to call this function to avoid duplication of error checking 888 + * code. 889 + * 890 + * Note that @can_disable_primary_planes only tests if the CRTC can be 891 + * enabled without a primary plane. To test if a primary plane can be updated 892 + * without a CRTC, use drm_atomic_helper_check_plane_state() in the plane's 893 + * atomic check. 894 + * 895 + * RETURNS: 896 + * Zero if update appears valid, error code on failure 897 + */ 898 + int drm_atomic_helper_check_crtc_state(struct drm_crtc_state *crtc_state, 899 + bool can_disable_primary_planes) 900 + { 901 + struct drm_device *dev = crtc_state->crtc->dev; 902 + struct drm_atomic_state *state = crtc_state->state; 903 + 904 + if (!crtc_state->enable) 905 + return 0; 906 + 907 + /* needs at least one primary plane to be enabled */ 908 + if (!can_disable_primary_planes) { 909 + bool has_primary_plane = false; 910 + struct drm_plane *plane; 911 + 912 + drm_for_each_plane_mask(plane, dev, crtc_state->plane_mask) { 913 + struct drm_plane_state *plane_state; 914 + 915 + if (plane->type != DRM_PLANE_TYPE_PRIMARY) 916 + continue; 917 + plane_state = drm_atomic_get_plane_state(state, plane); 918 + if (IS_ERR(plane_state)) 919 + return PTR_ERR(plane_state); 920 + if (plane_state->fb && plane_state->crtc) { 921 + has_primary_plane = true; 922 + break; 923 + } 924 + } 925 + if (!has_primary_plane) { 926 + drm_dbg_kms(dev, "Cannot enable CRTC without a primary plane.\n"); 927 + return -EINVAL; 928 + } 929 + } 930 + 931 + return 0; 932 + } 933 + EXPORT_SYMBOL(drm_atomic_helper_check_crtc_state); 934 + 935 + /** 881 936 * drm_atomic_helper_check_planes - validate state object for planes changes 882 937 * @dev: DRM device 883 938 * @state: the driver state object
+2
include/drm/drm_atomic_helper.h
··· 46 46 int max_scale, 47 47 bool can_position, 48 48 bool can_update_disabled); 49 + int drm_atomic_helper_check_crtc_state(struct drm_crtc_state *crtc_state, 50 + bool can_disable_primary_plane); 49 51 int drm_atomic_helper_check_planes(struct drm_device *dev, 50 52 struct drm_atomic_state *state); 51 53 int drm_atomic_helper_check(struct drm_device *dev,