diff options
Diffstat (limited to 'drivers/gpu/drm/drm_modes.c')
-rw-r--r-- | drivers/gpu/drm/drm_modes.c | 56 |
1 files changed, 44 insertions, 12 deletions
diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index 6d8b941c8200..11cc4deca55b 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c | |||
@@ -906,9 +906,40 @@ bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1, | |||
906 | EXPORT_SYMBOL(drm_mode_equal_no_clocks_no_stereo); | 906 | EXPORT_SYMBOL(drm_mode_equal_no_clocks_no_stereo); |
907 | 907 | ||
908 | /** | 908 | /** |
909 | * drm_mode_validate_basic - make sure the mode is somewhat sane | ||
910 | * @mode: mode to check | ||
911 | * | ||
912 | * Check that the mode timings are at least somewhat reasonable. | ||
913 | * Any hardware specific limits are left up for each driver to check. | ||
914 | * | ||
915 | * Returns: | ||
916 | * The mode status | ||
917 | */ | ||
918 | enum drm_mode_status | ||
919 | drm_mode_validate_basic(const struct drm_display_mode *mode) | ||
920 | { | ||
921 | if (mode->clock == 0) | ||
922 | return MODE_CLOCK_LOW; | ||
923 | |||
924 | if (mode->hdisplay == 0 || | ||
925 | mode->hsync_start < mode->hdisplay || | ||
926 | mode->hsync_end < mode->hsync_start || | ||
927 | mode->htotal < mode->hsync_end) | ||
928 | return MODE_H_ILLEGAL; | ||
929 | |||
930 | if (mode->vdisplay == 0 || | ||
931 | mode->vsync_start < mode->vdisplay || | ||
932 | mode->vsync_end < mode->vsync_start || | ||
933 | mode->vtotal < mode->vsync_end) | ||
934 | return MODE_V_ILLEGAL; | ||
935 | |||
936 | return MODE_OK; | ||
937 | } | ||
938 | EXPORT_SYMBOL(drm_mode_validate_basic); | ||
939 | |||
940 | /** | ||
909 | * drm_mode_validate_size - make sure modes adhere to size constraints | 941 | * drm_mode_validate_size - make sure modes adhere to size constraints |
910 | * @dev: DRM device | 942 | * @mode: mode to check |
911 | * @mode_list: list of modes to check | ||
912 | * @maxX: maximum width | 943 | * @maxX: maximum width |
913 | * @maxY: maximum height | 944 | * @maxY: maximum height |
914 | * | 945 | * |
@@ -916,20 +947,21 @@ EXPORT_SYMBOL(drm_mode_equal_no_clocks_no_stereo); | |||
916 | * limitations of the DRM device/connector. If a mode is too big its status | 947 | * limitations of the DRM device/connector. If a mode is too big its status |
917 | * member is updated with the appropriate validation failure code. The list | 948 | * member is updated with the appropriate validation failure code. The list |
918 | * itself is not changed. | 949 | * itself is not changed. |
950 | * | ||
951 | * Returns: | ||
952 | * The mode status | ||
919 | */ | 953 | */ |
920 | void drm_mode_validate_size(struct drm_device *dev, | 954 | enum drm_mode_status |
921 | struct list_head *mode_list, | 955 | drm_mode_validate_size(const struct drm_display_mode *mode, |
922 | int maxX, int maxY) | 956 | int maxX, int maxY) |
923 | { | 957 | { |
924 | struct drm_display_mode *mode; | 958 | if (maxX > 0 && mode->hdisplay > maxX) |
959 | return MODE_VIRTUAL_X; | ||
925 | 960 | ||
926 | list_for_each_entry(mode, mode_list, head) { | 961 | if (maxY > 0 && mode->vdisplay > maxY) |
927 | if (maxX > 0 && mode->hdisplay > maxX) | 962 | return MODE_VIRTUAL_Y; |
928 | mode->status = MODE_VIRTUAL_X; | ||
929 | 963 | ||
930 | if (maxY > 0 && mode->vdisplay > maxY) | 964 | return MODE_OK; |
931 | mode->status = MODE_VIRTUAL_Y; | ||
932 | } | ||
933 | } | 965 | } |
934 | EXPORT_SYMBOL(drm_mode_validate_size); | 966 | EXPORT_SYMBOL(drm_mode_validate_size); |
935 | 967 | ||