aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_modes.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2018-02-15 18:29:27 -0500
committerDave Airlie <airlied@redhat.com>2018-02-15 18:29:27 -0500
commit76ea0f334e7fb13226e64ee7de928611f5303faf (patch)
tree4a6b8d8f1b19a68072f2ce8f33add59be9a67be7 /drivers/gpu/drm/drm_modes.c
parentf0308d76906a5b65ec4fcc3b133394caa9f00638 (diff)
parent1bc3d3cce8c3b44c2b5ac6cee98c830bb40e6b0f (diff)
Merge tag 'drm-misc-next-2018-02-13' of git://anongit.freedesktop.org/drm/drm-misc into drm-next
drm-misc-next for 4.17: UAPI Changes: - drm/vc4: Expose performance counters to userspace (Boris) Cross-subsystem Changes: - MAINTAINERS: Linus to maintain panel-arm-versatile in -misc (Linus) Core Changes: - Only use swiotlb when necessary (Chunming) Driver Changes: - drm/panel: Add support for ARM Versatile panels (Linus) - pl111: Improvements around versatile panel support (Linus) ---------------------------------------- Tagged on 2018-02-06: drm-misc-next for 4.17: UAPI Changes: - Validate mode flags + type (Ville) - Deprecate unused mode flags PIXMUX, BCAST (Ville) - Deprecate unused mode types BUILTIN, CRTC_C, CLOCK_C, DEFAULT (Ville) Cross-subsystem Changes: - MAINTAINERS: s/Daniel/Maarten/ for drm-misc (Daniel) Core Changes: - gem: Export gem functions for drivers to use (Samuel) - bridge: Introduce bridge timings in drm_bridge (Linus) - dma-buf: Allow exclusive fence to be bundled in fence array when calling reservation_object_get_fences_rcu (Christian) - dp: Add training pattern 4 and HBR3 support to dp helpers (Manasi) - fourcc: Add alpha bit to formats to avoid driver format LUTs (Maxime) - mode: Various cleanups + add new device-wide .mode_valid hook (Ville) - atomic: Fix state leak when non-blocking commits fail (Leo) NOTE: IIRC, this was cross-picked to -fixes so it might fall out - crc: Allow polling on the data fd (Maarten) Driver Changes: - bridge/vga-dac: Add THS8134* support (Linus) - tinydrm: Various MIPI DBI improvements/cleanups (Noralf) - bridge/dw-mipi-dsi: Cleanups + use create_packet helper (Brian) - drm/sun4i: Add Display Engine frontend support (Maxime) - drm/sun4i: Add zpos support + increase num planes from 2 to 4 (Maxime) - various: Use drm_mode_get_hv_timing() to fill plane clip rectangle (Ville) - stm: Add 8-bit clut support, add dsi phy v1.31 support, +fixes (Phillipe) Cc: Boris Brezillon <boris.brezillon@free-electrons.com> Cc: Chunming Zhou <david1.zhou@amd.com> Cc: Samuel Li <Samuel.Li@amd.com> Cc: Linus Walleij <linus.walleij@linaro.org> Cc: Noralf Trønnes <noralf@tronnes.org> Cc: Brian Norris <briannorris@chromium.org> Cc: Maxime Ripard <maxime.ripard@free-electrons.com> Cc: Ville Syrjala <ville.syrjala@linux.intel.com> Cc: Christian König <christian.koenig@amd.com> Cc: Manasi Navare <manasi.d.navare@intel.com> Cc: Philippe Cornu <philippe.cornu@st.com> Cc: Leo (Sunpeng) Li <sunpeng.li@amd.com> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> * tag 'drm-misc-next-2018-02-13' of git://anongit.freedesktop.org/drm/drm-misc: (115 commits) drm/radeon: only enable swiotlb path when need v2 drm/amdgpu: only enable swiotlb alloc when need v2 drm: add func to get max iomem address v2 drm/vc4: Expose performance counters to userspace drm: Print the pid when debug logging an ioctl error. drm/stm: ltdc: remove non-alpha color formats on layer 2 for older hw drm/stm: ltdc: add non-alpha color formats drm/bridge/synopsys: dsi: Add 1.31 version support drm/bridge/synopsys: dsi: Add read feature drm/pl111: Support multiple endpoints on the CLCD drm/pl111: Support variants with broken VBLANK drm/pl111: Support variants with broken clock divider drm/pl111: Handle the Versatile RGB/BGR565 mode drm/pl111: Properly detect the ARM PL110 variants drm/panel: Add support for ARM Versatile panels drm/panel: Device tree bindings for ARM Versatile panels drm/bridge: Rename argument from crtc to bridge drm/crc: Add support for polling on the data fd. drm/sun4i: Use drm_mode_get_hv_timing() to populate plane clip rectangle drm/rcar-du: Use drm_mode_get_hv_timing() to populate plane clip rectangle ...
Diffstat (limited to 'drivers/gpu/drm/drm_modes.c')
-rw-r--r--drivers/gpu/drm/drm_modes.c62
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 */
834void drm_mode_set_crtcinfo(struct drm_display_mode *p, int adjust_flags) 834void 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}
1024EXPORT_SYMBOL(drm_mode_equal_no_clocks_no_stereo); 1024EXPORT_SYMBOL(drm_mode_equal_no_clocks_no_stereo);
1025 1025
1026/** 1026static 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 */
1036enum drm_mode_status
1037drm_mode_validate_basic(const struct drm_display_mode *mode) 1027drm_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}
1056EXPORT_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 */
1068enum drm_mode_status
1069drm_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}
1083EXPORT_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 */
1567int drm_mode_convert_umode(struct drm_display_mode *out, 1595int 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