diff options
Diffstat (limited to 'drivers/gpu/drm/drm_modes.c')
-rw-r--r-- | drivers/gpu/drm/drm_modes.c | 62 |
1 files changed, 44 insertions, 18 deletions
diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index 4a3f68a33844..c397b523c945 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c | |||
@@ -833,7 +833,7 @@ EXPORT_SYMBOL(drm_mode_get_hv_timing); | |||
833 | */ | 833 | */ |
834 | void drm_mode_set_crtcinfo(struct drm_display_mode *p, int adjust_flags) | 834 | void drm_mode_set_crtcinfo(struct drm_display_mode *p, int adjust_flags) |
835 | { | 835 | { |
836 | if ((p == NULL) || ((p->type & DRM_MODE_TYPE_CRTC_C) == DRM_MODE_TYPE_BUILTIN)) | 836 | if (!p) |
837 | return; | 837 | return; |
838 | 838 | ||
839 | p->crtc_clock = p->clock; | 839 | p->crtc_clock = p->clock; |
@@ -1023,19 +1023,18 @@ bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1, | |||
1023 | } | 1023 | } |
1024 | EXPORT_SYMBOL(drm_mode_equal_no_clocks_no_stereo); | 1024 | EXPORT_SYMBOL(drm_mode_equal_no_clocks_no_stereo); |
1025 | 1025 | ||
1026 | /** | 1026 | static enum drm_mode_status |
1027 | * drm_mode_validate_basic - make sure the mode is somewhat sane | ||
1028 | * @mode: mode to check | ||
1029 | * | ||
1030 | * Check that the mode timings are at least somewhat reasonable. | ||
1031 | * Any hardware specific limits are left up for each driver to check. | ||
1032 | * | ||
1033 | * Returns: | ||
1034 | * The mode status | ||
1035 | */ | ||
1036 | enum drm_mode_status | ||
1037 | drm_mode_validate_basic(const struct drm_display_mode *mode) | 1027 | drm_mode_validate_basic(const struct drm_display_mode *mode) |
1038 | { | 1028 | { |
1029 | if (mode->type & ~DRM_MODE_TYPE_ALL) | ||
1030 | return MODE_BAD; | ||
1031 | |||
1032 | if (mode->flags & ~DRM_MODE_FLAG_ALL) | ||
1033 | return MODE_BAD; | ||
1034 | |||
1035 | if ((mode->flags & DRM_MODE_FLAG_3D_MASK) > DRM_MODE_FLAG_3D_MAX) | ||
1036 | return MODE_BAD; | ||
1037 | |||
1039 | if (mode->clock == 0) | 1038 | if (mode->clock == 0) |
1040 | return MODE_CLOCK_LOW; | 1039 | return MODE_CLOCK_LOW; |
1041 | 1040 | ||
@@ -1053,7 +1052,35 @@ drm_mode_validate_basic(const struct drm_display_mode *mode) | |||
1053 | 1052 | ||
1054 | return MODE_OK; | 1053 | return MODE_OK; |
1055 | } | 1054 | } |
1056 | EXPORT_SYMBOL(drm_mode_validate_basic); | 1055 | |
1056 | /** | ||
1057 | * drm_mode_validate_driver - make sure the mode is somewhat sane | ||
1058 | * @dev: drm device | ||
1059 | * @mode: mode to check | ||
1060 | * | ||
1061 | * First do basic validation on the mode, and then allow the driver | ||
1062 | * to check for device/driver specific limitations via the optional | ||
1063 | * &drm_mode_config_helper_funcs.mode_valid hook. | ||
1064 | * | ||
1065 | * Returns: | ||
1066 | * The mode status | ||
1067 | */ | ||
1068 | enum drm_mode_status | ||
1069 | drm_mode_validate_driver(struct drm_device *dev, | ||
1070 | const struct drm_display_mode *mode) | ||
1071 | { | ||
1072 | enum drm_mode_status status; | ||
1073 | |||
1074 | status = drm_mode_validate_basic(mode); | ||
1075 | if (status != MODE_OK) | ||
1076 | return status; | ||
1077 | |||
1078 | if (dev->mode_config.funcs->mode_valid) | ||
1079 | return dev->mode_config.funcs->mode_valid(dev, mode); | ||
1080 | else | ||
1081 | return MODE_OK; | ||
1082 | } | ||
1083 | EXPORT_SYMBOL(drm_mode_validate_driver); | ||
1057 | 1084 | ||
1058 | /** | 1085 | /** |
1059 | * drm_mode_validate_size - make sure modes adhere to size constraints | 1086 | * drm_mode_validate_size - make sure modes adhere to size constraints |
@@ -1555,6 +1582,7 @@ void drm_mode_convert_to_umode(struct drm_mode_modeinfo *out, | |||
1555 | 1582 | ||
1556 | /** | 1583 | /** |
1557 | * drm_crtc_convert_umode - convert a modeinfo into a drm_display_mode | 1584 | * drm_crtc_convert_umode - convert a modeinfo into a drm_display_mode |
1585 | * @dev: drm device | ||
1558 | * @out: drm_display_mode to return to the user | 1586 | * @out: drm_display_mode to return to the user |
1559 | * @in: drm_mode_modeinfo to use | 1587 | * @in: drm_mode_modeinfo to use |
1560 | * | 1588 | * |
@@ -1564,7 +1592,8 @@ void drm_mode_convert_to_umode(struct drm_mode_modeinfo *out, | |||
1564 | * Returns: | 1592 | * Returns: |
1565 | * Zero on success, negative errno on failure. | 1593 | * Zero on success, negative errno on failure. |
1566 | */ | 1594 | */ |
1567 | int drm_mode_convert_umode(struct drm_display_mode *out, | 1595 | int drm_mode_convert_umode(struct drm_device *dev, |
1596 | struct drm_display_mode *out, | ||
1568 | const struct drm_mode_modeinfo *in) | 1597 | const struct drm_mode_modeinfo *in) |
1569 | { | 1598 | { |
1570 | int ret = -EINVAL; | 1599 | int ret = -EINVAL; |
@@ -1574,9 +1603,6 @@ int drm_mode_convert_umode(struct drm_display_mode *out, | |||
1574 | goto out; | 1603 | goto out; |
1575 | } | 1604 | } |
1576 | 1605 | ||
1577 | if ((in->flags & DRM_MODE_FLAG_3D_MASK) > DRM_MODE_FLAG_3D_MAX) | ||
1578 | goto out; | ||
1579 | |||
1580 | out->clock = in->clock; | 1606 | out->clock = in->clock; |
1581 | out->hdisplay = in->hdisplay; | 1607 | out->hdisplay = in->hdisplay; |
1582 | out->hsync_start = in->hsync_start; | 1608 | out->hsync_start = in->hsync_start; |
@@ -1594,7 +1620,7 @@ int drm_mode_convert_umode(struct drm_display_mode *out, | |||
1594 | strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN); | 1620 | strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN); |
1595 | out->name[DRM_DISPLAY_MODE_LEN-1] = 0; | 1621 | out->name[DRM_DISPLAY_MODE_LEN-1] = 0; |
1596 | 1622 | ||
1597 | out->status = drm_mode_validate_basic(out); | 1623 | out->status = drm_mode_validate_driver(dev, out); |
1598 | if (out->status != MODE_OK) | 1624 | if (out->status != MODE_OK) |
1599 | goto out; | 1625 | goto out; |
1600 | 1626 | ||