summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2008-03-16 19:00:29 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2008-03-16 19:00:29 +0000
commitc5322cc7f26f297d89d5739341558d77a823ca0a (patch)
tree89262368ac92e725ff85a9bd6201003c7e69d4c7 /sys/dev
parent68d85f5a89fb982d3c281c6c189cd217dc0d9ae0 (diff)
Make agp(4) attach at vga(4) instead of pchb(4). This is because sometimes
agp and drm need to use the same memory mapping, the best way to deal with that is to allow them to share (that's coming later), for this to work cleanly we move the attach point of agp. Ideally most agp drivers would attach at pchb, with only agp_i810 (and any that work similarly) attaching at vga, but this will do for now. ok kettenis@, miod@.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/vga.c18
-rw-r--r--sys/dev/pci/agp.c7
-rw-r--r--sys/dev/pci/agpvar.h4
-rw-r--r--sys/dev/pci/files.agp22
-rw-r--r--sys/dev/pci/vga_pci.c89
5 files changed, 119 insertions, 21 deletions
diff --git a/sys/dev/ic/vga.c b/sys/dev/ic/vga.c
index e7458f9456d..0f64441b4a0 100644
--- a/sys/dev/ic/vga.c
+++ b/sys/dev/ic/vga.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vga.c,v 1.46 2007/10/01 04:03:51 krw Exp $ */
+/* $OpenBSD: vga.c,v 1.47 2008/03/16 19:00:28 oga Exp $ */
/* $NetBSD: vga.c,v 1.28.2.1 2000/06/30 16:27:47 simonb Exp $ */
/*
@@ -100,6 +100,8 @@ int vga_alloc_attr(void *, int, int, int, long *);
void vga_copyrows(void *, int, int, int);
void vga_unpack_attr(void *, long, int *, int *, int *);
+int displaysubmatch(struct device *, void *, void *);
+
static const struct wsdisplay_emulops vga_emulops = {
pcdisplay_cursor,
vga_mapchar,
@@ -545,7 +547,19 @@ vga_extended_attach(self, iot, memt, type, map)
aa.accesscookie = vc;
aa.defaultscreens = 0;
- config_found(self, &aa, wsemuldisplaydevprint);
+ config_found_sm(self, &aa, wsemuldisplaydevprint, displaysubmatch);
+}
+
+int
+displaysubmatch(struct device *parent, void *match, void *aux)
+{
+ extern struct cfdriver wsdisplay_cd;
+ struct cfdata *cf = match;
+
+ /* only allow wsdisplay to attach */
+ if (cf->cf_driver == &wsdisplay_cd)
+ return ((*cf->cf_attach->ca_match)(parent, match, aux));
+ return (0);
}
int
diff --git a/sys/dev/pci/agp.c b/sys/dev/pci/agp.c
index 49bcbef2704..05526203d67 100644
--- a/sys/dev/pci/agp.c
+++ b/sys/dev/pci/agp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: agp.c,v 1.16 2008/01/04 00:23:26 kettenis Exp $ */
+/* $OpenBSD: agp.c,v 1.17 2008/03/16 19:00:28 oga Exp $ */
/*-
* Copyright (c) 2000 Doug Rabson
* All rights reserved.
@@ -110,6 +110,11 @@ agp_probe(struct device *parent, void *match, void *aux)
struct agpbus_attach_args *aaa = aux;
struct pci_attach_args *pa = &aaa->apa_pci_args;
+ /* pci_args must be a pchb */
+ if (PCI_CLASS(pa->pa_class) != PCI_CLASS_BRIDGE ||
+ PCI_SUBCLASS(pa->pa_class) != PCI_SUBCLASS_BRIDGE_HOST)
+ return (0);
+
if (agp_lookup(pa) == NULL)
return (0);
diff --git a/sys/dev/pci/agpvar.h b/sys/dev/pci/agpvar.h
index ecceb70dd88..2f8b9d9a495 100644
--- a/sys/dev/pci/agpvar.h
+++ b/sys/dev/pci/agpvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: agpvar.h,v 1.10 2007/12/07 17:35:22 oga Exp $ */
+/* $OpenBSD: agpvar.h,v 1.11 2008/03/16 19:00:28 oga Exp $ */
/* $NetBSD: agpvar.h,v 1.4 2001/10/01 21:54:48 fvdl Exp $ */
/*-
@@ -44,7 +44,6 @@
#define AGPUNIT(x) minor(x)
struct agpbus_attach_args {
- char *apa_busname;
struct pci_attach_args apa_pci_args;
};
@@ -174,6 +173,7 @@ paddr_t agpmmap(void *, off_t, int);
int agpioctl(dev_t, u_long, caddr_t, int, struct proc *);
int agpopen(dev_t, int, int, struct proc *);
int agpclose(dev_t, int, int , struct proc *);
+void agp_set_pchb(struct pci_attach_args*);
/*
* Functions private to the AGP code.
*/
diff --git a/sys/dev/pci/files.agp b/sys/dev/pci/files.agp
index e1b5249e1f3..cdd86684e62 100644
--- a/sys/dev/pci/files.agp
+++ b/sys/dev/pci/files.agp
@@ -1,31 +1,27 @@
-# $OpenBSD: files.agp,v 1.1 2007/11/25 17:11:12 oga Exp $
+# $OpenBSD: files.agp,v 1.2 2008/03/16 19:00:28 oga Exp $
-define agpbus { }
-
-device agp
-attach agp at agpbus
file dev/pci/agp.c agp needs-flag
define agp_ali
-file dev/pci/agp_ali.c agp_ali & agp needs-flag
+file dev/pci/agp_ali.c agp_ali & agpbus needs-flag
define agp_amd
-file dev/pci/agp_amd.c agp_amd & agp needs-flag
+file dev/pci/agp_amd.c agp_amd & agpbus needs-flag
define agp_apple
-file dev/pci/agp_apple.c agp_apple & agp needs-flag
+file dev/pci/agp_apple.c agp_apple & agpbus needs-flag
define agp_i810
-file dev/pci/agp_i810.c agp_i810 & agp needs-flag
+file dev/pci/agp_i810.c agp_i810 & agpbus needs-flag
define agp_intel
-file dev/pci/agp_intel.c agp_intel & agp needs-flag
+file dev/pci/agp_intel.c agp_intel & agpbus needs-flag
define agp_sis
-file dev/pci/agp_sis.c agp_sis & agp needs-flag
+file dev/pci/agp_sis.c agp_sis & agpbus needs-flag
define agp_via
-file dev/pci/agp_via.c agp_via & agp needs-flag
+file dev/pci/agp_via.c agp_via & agpbus needs-flag
define agp_amd64
-file dev/pci/agp_amd64.c agp_amd64 & agp needs-flag
+file dev/pci/agp_amd64.c agp_amd64 & agpbus needs-flag
diff --git a/sys/dev/pci/vga_pci.c b/sys/dev/pci/vga_pci.c
index 6f8abdb67c3..7caf597c200 100644
--- a/sys/dev/pci/vga_pci.c
+++ b/sys/dev/pci/vga_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vga_pci.c,v 1.29 2007/11/28 23:37:34 oga Exp $ */
+/* $OpenBSD: vga_pci.c,v 1.30 2008/03/16 19:00:28 oga Exp $ */
/* $NetBSD: vga_pci.c,v 1.3 1998/06/08 06:55:58 thorpej Exp $ */
/*
@@ -79,6 +79,8 @@
#include <dev/pci/pcivar.h>
#include <dev/pci/pcidevs.h>
+#include <dev/pci/agpvar.h>
+
#include <dev/ic/mc6845reg.h>
#include <dev/ic/pcdisplayvar.h>
#include <dev/ic/vgareg.h>
@@ -93,12 +95,21 @@
#include <dev/vesa/vesabiosvar.h>
#endif
+#include "agp.h"
#include "drmbase.h"
int vga_pci_match(struct device *, void *, void *);
void vga_pci_attach(struct device *, struct device *, void *);
paddr_t vga_pci_mmap(void* v, off_t off, int prot);
-int vga_drm_print(void *, const char *);
+
+#if NAGP > 0
+int agpsubmatch(struct device *, void *, void *);
+int agpbus_print(void *, const char *);
+#endif
+#if NDRMBASE > 0
+int drmsubmatch(struct device *, void *, void *);
+int vga_drm_print(void *, const char *);
+#endif
#ifdef VESAFB
int vesafb_putcmap(struct vga_pci_softc *, struct wsdisplay_cmap *);
@@ -109,6 +120,20 @@ struct cfattach vga_pci_ca = {
sizeof(struct vga_pci_softc), vga_pci_match, vga_pci_attach,
};
+#if NAGP > 0
+struct pci_attach_args agp_pchb_pa;
+int agp_pchb_pa_set = 0;
+
+void
+agp_set_pchb(struct pci_attach_args *pa)
+{
+ if (!agp_pchb_pa_set) {
+ memcpy(&agp_pchb_pa, pa, sizeof *pa);
+ agp_pchb_pa_set++;
+ }
+}
+#endif
+
int
vga_pci_match(struct device *parent, void *match, void *aux)
{
@@ -140,6 +165,9 @@ void
vga_pci_attach(struct device *parent, struct device *self, void *aux)
{
struct pci_attach_args *pa = aux;
+#if NAGP >0
+ struct agpbus_attach_args aba;
+#endif
pcireg_t reg;
#ifdef VESAFB
struct vga_pci_softc *sc = (struct vga_pci_softc *)self;
@@ -165,11 +193,65 @@ vga_pci_attach(struct device *parent, struct device *self, void *aux)
vga_common_attach(self, pa->pa_iot, pa->pa_memt,
WSDISPLAY_TYPE_PCIVGA);
+#if NAGP > 0
+ /*
+ * attach agp here instead of pchb so it can share mappings
+ * with the DRM
+ */
+ if (agp_pchb_pa_set) {
+ aba.apa_pci_args = agp_pchb_pa;
+ config_found_sm(self, &aba, agpbus_print, agpsubmatch);
+
+ }
+#endif
+
#if NDRMBASE > 0
- config_found(self, aux, vga_drm_print);
+ config_found_sm(self, aux, vga_drm_print, drmsubmatch);
#endif
}
+#if NAGP > 0
+int
+agpsubmatch(struct device *parent, void *match, void *aux)
+{
+ extern struct cfdriver agp_cd;
+ struct cfdata *cf = match;
+
+ /* only allow agp to attach */
+ if (cf->cf_driver == &agp_cd)
+ return ((*cf->cf_attach->ca_match)(parent, match, aux));
+ return (0);
+}
+
+int
+agpbus_print(void *vaa, const char *pnp)
+{
+ if (pnp)
+ printf("agp at %s", pnp);
+ return (UNCONF);
+}
+#endif
+
+#if NDRMBASE > 0
+int
+drmsubmatch(struct device *parent, void *match, void *aux)
+{
+ struct cfdata *cf = match;
+ struct cfdriver *cd;
+ size_t len = 0;
+ char *sm;
+
+ cd = cf->cf_driver;
+
+ /* is this a *drm device? */
+ len = strlen(cd->cd_name);
+ sm = cd->cd_name + len -3;
+ if (strncmp(sm,"drm",3) == 0)
+ return ((*cf->cf_attach->ca_match)(parent, match, aux));
+
+ return (0);
+}
+
int
vga_drm_print(void *aux, const char *pnp)
{
@@ -177,6 +259,7 @@ vga_drm_print(void *aux, const char *pnp)
printf("direct rendering for %s", pnp);
return (UNSUPP);
}
+#endif
paddr_t
vga_pci_mmap(void *v, off_t off, int prot)