summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/amd64/amd64/efifb.c60
-rw-r--r--sys/arch/amd64/amd64/mainbus.c4
-rw-r--r--sys/arch/amd64/conf/GENERIC12
-rw-r--r--sys/arch/amd64/include/efifbvar.h7
-rw-r--r--sys/arch/i386/conf/GENERIC10
-rw-r--r--sys/conf/files4
-rw-r--r--sys/dev/pci/drm/drm_drv.c14
-rw-r--r--sys/dev/pci/drm/files.drm4
-rw-r--r--sys/dev/pci/drm/i915/i915_drv.c47
-rw-r--r--sys/dev/pci/drm/i915/i915_drv.h1
-rw-r--r--sys/dev/pci/drm/include/drm/drmP.h11
-rw-r--r--sys/dev/pci/drm/radeon/radeon.h1
-rw-r--r--sys/dev/pci/drm/radeon/radeon_kms.c29
-rw-r--r--sys/dev/wscons/wsdisplay.c15
-rw-r--r--sys/dev/wscons/wsdisplayvar.h10
15 files changed, 160 insertions, 69 deletions
diff --git a/sys/arch/amd64/amd64/efifb.c b/sys/arch/amd64/amd64/efifb.c
index 2a4b44084bd..72c71276f40 100644
--- a/sys/arch/amd64/amd64/efifb.c
+++ b/sys/arch/amd64/amd64/efifb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: efifb.c,v 1.23 2019/03/28 14:35:29 fcambus Exp $ */
+/* $OpenBSD: efifb.c,v 1.24 2019/05/04 11:34:47 kettenis Exp $ */
/*
* Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net>
@@ -31,6 +31,8 @@
#include <machine/biosvar.h>
#include <machine/efifbvar.h>
+extern void mainbus_efifb_reattach(void);
+
/* coreboot tables */
struct cb_header {
@@ -79,7 +81,6 @@ struct efifb {
int depth;
paddr_t paddr;
psize_t psize;
- int detached;
struct cb_framebuffer cb_table_fb;
};
@@ -142,6 +143,7 @@ struct cfdriver efifb_cd = {
NULL, "efifb", DV_DULL
};
+int efifb_detached;
struct efifb efifb_console;
struct wsdisplay_charcell efifb_bs[EFIFB_HEIGHT * EFIFB_WIDTH];
@@ -150,17 +152,17 @@ efifb_match(struct device *parent, void *cf, void *aux)
{
struct efifb_attach_args *eaa = aux;
+ if (efifb_detached)
+ return 0;
+
if (strcmp(eaa->eaa_name, efifb_cd.cd_name) == 0) {
- if (efifb_console.paddr != 0) {
- if (efifb_console.detached)
- return (0);
- return (1);
- }
+ if (efifb_console.paddr != 0)
+ return 1;
if (bios_efiinfo != NULL && bios_efiinfo->fb_addr != 0)
- return (1);
+ return 1;
}
- return (0);
+ return 0;
}
void
@@ -501,16 +503,48 @@ efifb_is_console(struct pci_attach_args *pa)
return 0;
}
+int
+efifb_is_primary(struct pci_attach_args *pa)
+{
+ pci_chipset_tag_t pc = pa->pa_pc;
+ pcitag_t tag = pa->pa_tag;
+ pcireg_t type;
+ bus_addr_t base;
+ bus_size_t size;
+ int reg;
+
+ for (reg = PCI_MAPREG_START; reg < PCI_MAPREG_END; reg += 4) {
+ if (!pci_mapreg_probe(pc, tag, reg, &type))
+ continue;
+
+ if (type == PCI_MAPREG_TYPE_IO)
+ continue;
+
+ if (pci_mapreg_info(pc, tag, reg, type, &base, &size, NULL))
+ continue;
+
+ if (bios_efiinfo != NULL && bios_efiinfo->fb_addr != 0)
+ return (1);
+
+ if (type & PCI_MAPREG_MEM_TYPE_64BIT)
+ reg += 4;
+ }
+
+ /* XXX coreboot framebuffer isn't matched above. */
+ return efifb_is_console(pa);;
+}
+
void
-efifb_cndetach(void)
+efifb_detach(void)
{
- efifb_console.detached = 1;
+ efifb_detached = 1;
}
void
-efifb_cnreattach(void)
+efifb_reattach(void)
{
- efifb_console.detached = 0;
+ efifb_detached = 0;
+ mainbus_efifb_reattach();
}
int
diff --git a/sys/arch/amd64/amd64/mainbus.c b/sys/arch/amd64/amd64/mainbus.c
index f4fb3ec02fd..b3da7975883 100644
--- a/sys/arch/amd64/amd64/mainbus.c
+++ b/sys/arch/amd64/amd64/mainbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mainbus.c,v 1.45 2018/09/22 17:41:52 kettenis Exp $ */
+/* $OpenBSD: mainbus.c,v 1.46 2019/05/04 11:34:47 kettenis Exp $ */
/* $NetBSD: mainbus.c,v 1.1 2003/04/26 18:39:29 fvdl Exp $ */
/*
@@ -273,8 +273,8 @@ mainbus_efifb_reattach(void)
{
union mainbus_attach_args mba;
struct device *self = device_mainbus();
+
if (bios_efiinfo != NULL || efifb_cb_found()) {
- efifb_cnreattach();
mba.mba_eaa.eaa_name = "efifb";
config_found(self, &mba, mainbus_print);
}
diff --git a/sys/arch/amd64/conf/GENERIC b/sys/arch/amd64/conf/GENERIC
index b7af8a6498f..0dde82cd342 100644
--- a/sys/arch/amd64/conf/GENERIC
+++ b/sys/arch/amd64/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.468 2019/03/28 09:41:35 kettenis Exp $
+# $OpenBSD: GENERIC,v 1.469 2019/05/04 11:34:47 kettenis Exp $
#
# For further information on compiling OpenBSD kernels, see the config(8)
# man page.
@@ -359,14 +359,14 @@ wsmouse* at pms? mux 0
inteldrm* at pci? # Intel i915, i945 DRM driver
intagp* at inteldrm?
agp* at intagp?
-drm0 at inteldrm? console 1
+drm0 at inteldrm? primary 1
drm* at inteldrm?
-wsdisplay0 at inteldrm? console 1
+wsdisplay0 at inteldrm? primary 1
wsdisplay* at inteldrm? mux -1
radeondrm* at pci? # ATI Radeon DRM driver
-drm0 at radeondrm? console 1
+drm0 at radeondrm? primary 1
drm* at radeondrm?
-wsdisplay0 at radeondrm? console 1
+wsdisplay0 at radeondrm? primary 1
wsdisplay* at radeondrm? mux -1
pcppi0 at isa?
@@ -389,7 +389,7 @@ lpt0 at isa? port 0x378 irq 7 # standard PC parallel ports
lpt* at puc?
efifb0 at mainbus? # EFI Framebuffer
-wsdisplay0 at efifb? console ?
+wsdisplay0 at efifb?
ahc* at pci? # Adaptec 2940 SCSI controllers
jmb* at pci? # JMicron JMB36x controllers
diff --git a/sys/arch/amd64/include/efifbvar.h b/sys/arch/amd64/include/efifbvar.h
index 0737ea8e5ce..a9bb004a15d 100644
--- a/sys/arch/amd64/include/efifbvar.h
+++ b/sys/arch/amd64/include/efifbvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: efifbvar.h,v 1.9 2019/01/10 01:16:29 jsg Exp $ */
+/* $OpenBSD: efifbvar.h,v 1.10 2019/05/04 11:34:47 kettenis Exp $ */
/*
* Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net>
@@ -28,8 +28,9 @@ struct pci_attach_args;
int efifb_cnattach(void);
void efifb_cnremap(void);
int efifb_is_console(struct pci_attach_args *);
-void efifb_cndetach(void);
-void efifb_cnreattach(void);
+int efifb_is_primary(struct pci_attach_args *);
+void efifb_detach(void);
+void efifb_reattach(void);
int efifb_cb_found(void);
int efifb_cb_cnattach(void);
diff --git a/sys/arch/i386/conf/GENERIC b/sys/arch/i386/conf/GENERIC
index 9fd738a0e5b..166251a5ec2 100644
--- a/sys/arch/i386/conf/GENERIC
+++ b/sys/arch/i386/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.840 2019/03/22 12:07:00 sthen Exp $
+# $OpenBSD: GENERIC,v 1.841 2019/05/04 11:34:47 kettenis Exp $
#
# For further information on compiling OpenBSD kernels, see the config(8)
# man page.
@@ -384,14 +384,14 @@ agp* at viaagp? # AGP bridges
inteldrm* at pci? # Intel i915, i945 DRM driver
intagp* at inteldrm?
agp* at intagp?
-drm0 at inteldrm? console 1
+drm0 at inteldrm? primary 1
drm* at inteldrm?
-wsdisplay0 at inteldrm? console 1
+wsdisplay0 at inteldrm? primary 1
wsdisplay* at inteldrm? mux -1
radeondrm* at pci? # ATI Radeon DRM driver
-drm0 at radeondrm? console 1
+drm0 at radeondrm? primary 1
drm* at radeondrm?
-wsdisplay0 at radeondrm? console 1
+wsdisplay0 at radeondrm? primary 1
wsdisplay* at radeondrm? mux -1
pcppi0 at isa?
diff --git a/sys/conf/files b/sys/conf/files
index 357c7d0f551..17c0c0d2199 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -1,4 +1,4 @@
-# $OpenBSD: files,v 1.670 2019/03/18 17:30:08 anton Exp $
+# $OpenBSD: files,v 1.671 2019/05/04 11:34:47 kettenis Exp $
# $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@@ -74,7 +74,7 @@ define ax88190 # AX88190-family Ethernet controllers
# a wscons output device; used later, but needs to be near the top for
# common file (e.g. vga) definitions.
define wsdisplaydev {[mux = 1]}
-define wsemuldisplaydev {[console = -1], [mux = 1]}
+define wsemuldisplaydev {[console = -1], [primary = -1], [mux = 1]}
define wskbddev {[console = -1], [mux = 1]}
define wsmousedev {[mux = 0]}
diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c
index aed8d64de7c..0a2211ac1c3 100644
--- a/sys/dev/pci/drm/drm_drv.c
+++ b/sys/dev/pci/drm/drm_drv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_drv.c,v 1.161 2019/05/02 09:47:16 kettenis Exp $ */
+/* $OpenBSD: drm_drv.c,v 1.162 2019/05/04 11:34:47 kettenis Exp $ */
/*-
* Copyright 2007-2009 Owain G. Ainsworth <oga@openbsd.org>
* Copyright © 2008 Intel Corporation
@@ -98,7 +98,7 @@ SPLAY_PROTOTYPE(drm_file_tree, drm_file, link, drm_file_cmp);
*/
struct drm_device *
drm_attach_pci(struct drm_driver *driver, struct pci_attach_args *pa,
- int is_agp, int console, struct device *dev, struct drm_device *drm)
+ int is_agp, int primary, struct device *dev, struct drm_device *drm)
{
struct drm_attach_args arg;
struct drm_softc *sc;
@@ -109,7 +109,7 @@ drm_attach_pci(struct drm_driver *driver, struct pci_attach_args *pa,
arg.dmat = pa->pa_dmat;
arg.bst = pa->pa_memt;
arg.is_agp = is_agp;
- arg.console = console;
+ arg.primary = primary;
arg.pci_vendor = PCI_VENDOR(pa->pa_id);
arg.pci_device = PCI_PRODUCT(pa->pa_id);
@@ -180,18 +180,18 @@ drm_probe(struct device *parent, void *match, void *aux)
struct cfdata *cf = match;
struct drm_attach_args *da = aux;
- if (cf->drmdevcf_console != DRMDEVCF_CONSOLE_UNK) {
+ if (cf->drmdevcf_primary != DRMDEVCF_PRIMARY_UNK) {
/*
- * If console-ness of device specified, either match
+ * If primary-ness of device specified, either match
* exactly (at high priority), or fail.
*/
- if (cf->drmdevcf_console != 0 && da->console != 0)
+ if (cf->drmdevcf_primary != 0 && da->primary != 0)
return (10);
else
return (0);
}
- /* If console-ness unspecified, it wins. */
+ /* If primary-ness unspecified, it wins. */
return (1);
}
diff --git a/sys/dev/pci/drm/files.drm b/sys/dev/pci/drm/files.drm
index 3538bcd9d3d..4128ae94672 100644
--- a/sys/dev/pci/drm/files.drm
+++ b/sys/dev/pci/drm/files.drm
@@ -1,8 +1,8 @@
# $NetBSD: files.drm,v 1.2 2007/03/28 11:29:37 jmcneill Exp $
-# $OpenBSD: files.drm,v 1.43 2019/04/14 10:14:51 jsg Exp $
+# $OpenBSD: files.drm,v 1.44 2019/05/04 11:34:47 kettenis Exp $
# direct rendering modules
-define drmbase {[console = -1]}
+define drmbase {[primary = -1]}
device drm: drmbase
attach drm at drmbase
file dev/pci/drm/drm_agpsupport.c drm & agp
diff --git a/sys/dev/pci/drm/i915/i915_drv.c b/sys/dev/pci/drm/i915/i915_drv.c
index 67f9b15ba09..94328f76178 100644
--- a/sys/dev/pci/drm/i915/i915_drv.c
+++ b/sys/dev/pci/drm/i915/i915_drv.c
@@ -3106,6 +3106,7 @@ static struct drm_driver driver = {
#ifdef __amd64__
#include "efifb.h"
+#include <machine/biosvar.h>
#endif
#if NEFIFB > 0
@@ -3432,11 +3433,18 @@ struct cfdriver inteldrm_cd = {
void inteldrm_init_backlight(struct inteldrm_softc *);
int inteldrm_intr(void *);
+/*
+ * Set if the mountroot hook has a fatal error.
+ */
+int inteldrm_fatal_error;
+
int
inteldrm_match(struct device *parent, void *match, void *aux)
{
struct pci_attach_args *pa = aux;
+ if (inteldrm_fatal_error)
+ return 0;
if (drm_pciprobe(aux, pciidlist) && pa->pa_function == 0)
return 20;
return 0;
@@ -3468,20 +3476,22 @@ inteldrm_attach(struct device *parent, struct device *self, void *aux)
(pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG)
& (PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MEM_ENABLE))
== (PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MEM_ENABLE)) {
+ dev_priv->primary = 1;
+ dev_priv->console = vga_is_console(pa->pa_iot, -1);;
vga_console_attached = 1;
- dev_priv->console = 1;
}
#if NEFIFB > 0
- if (efifb_is_console(pa)) {
- dev_priv->console = 1;
- efifb_cndetach();
+ if (efifb_is_primary(pa)) {
+ dev_priv->primary = 1;
+ dev_priv->console = efifb_is_console(pa);
+ efifb_detach();
}
#endif
printf("\n");
- dev = drm_attach_pci(&driver, pa, 0, dev_priv->console,
+ dev = drm_attach_pci(&driver, pa, 0, dev_priv->primary,
self, &dev_priv->drm);
id = drm_find_description(PCI_VENDOR(pa->pa_id),
@@ -3561,6 +3571,24 @@ inteldrm_attach(struct device *parent, struct device *self, void *aux)
}
void
+inteldrm_forcedetach(struct inteldrm_softc *dev_priv)
+{
+ struct pci_softc *psc = (struct pci_softc *)dev_priv->sc_dev.dv_parent;
+ pcitag_t tag = dev_priv->tag;
+ extern int vga_console_attached;
+
+ if (dev_priv->primary) {
+ vga_console_attached = 0;
+#if NEFIFB > 0
+ efifb_reattach();
+#endif
+ }
+
+ config_detach(&dev_priv->sc_dev, 0);
+ pci_probe_device(psc, tag, NULL, NULL);
+}
+
+void
inteldrm_attachhook(struct device *self)
{
struct inteldrm_softc *dev_priv = (struct inteldrm_softc *)self;
@@ -3570,10 +3598,10 @@ inteldrm_attachhook(struct device *self)
struct drm_device *dev = &dev_priv->drm;
if (i915_driver_load(dev_priv, id))
- return;
+ goto fail;
if (ri->ri_bits == NULL)
- return;
+ goto fail;
printf("%s: %dx%d, %dbpp\n", dev_priv->sc_dev.dv_xname,
ri->ri_width, ri->ri_height, ri->ri_depth);
@@ -3615,6 +3643,7 @@ inteldrm_attachhook(struct device *self)
inteldrm_stdscreen.fontheight = ri->ri_font->fontheight;
aa.console = dev_priv->console;
+ aa.primary = dev_priv->primary;
aa.scrdata = &inteldrm_screenlist;
aa.accessops = &inteldrm_accessops;
aa.accesscookie = dev_priv;
@@ -3638,6 +3667,10 @@ inteldrm_attachhook(struct device *self)
config_found_sm(self, &aa, wsemuldisplaydevprint,
wsemuldisplaydevsubmatch);
return;
+
+fail:
+ inteldrm_fatal_error = 1;
+ inteldrm_forcedetach(dev_priv);
}
int
diff --git a/sys/dev/pci/drm/i915/i915_drv.h b/sys/dev/pci/drm/i915/i915_drv.h
index 3e0aac63a02..3e4606d04f6 100644
--- a/sys/dev/pci/drm/i915/i915_drv.h
+++ b/sys/dev/pci/drm/i915/i915_drv.h
@@ -1721,6 +1721,7 @@ struct inteldrm_softc {
struct drm_pcidev *id;
int console;
+ int primary;
int nscreens;
void (*switchcb)(void *, int, int);
void *switchcbarg;
diff --git a/sys/dev/pci/drm/include/drm/drmP.h b/sys/dev/pci/drm/include/drm/drmP.h
index 080f74426e0..3e388f34bae 100644
--- a/sys/dev/pci/drm/include/drm/drmP.h
+++ b/sys/dev/pci/drm/include/drm/drmP.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: drmP.h,v 1.1 2019/04/14 10:14:52 jsg Exp $ */
+/* $OpenBSD: drmP.h,v 1.2 2019/05/04 11:34:48 kettenis Exp $ */
/* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
*/
@@ -239,13 +239,12 @@ struct drm_attach_args {
pci_chipset_tag_t pc;
pcitag_t tag;
pcitag_t *bridgetag;
- int console;
+ int primary;
};
-#define DRMDEVCF_CONSOLE 0
-#define drmdevcf_console cf_loc[DRMDEVCF_CONSOLE]
-/* spec'd as console? */
-#define DRMDEVCF_CONSOLE_UNK -1
+#define DRMDEVCF_PRIMARY 0
+#define drmdevcf_primary cf_loc[DRMDEVCF_PRIMARY] /* spec'd as primary? */
+#define DRMDEVCF_PRIMARY_UNK -1
extern int drm_debug_flag;
diff --git a/sys/dev/pci/drm/radeon/radeon.h b/sys/dev/pci/drm/radeon/radeon.h
index 595543c4fbe..fe098d02de3 100644
--- a/sys/dev/pci/drm/radeon/radeon.h
+++ b/sys/dev/pci/drm/radeon/radeon.h
@@ -2341,6 +2341,7 @@ struct radeon_device {
struct task switchtask;
struct rasops_info ro;
int console;
+ int primary;
struct task burner_task;
int burner_fblank;
diff --git a/sys/dev/pci/drm/radeon/radeon_kms.c b/sys/dev/pci/drm/radeon/radeon_kms.c
index 3fb81fa4222..a12106fcbbe 100644
--- a/sys/dev/pci/drm/radeon/radeon_kms.c
+++ b/sys/dev/pci/drm/radeon/radeon_kms.c
@@ -45,6 +45,11 @@ static inline bool radeon_has_atpx(void) { return false; }
#include "vga.h"
#if NVGA > 0
+#include <dev/ic/mc6845reg.h>
+#include <dev/ic/pcdisplayvar.h>
+#include <dev/ic/vgareg.h>
+#include <dev/ic/vgavar.h>
+
extern int vga_console_attached;
#endif
@@ -484,22 +489,25 @@ radeondrm_attach_kms(struct device *parent, struct device *self, void *aux)
#if defined(__sparc64__) || defined(__macppc__)
if (fbnode == PCITAG_NODE(rdev->pa_tag))
- rdev->console = 1;
+ rdev->console = rdev->primary = 1;
#else
if (PCI_CLASS(pa->pa_class) == PCI_CLASS_DISPLAY &&
PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_DISPLAY_VGA &&
(pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG)
& (PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MEM_ENABLE))
== (PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MEM_ENABLE)) {
- rdev->console = 1;
+ rdev->primary = 1;
#if NVGA > 0
+ rdev->console = vga_is_console(pa->pa_iot, -1);
vga_console_attached = 1;
#endif
}
+
#if NEFIFB > 0
- if (efifb_is_console(pa)) {
- rdev->console = 1;
- efifb_cndetach();
+ if (efifb_is_primary(pa)) {
+ rdev->primary = 1;
+ rdev->console = efifb_is_console(pa);
+ efifb_detach();
}
#endif
#endif
@@ -628,7 +636,7 @@ radeondrm_attach_kms(struct device *parent, struct device *self, void *aux)
kms_driver.num_ioctls = radeon_max_kms_ioctl;
kms_driver.driver_features |= DRIVER_MODESET;
- dev = drm_attach_pci(&kms_driver, pa, is_agp, rdev->console,
+ dev = drm_attach_pci(&kms_driver, pa, is_agp, rdev->primary,
self, NULL);
rdev->ddev = dev;
rdev->pdev = dev->pdev;
@@ -696,8 +704,6 @@ radeondrm_attach_kms(struct device *parent, struct device *self, void *aux)
config_mountroot(self, radeondrm_attachhook);
}
-extern void mainbus_efifb_reattach(void);
-
int
radeondrm_forcedetach(struct radeon_device *rdev)
{
@@ -705,7 +711,7 @@ radeondrm_forcedetach(struct radeon_device *rdev)
pcitag_t tag = rdev->pa_tag;
#if NVGA > 0
- if (rdev->console)
+ if (rdev->primary)
vga_console_attached = 0;
#endif
@@ -716,8 +722,8 @@ radeondrm_forcedetach(struct radeon_device *rdev)
config_detach(&rdev->self, 0);
return pci_probe_device(sc, tag, NULL, NULL);
#if NEFIFB > 0
- } else if (rdev->console) {
- mainbus_efifb_reattach();
+ } else if (rdev->primary) {
+ efifb_reattach();
}
#endif
@@ -807,6 +813,7 @@ radeondrm_attachhook(struct device *self)
radeondrm_stdscreen.fontheight = ri->ri_font->fontheight;
aa.console = rdev->console;
+ aa.primary = rdev->primary;
aa.scrdata = &radeondrm_screenlist;
aa.accessops = &radeondrm_accessops;
aa.accesscookie = ri;
diff --git a/sys/dev/wscons/wsdisplay.c b/sys/dev/wscons/wsdisplay.c
index b713695a916..e8da462bed3 100644
--- a/sys/dev/wscons/wsdisplay.c
+++ b/sys/dev/wscons/wsdisplay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsdisplay.c,v 1.131 2018/02/19 08:59:52 mpi Exp $ */
+/* $OpenBSD: wsdisplay.c,v 1.132 2019/05/04 11:34:48 kettenis Exp $ */
/* $NetBSD: wsdisplay.c,v 1.82 2005/02/27 00:27:52 perry Exp $ */
/*
@@ -529,7 +529,18 @@ wsdisplay_emul_match(struct device *parent, void *match, void *aux)
return (0);
}
- /* If console-ness unspecified, it wins. */
+ if (cf->wsemuldisplaydevcf_primary != WSEMULDISPLAYDEVCF_PRIMARY_UNK) {
+ /*
+ * If primary-ness of device specified, either match
+ * exactly (at high priority), or fail.
+ */
+ if (cf->wsemuldisplaydevcf_primary != 0 && ap->primary != 0)
+ return (10);
+ else
+ return (0);
+ }
+
+ /* If console-ness and primary-ness unspecified, it wins. */
return (1);
}
diff --git a/sys/dev/wscons/wsdisplayvar.h b/sys/dev/wscons/wsdisplayvar.h
index 995d09200ea..211b44c79a3 100644
--- a/sys/dev/wscons/wsdisplayvar.h
+++ b/sys/dev/wscons/wsdisplayvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsdisplayvar.h,v 1.31 2017/07/19 14:34:10 kettenis Exp $ */
+/* $OpenBSD: wsdisplayvar.h,v 1.32 2019/05/04 11:34:48 kettenis Exp $ */
/* $NetBSD: wsdisplayvar.h,v 1.30 2005/02/04 02:10:49 perry Exp $ */
/*
@@ -160,6 +160,7 @@ struct wsscreen_list {
*/
struct wsemuldisplaydev_attach_args {
int console; /* is it console? */
+ int primary; /* is it primry? */
const struct wsscreen_list *scrdata; /* screen cfg info */
const struct wsdisplay_accessops *accessops; /* access ops */
void *accesscookie; /* access cookie */
@@ -169,10 +170,13 @@ struct wsemuldisplaydev_attach_args {
#define WSEMULDISPLAYDEVCF_CONSOLE 0
#define wsemuldisplaydevcf_console cf_loc[WSEMULDISPLAYDEVCF_CONSOLE] /* spec'd as console? */
#define WSEMULDISPLAYDEVCF_CONSOLE_UNK -1
+#define WSEMULDISPLAYDEVCF_PRIMARY 1
+#define wsemuldisplaydevcf_primary cf_loc[WSEMULDISPLAYDEVCF_PRIMARY] /* spec'd as primary? */
+#define WSEMULDISPLAYDEVCF_PRIMARY_UNK -1
+#define WSEMULDISPLAYDEVCF_MUX 2
+#define wsemuldisplaydevcf_mux cf_loc[WSEMULDISPLAYDEVCF_MUX]
#define WSDISPLAYDEVCF_MUX 0
#define wsdisplaydevcf_mux cf_loc[WSDISPLAYDEVCF_MUX]
-#define WSEMULDISPLAYDEVCF_MUX 1
-#define wsemuldisplaydevcf_mux cf_loc[WSEMULDISPLAYDEVCF_MUX]
struct wscons_syncops {
int (*detach)(void *, int, void (*)(void *, int, int), void *);