Module Name:    src
Committed By:   wiz
Date:           Wed Mar 10 07:23:42 UTC 2021

Modified Files:
        src/share/man/man4: drm.4
        src/sys/arch/amd64/conf: GENERIC
        src/sys/external/bsd/drm2/dist/drm: drm_modes.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/share/man/man4/drm.4
cvs rdiff -u -r1.587 -r1.588 src/sys/arch/amd64/conf/GENERIC
cvs rdiff -u -r1.8 -r1.9 src/sys/external/bsd/drm2/dist/drm/drm_modes.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man4/drm.4
diff -u src/share/man/man4/drm.4:1.17 src/share/man/man4/drm.4:1.18
--- src/share/man/man4/drm.4:1.17	Wed Jul 18 16:41:53 2018
+++ src/share/man/man4/drm.4	Wed Mar 10 07:23:42 2021
@@ -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:

Index: src/sys/arch/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.587 src/sys/arch/amd64/conf/GENERIC:1.588
--- src/sys/arch/amd64/conf/GENERIC:1.587	Wed Mar 10 06:38:44 2021
+++ src/sys/arch/amd64/conf/GENERIC	Wed Mar 10 07:23:42 2021
@@ -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

Index: src/sys/external/bsd/drm2/dist/drm/drm_modes.c
diff -u src/sys/external/bsd/drm2/dist/drm/drm_modes.c:1.8 src/sys/external/bsd/drm2/dist/drm/drm_modes.c:1.9
--- src/sys/external/bsd/drm2/dist/drm/drm_modes.c:1.8	Fri Feb 14 04:38:36 2020
+++ src/sys/external/bsd/drm2/dist/drm/drm_modes.c	Wed Mar 10 07:23:42 2021
@@ -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 <sys/cdefs.h>
-__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 <linux/list.h>
 #include <linux/list_sort.h>
@@ -1019,9 +1019,19 @@ drm_mode_validate_size(const struct drm_
 	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);

Reply via email to