Wed Mar 10 07:23:42 2021 UTC ()
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.


(wiz)
diff -r1.17 -r1.18 src/share/man/man4/drm.4
diff -r1.587 -r1.588 src/sys/arch/amd64/conf/GENERIC
diff -r1.8 -r1.9 src/sys/external/bsd/drm2/dist/drm/drm_modes.c

cvs diff -r1.17 -r1.18 src/share/man/man4/drm.4 (expand / switch to unified diff)

--- src/share/man/man4/drm.4 2018/07/18 16:41:53 1.17
+++ src/share/man/man4/drm.4 2021/03/10 07:23:42 1.18
@@ -1,56 +1,58 @@ @@ -1,56 +1,58 @@
1.\" $NetBSD: drm.4,v 1.17 2018/07/18 16:41:53 wiz Exp $ 1.\" $NetBSD: drm.4,v 1.18 2021/03/10 07:23:42 wiz Exp $
2.\" 2.\"
3.\" Copyright (c) 2007, 2013 Thomas Klausner 3.\" Copyright (c) 2007, 2013 Thomas Klausner
4.\" All rights reserved. 4.\" All rights reserved.
5.\" 5.\"
6.\" Redistribution and use in source and binary forms, with or without 6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions 7.\" modification, are permitted provided that the following conditions
8.\" are met: 8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright 9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer. 10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the 12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution. 13.\" documentation and/or other materials provided with the distribution.
14.\" 14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25.\" 25.\"
26.Dd July 10, 2018 26.Dd March 10, 2021
27.Dt DRM 4 27.Dt DRM 4
28.Os 28.Os
29.Sh NAME 29.Sh NAME
30.Nm drm 30.Nm drm
31.Nd Direct Rendering Manager (DRI kernel support) 31.Nd Direct Rendering Manager (DRI kernel support)
32.Sh SYNOPSIS 32.Sh SYNOPSIS
33.Cd i915drm* at drm? 33.Cd i915drm* at drm?
34.Cd mach64drm* at drm? 34.Cd mach64drm* at drm?
35.Cd mgadrm* at drm? 35.Cd mgadrm* at drm?
36.Cd r128drm* at drm? 36.Cd r128drm* at drm?
37.Cd radeondrm* at drm? 37.Cd radeondrm* at drm?
38.Cd savagedrm* at drm? 38.Cd savagedrm* at drm?
39.Cd sisdrm* at drm? 39.Cd sisdrm* at drm?
40.Cd tdfxdrm* at drm? 40.Cd tdfxdrm* at drm?
41.Pp 41.Pp
42.Cd options DRM_DEBUG 42.Cd options DRM_DEBUG
43.Cd options DRM_NO_AGP 43.Cd options DRM_NO_AGP
 44.Cd options DRM_MAX_RESOLUTION_HORIZONTAL=integer
 45.Cd options DRM_MAX_RESOLUTION_VERTICAL=integer
44.Sh DESCRIPTION 46.Sh DESCRIPTION
45The Direct Rendering Manager is part of the Direct Rendering 47The Direct Rendering Manager is part of the Direct Rendering
46Infrastructure for supporting video acceleration (3d acceleration, 48Infrastructure for supporting video acceleration (3d acceleration,
47mostly). 49mostly).
48.Pp 50.Pp
49The 51The
50.Nm 52.Nm
51drivers provide support for the following chipsets: 53drivers provide support for the following chipsets:
52.Bl -tag -width XsavagedrmXXX -offset indent -compact 54.Bl -tag -width XsavagedrmXXX -offset indent -compact
53.It i915drm 55.It i915drm
54Intel i915, i945 56Intel i915, i945
55.It mach64drm 57.It mach64drm
56Mach64 (3D Rage Pro, Rage) 58Mach64 (3D Rage Pro, Rage)
@@ -78,26 +80,35 @@ instead may be sufficient), @@ -78,26 +80,35 @@ instead may be sufficient),
78.Xr X 7 80.Xr X 7
79must be compiled with DRI support, Mesa DRI drivers must be installed, 81must be compiled with DRI support, Mesa DRI drivers must be installed,
80the appropriate 82the appropriate
81.Pa /dev/dri/card* 83.Pa /dev/dri/card*
82device must exist, and DRI must be enabled in the X configuration 84device must exist, and DRI must be enabled in the X configuration
83file. 85file.
84.Xr X 7 86.Xr X 7
85provided with 87provided with
86.Nx 88.Nx
87and compiled from 89and compiled from
88.Xr pkgsrc 7 90.Xr pkgsrc 7
89do so automatically where supported. 91do so automatically where supported.
90.Pp 92.Pp
 93With some drivers (at least
 94.Xr radeon 4 ) ,
 95in some cases the driver does not choose the resolution correctly.
 96The options
 97.Dv DRM_MAX_RESOLUTION_HORIZONTAL
 98and
 99.Dv DRM_MAX_RESOLUTION_VERTICAL
 100allow limiting the maximum resolution in X and Y direction.
 101.Pp
91.Xr X 7 102.Xr X 7
92will attempt to create the device node automatically. 103will attempt to create the device node automatically.
93To create the device node manually: 104To create the device node manually:
94.Bd -literal -offset indent 105.Bd -literal -offset indent
95mkdir -p /dev/dri 106mkdir -p /dev/dri
96mknod /dev/dri/card0 c 180 0 107mknod /dev/dri/card0 c 180 0
97chgrp wheel /dev/dri/card0 108chgrp wheel /dev/dri/card0
98chmod 0660 /dev/dri/card0 109chmod 0660 /dev/dri/card0
99.Ed 110.Ed
100.Pp 111.Pp
101To enable DRI in the X configuration add the following to either 112To enable DRI in the X configuration add the following to either
102.Pa xorg.conf 113.Pa xorg.conf
103for 114for

cvs diff -r1.587 -r1.588 src/sys/arch/amd64/conf/GENERIC (expand / switch to unified diff)

--- src/sys/arch/amd64/conf/GENERIC 2021/03/10 06:38:44 1.587
+++ src/sys/arch/amd64/conf/GENERIC 2021/03/10 07:23:42 1.588
@@ -1,38 +1,38 @@ @@ -1,38 +1,38 @@
1# $NetBSD: GENERIC,v 1.587 2021/03/10 06:38:44 msaitoh Exp $ 1# $NetBSD: GENERIC,v 1.588 2021/03/10 07:23:42 wiz Exp $
2# 2#
3# GENERIC machine description file 3# GENERIC machine description file
4# 4#
5# This machine description file is used to generate the default NetBSD 5# This machine description file is used to generate the default NetBSD
6# kernel. The generic kernel does not include all options, subsystems 6# kernel. The generic kernel does not include all options, subsystems
7# and device drivers, but should be useful for most applications. 7# and device drivers, but should be useful for most applications.
8# 8#
9# The machine description file can be customised for your specific 9# The machine description file can be customised for your specific
10# machine to reduce the kernel size and improve its performance. 10# machine to reduce the kernel size and improve its performance.
11# 11#
12# For further information on compiling NetBSD kernels, see the config(8) 12# For further information on compiling NetBSD kernels, see the config(8)
13# man page. 13# man page.
14# 14#
15# For further information on hardware support for this architecture, see 15# For further information on hardware support for this architecture, see
16# the intro(4) man page. For further information about kernel options 16# the intro(4) man page. For further information about kernel options
17# for this architecture, see the options(4) man page. For an explanation 17# for this architecture, see the options(4) man page. For an explanation
18# of each device driver in this file see the section 4 man page for the 18# of each device driver in this file see the section 4 man page for the
19# device. 19# device.
20 20
21include "arch/amd64/conf/std.amd64" 21include "arch/amd64/conf/std.amd64"
22 22
23options INCLUDE_CONFIG_FILE # embed config file in kernel binary 23options INCLUDE_CONFIG_FILE # embed config file in kernel binary
24 24
25#ident "GENERIC-$Revision: 1.587 $" 25#ident "GENERIC-$Revision: 1.588 $"
26 26
27maxusers 64 # estimated number of users 27maxusers 64 # estimated number of users
28 28
29# delay between "rebooting ..." message and hardware reset, in milliseconds 29# delay between "rebooting ..." message and hardware reset, in milliseconds
30#options CPURESET_DELAY=2000 30#options CPURESET_DELAY=2000
31 31
32# This option allows you to force a serial console at the specified 32# This option allows you to force a serial console at the specified
33# I/O address. see console(4) for details. 33# I/O address. see console(4) for details.
34#options CONSDEVNAME="\"com\"",CONADDR=0x2f8,CONSPEED=57600 34#options CONSDEVNAME="\"com\"",CONADDR=0x2f8,CONSPEED=57600
35# you don't want the option below ON iff you are using the 35# you don't want the option below ON iff you are using the
36# serial console option of the new boot strap code. 36# serial console option of the new boot strap code.
37#options CONS_OVERRIDE # Always use above! independent of boot info 37#options CONS_OVERRIDE # Always use above! independent of boot info
38 38
@@ -446,26 +446,29 @@ intelfb* at intelfbbus? @@ -446,26 +446,29 @@ intelfb* at intelfbbus?
446 446
447radeon* at pci? dev ? function ? 447radeon* at pci? dev ? function ?
448radeondrmkmsfb* at radeonfbbus? 448radeondrmkmsfb* at radeonfbbus?
449 449
450#amdgpu* at pci? dev ? function ? 450#amdgpu* at pci? dev ? function ?
451#amdgpufb* at amdgpufbbus? 451#amdgpufb* at amdgpufbbus?
452 452
453nouveau* at pci? dev ? function ? 453nouveau* at pci? dev ? function ?
454nouveaufb* at nouveaufbbus? 454nouveaufb* at nouveaufbbus?
455 455
456# DRMUMS drivers 456# DRMUMS drivers
457#viadrmums* at drm? 457#viadrmums* at drm?
458 458
 459#options DRM_MAX_RESOLUTION_HORIZONTAL=1920 # Limit DRM size in horizontal dimension
 460#options DRM_MAX_RESOLUTION_VERTICAL=1080 # Limit DRM size in vertical dimension
 461
459# Cryptographic Devices 462# Cryptographic Devices
460 463
461# PCI cryptographic devices 464# PCI cryptographic devices
462amdccp* at pci? dev ? function ? # AMD Cryptographic Coprocessor 465amdccp* at pci? dev ? function ? # AMD Cryptographic Coprocessor
463hifn* at pci? dev ? function ? # Hifn 7755/7811/795x 466hifn* at pci? dev ? function ? # Hifn 7755/7811/795x
464#qat* at pci? dev ? function ? # Intel QuickAssist 467#qat* at pci? dev ? function ? # Intel QuickAssist
465ubsec* at pci? dev ? function ? # Broadcom 5501/5601/580x/582x 468ubsec* at pci? dev ? function ? # Broadcom 5501/5601/580x/582x
466 469
467# Trusted Platform Module 470# Trusted Platform Module
468tpm* at isa? iomem 0xfed40000 irq 7 471tpm* at isa? iomem 0xfed40000 irq 7
469 472
470# Serial Devices 473# Serial Devices
471 474

cvs diff -r1.8 -r1.9 src/sys/external/bsd/drm2/dist/drm/drm_modes.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/dist/drm/drm_modes.c 2020/02/14 04:38:36 1.8
+++ src/sys/external/bsd/drm2/dist/drm/drm_modes.c 2021/03/10 07:23:42 1.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: drm_modes.c,v 1.8 2020/02/14 04:38:36 riastradh Exp $ */ 1/* $NetBSD: drm_modes.c,v 1.9 2021/03/10 07:23:42 wiz Exp $ */
2 2
3/* 3/*
4 * Copyright © 1997-2003 by The XFree86 Project, Inc. 4 * Copyright © 1997-2003 by The XFree86 Project, Inc.
5 * Copyright © 2007 Dave Airlie 5 * Copyright © 2007 Dave Airlie
6 * Copyright © 2007-2008 Intel Corporation 6 * Copyright © 2007-2008 Intel Corporation
7 * Jesse Barnes <jesse.barnes@intel.com> 7 * Jesse Barnes <jesse.barnes@intel.com>
8 * Copyright 2005-2006 Luc Verhaegen 8 * Copyright 2005-2006 Luc Verhaegen
9 * Copyright (c) 2001, Andy Ritger aritger@nvidia.com 9 * Copyright (c) 2001, Andy Ritger aritger@nvidia.com
10 * 10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a 11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"), 12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation 13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
@@ -23,27 +23,27 @@ @@ -23,27 +23,27 @@
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 24 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE. 27 * OTHER DEALINGS IN THE SOFTWARE.
28 * 28 *
29 * Except as contained in this notice, the name of the copyright holder(s) 29 * Except as contained in this notice, the name of the copyright holder(s)
30 * and author(s) shall not be used in advertising or otherwise to promote 30 * and author(s) shall not be used in advertising or otherwise to promote
31 * the sale, use or other dealings in this Software without prior written 31 * the sale, use or other dealings in this Software without prior written
32 * authorization from the copyright holder(s) and author(s). 32 * authorization from the copyright holder(s) and author(s).
33 */ 33 */
34 34
35#include <sys/cdefs.h> 35#include <sys/cdefs.h>
36__KERNEL_RCSID(0, "$NetBSD: drm_modes.c,v 1.8 2020/02/14 04:38:36 riastradh Exp $"); 36__KERNEL_RCSID(0, "$NetBSD: drm_modes.c,v 1.9 2021/03/10 07:23:42 wiz Exp $");
37 37
38#include <linux/list.h> 38#include <linux/list.h>
39#include <linux/list_sort.h> 39#include <linux/list_sort.h>
40#include <linux/export.h> 40#include <linux/export.h>
41#include <drm/drmP.h> 41#include <drm/drmP.h>
42#include <drm/drm_crtc.h> 42#include <drm/drm_crtc.h>
43#ifdef CONFIG_VIDEOMODE_HELPERS 43#ifdef CONFIG_VIDEOMODE_HELPERS
44#ifdef CONFIG_OF 44#ifdef CONFIG_OF
45#include <video/of_videomode.h> 45#include <video/of_videomode.h>
46#endif 46#endif
47#include <video/videomode.h> 47#include <video/videomode.h>
48#endif 48#endif
49#include <drm/drm_modes.h> 49#include <drm/drm_modes.h>
@@ -1009,29 +1009,39 @@ EXPORT_SYMBOL(drm_mode_validate_basic); @@ -1009,29 +1009,39 @@ EXPORT_SYMBOL(drm_mode_validate_basic);
1009 * member is updated with the appropriate validation failure code. The list 1009 * member is updated with the appropriate validation failure code. The list
1010 * itself is not changed. 1010 * itself is not changed.
1011 * 1011 *
1012 * Returns: 1012 * Returns:
1013 * The mode status 1013 * The mode status
1014 */ 1014 */
1015enum drm_mode_status 1015enum drm_mode_status
1016drm_mode_validate_size(const struct drm_display_mode *mode, 1016drm_mode_validate_size(const struct drm_display_mode *mode,
1017 int maxX, int maxY) 1017 int maxX, int maxY)
1018{ 1018{
1019 if (maxX > 0 && mode->hdisplay > maxX) 1019 if (maxX > 0 && mode->hdisplay > maxX)
1020 return MODE_VIRTUAL_X; 1020 return MODE_VIRTUAL_X;
1021 1021
 1022#if defined(DRM_MAX_RESOLUTION_HORIZONTAL)
 1023 if (mode->hdisplay > DRM_MAX_RESOLUTION_HORIZONTAL)
 1024 return MODE_VIRTUAL_X;
 1025#endif
 1026
1022 if (maxY > 0 && mode->vdisplay > maxY) 1027 if (maxY > 0 && mode->vdisplay > maxY)
1023 return MODE_VIRTUAL_Y; 1028 return MODE_VIRTUAL_Y;
1024 1029
 1030#if defined(DRM_MAX_RESOLUTION_VERTICAL)
 1031 if (mode->vdisplay > DRM_MAX_RESOLUTION_VERTICAL)
 1032 return MODE_VIRTUAL_Y;
 1033#endif
 1034
1025 return MODE_OK; 1035 return MODE_OK;
1026} 1036}
1027EXPORT_SYMBOL(drm_mode_validate_size); 1037EXPORT_SYMBOL(drm_mode_validate_size);
1028 1038
1029#define MODE_STATUS(status) [MODE_ ## status + 3] = #status 1039#define MODE_STATUS(status) [MODE_ ## status + 3] = #status
1030 1040
1031static const char * const drm_mode_status_names[] = { 1041static const char * const drm_mode_status_names[] = {
1032 MODE_STATUS(OK), 1042 MODE_STATUS(OK),
1033 MODE_STATUS(HSYNC), 1043 MODE_STATUS(HSYNC),
1034 MODE_STATUS(VSYNC), 1044 MODE_STATUS(VSYNC),
1035 MODE_STATUS(H_ILLEGAL), 1045 MODE_STATUS(H_ILLEGAL),
1036 MODE_STATUS(V_ILLEGAL), 1046 MODE_STATUS(V_ILLEGAL),
1037 MODE_STATUS(BAD_WIDTH), 1047 MODE_STATUS(BAD_WIDTH),