From 279c4abbecfc0dc6ff757811f12fe9f6cc6a85ee Mon Sep 17 00:00:00 2001 From: wiz Date: Wed, 10 Mar 2021 07:23:42 +0000 Subject: [PATCH] drm(4): allow limiting maximum X/Y resolution With some drivers (at least radeon(4)), in some cases the driver does not choose the resolution correctly. The options DRM_MAX_RESOLUTION_HORIZONTAL and DRM_MAX_RESOLUTION_VERTICAL allow limiting the maximum resolution in X and Y direction. --- share/man/man4/drm.4 | 15 +++++++++++++-- sys/arch/amd64/conf/GENERIC | 7 +++++-- sys/external/bsd/drm2/dist/drm/drm_modes.c | 14 ++++++++++++-- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/share/man/man4/drm.4 b/share/man/man4/drm.4 index ac90a32d74d0..16585e8174c4 100644 --- a/share/man/man4/drm.4 +++ b/share/man/man4/drm.4 @@ -1,4 +1,4 @@ -.\" $NetBSD: drm.4,v 1.17 2018/07/18 16:41:53 wiz Exp $ +.\" $NetBSD: drm.4,v 1.18 2021/03/10 07:23:42 wiz Exp $ .\" .\" Copyright (c) 2007, 2013 Thomas Klausner .\" All rights reserved. @@ -23,7 +23,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd July 10, 2018 +.Dd March 10, 2021 .Dt DRM 4 .Os .Sh NAME @@ -41,6 +41,8 @@ .Pp .Cd options DRM_DEBUG .Cd options DRM_NO_AGP +.Cd options DRM_MAX_RESOLUTION_HORIZONTAL=integer +.Cd options DRM_MAX_RESOLUTION_VERTICAL=integer .Sh DESCRIPTION The Direct Rendering Manager is part of the Direct Rendering Infrastructure for supporting video acceleration (3d acceleration, @@ -88,6 +90,15 @@ and compiled from .Xr pkgsrc 7 do so automatically where supported. .Pp +With some drivers (at least +.Xr radeon 4 ) , +in some cases the driver does not choose the resolution correctly. +The options +.Dv DRM_MAX_RESOLUTION_HORIZONTAL +and +.Dv DRM_MAX_RESOLUTION_VERTICAL +allow limiting the maximum resolution in X and Y direction. +.Pp .Xr X 7 will attempt to create the device node automatically. To create the device node manually: diff --git a/sys/arch/amd64/conf/GENERIC b/sys/arch/amd64/conf/GENERIC index c290e07bff3c..79d8e4d43471 100644 --- a/sys/arch/amd64/conf/GENERIC +++ b/sys/arch/amd64/conf/GENERIC @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.587 2021/03/10 06:38:44 msaitoh Exp $ +# $NetBSD: GENERIC,v 1.588 2021/03/10 07:23:42 wiz Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ include "arch/amd64/conf/std.amd64" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.587 $" +#ident "GENERIC-$Revision: 1.588 $" maxusers 64 # estimated number of users @@ -456,6 +456,9 @@ nouveaufb* at nouveaufbbus? # DRMUMS drivers #viadrmums* at drm? +#options DRM_MAX_RESOLUTION_HORIZONTAL=1920 # Limit DRM size in horizontal dimension +#options DRM_MAX_RESOLUTION_VERTICAL=1080 # Limit DRM size in vertical dimension + # Cryptographic Devices # PCI cryptographic devices diff --git a/sys/external/bsd/drm2/dist/drm/drm_modes.c b/sys/external/bsd/drm2/dist/drm/drm_modes.c index 5e21dc097b7f..6428ed62e007 100644 --- a/sys/external/bsd/drm2/dist/drm/drm_modes.c +++ b/sys/external/bsd/drm2/dist/drm/drm_modes.c @@ -1,4 +1,4 @@ -/* $NetBSD: drm_modes.c,v 1.8 2020/02/14 04:38:36 riastradh Exp $ */ +/* $NetBSD: drm_modes.c,v 1.9 2021/03/10 07:23:42 wiz Exp $ */ /* * Copyright © 1997-2003 by The XFree86 Project, Inc. @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: drm_modes.c,v 1.8 2020/02/14 04:38:36 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: drm_modes.c,v 1.9 2021/03/10 07:23:42 wiz Exp $"); #include #include @@ -1019,9 +1019,19 @@ drm_mode_validate_size(const struct drm_display_mode *mode, if (maxX > 0 && mode->hdisplay > maxX) return MODE_VIRTUAL_X; +#if defined(DRM_MAX_RESOLUTION_HORIZONTAL) + if (mode->hdisplay > DRM_MAX_RESOLUTION_HORIZONTAL) + return MODE_VIRTUAL_X; +#endif + if (maxY > 0 && mode->vdisplay > maxY) return MODE_VIRTUAL_Y; +#if defined(DRM_MAX_RESOLUTION_VERTICAL) + if (mode->vdisplay > DRM_MAX_RESOLUTION_VERTICAL) + return MODE_VIRTUAL_Y; +#endif + return MODE_OK; } EXPORT_SYMBOL(drm_mode_validate_size);