tech-x11 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: patch for netbsd-5 and drm



On Sat, Jun 20, 2009 at 05:43:18PM +1000, matthew green wrote:
> 
> hi folks.
> 
> i've ported the great work for drm to netbsd-5 branch.  there
> are two files:
> 
>        http://www.netbsd.org/~mrg/drm.netbsd-5.diff
>        http://www.netbsd.org/~mrg/drm-external-patch-5.diff
> 
> the first one is small and patches files outside of src/sys/external/drm
> and the latter patches all the files inside there.
> 
> 
> i have tested it on netbsd-5 on amd64 with pkgsrc xorg.  works
> on my x1550 card.

The following patch (to be applied on top of Matt's two patches), fixes things
up so at least all the DRM drivers compile correctly and the resulting kernel
links on amd64.

I've done no verification of it beyond that, but since I likely won't be able
to actually play with the results for another day or two, I thought I'd send
it out in case there are willing testers for the other DRM drivers.

Thanks again to Matt and everyone who helped get us here!
--rafal

-- 
  Time is an illusion; lunchtime, doubly so.     |/\/\|           Rafal Boni
                   -- Ford Prefect               |\/\/|      
rafal%pobox.com@localhost
diff --git a/sys/external/bsd/drm/dist/bsd-core/mach64_drv.c 
b/sys/external/bsd/drm/dist/bsd-core/mach64_drv.c
index 2cc0ef1..0eb3618 100644
--- a/sys/external/bsd/drm/dist/bsd-core/mach64_drv.c
+++ b/sys/external/bsd/drm/dist/bsd-core/mach64_drv.c
@@ -44,6 +44,12 @@ static drm_pci_id_list_t mach64_pciidlist[] = {
        mach64_PCI_IDS
 };
 
+int
+mach64_driver_load(struct drm_device * dev, unsigned long flags)
+{
+        return drm_vblank_init(dev, 1);
+}
+
 static void mach64_configure(struct drm_device *dev)
 {
        dev->driver->driver_features =
@@ -73,6 +79,8 @@ static void mach64_configure(struct drm_device *dev)
        dev->driver->patchlevel         = DRIVER_PATCHLEVEL;
 }
 
+#if defined(__FreeBSD__)
+
 static int
 mach64_probe(device_t kdev)
 {
@@ -92,12 +100,6 @@ mach64_attach(device_t kdev)
        return drm_attach(kdev, mach64_pciidlist);
 }
 
-int
-mach64_driver_load(struct drm_device * dev, unsigned long flags)
-{
-        return drm_vblank_init(dev, 1);
-}
-
 static int
 mach64_detach(device_t kdev)
 {
@@ -133,3 +135,89 @@ DRIVER_MODULE(mach64, vgapci, mach64_driver, drm_devclass, 
0, 0);
 DRIVER_MODULE(mach64, pci, mach64_driver, drm_devclass, 0, 0);
 #endif
 MODULE_DEPEND(mach64, drm, 1, 1, 1);
+
+#elif   defined(__NetBSD__)
+
+static int
+mach64drm_probe(device_t parent, cfdata_t match, void *aux)
+{
+       struct pci_attach_args *pa = aux;
+       return drm_probe(pa, mach64_pciidlist);
+}
+
+static void
+mach64drm_attach(device_t parent, device_t self, void *aux)
+{
+       struct pci_attach_args *pa = aux;
+       struct drm_device *dev = device_private(self);
+
+       dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER,
+           M_WAITOK | M_ZERO);
+
+       mach64_configure(dev);
+
+       drm_attach(self, pa, mach64_pciidlist);
+}
+
+CFATTACH_DECL_NEW(mach64drm, sizeof(struct drm_device),
+    mach64drm_probe, mach64drm_attach, drm_detach, drm_activate);
+
+#ifdef _MODULE
+
+MODULE(MODULE_CLASS_DRIVER, mach64drm, NULL);
+
+CFDRIVER_DECL(mach64drm, DV_DULL, NULL);
+extern struct cfattach mach64drm_ca;
+static int drmloc[] = { -1 };
+static struct cfparent drmparent = {
+       "drm", "vga", DVUNIT_ANY
+};
+static struct cfdata mach64drm_cfdata[] = {
+       {
+               .cf_name = "mach64drm",
+               .cf_atname = "mach64drm",
+               .cf_unit = 0,
+               .cf_fstate = FSTATE_STAR,
+               .cf_loc = drmloc,
+               .cf_flags = 0,
+               .cf_pspec = &drmparent,
+       },
+       { NULL }
+};
+
+static int
+mach64drm_modcmd(modcmd_t cmd, void *arg)
+{
+       int err;
+
+       switch (cmd) {
+       case MODULE_CMD_INIT:
+               err = config_cfdriver_attach(&mach64drm_cd);
+               if (err)
+                       return err;
+               err = config_cfattach_attach("mach64drm", &mach64drm_ca);
+               if (err) {
+                       config_cfdriver_detach(&mach64drm_cd);
+                       return err;
+               }
+               err = config_cfdata_attach(mach64drm_cfdata, 1);
+               if (err) {
+                       config_cfattach_detach("mach64drm", &mach64drm_ca);
+                       config_cfdriver_detach(&mach64drm_cd);
+                       return err;
+               }
+               return 0;
+       case MODULE_CMD_FINI:
+               err = config_cfdata_detach(mach64drm_cfdata);
+               if (err)
+                       return err;
+               config_cfattach_detach("mach64drm", &mach64drm_ca);
+               config_cfdriver_detach(&mach64drm_cd);
+               return 0;
+       default:
+               return ENOTTY;
+       }
+}
+#endif /* _MODULE */
+
+#endif
diff --git a/sys/external/bsd/drm/dist/bsd-core/mga_drv.c 
b/sys/external/bsd/drm/dist/bsd-core/mga_drv.c
index d72215f..65c4050 100644
--- a/sys/external/bsd/drm/dist/bsd-core/mga_drv.c
+++ b/sys/external/bsd/drm/dist/bsd-core/mga_drv.c
@@ -61,8 +61,6 @@ static drm_pci_id_list_t mga_pciidlist[] = {
  */
 static int mga_driver_device_is_agp(struct drm_device * dev)
 {
-       device_t bus;
-
        /* There are PCI versions of the G450.  These cards have the
         * same PCI ID as the AGP G450, but have an additional PCI-to-PCI
         * bridge chip.  We detect these cards, which are not currently
@@ -71,6 +69,9 @@ static int mga_driver_device_is_agp(struct drm_device * dev)
         * device is 0x0021 (HB6 Universal PCI-PCI bridge), we reject the
         * device.
         */
+#if defined(__FreeBSD__)
+       device_t bus;
+
 #if __FreeBSD_version >= 700010
        bus = device_get_parent(device_get_parent(dev->device));
 #else
@@ -82,6 +83,10 @@ static int mga_driver_device_is_agp(struct drm_device * dev)
                return DRM_IS_NOT_AGP;
        else
                return DRM_MIGHT_BE_AGP;
+#else
+       /* XXXrkb: fill in impl here */
+       return DRM_MIGHT_BE_AGP;
+#endif
 }
 
 static void mga_configure(struct drm_device *dev)
@@ -116,6 +121,8 @@ static void mga_configure(struct drm_device *dev)
        dev->driver->patchlevel         = DRIVER_PATCHLEVEL;
 }
 
+#if defined(__FreeBSD__)
+
 static int
 mga_probe(device_t kdev)
 {
@@ -170,3 +177,89 @@ DRIVER_MODULE(mga, vgapci, mga_driver, drm_devclass, 0, 0);
 DRIVER_MODULE(mga, pci, mga_driver, drm_devclass, 0, 0);
 #endif
 MODULE_DEPEND(mga, drm, 1, 1, 1);
+
+#elif   defined(__NetBSD__)
+
+static int
+mgadrm_probe(device_t parent, cfdata_t match, void *aux)
+{
+       struct pci_attach_args *pa = aux;
+       return drm_probe(pa, mga_pciidlist);
+}
+
+static void
+mgadrm_attach(device_t parent, device_t self, void *aux)
+{
+       struct pci_attach_args *pa = aux;
+       struct drm_device *dev = device_private(self);
+
+       dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER,
+           M_WAITOK | M_ZERO);
+
+       mga_configure(dev);
+
+       drm_attach(self, pa, mga_pciidlist);
+}
+
+CFATTACH_DECL_NEW(mgadrm, sizeof(struct drm_device),
+    mgadrm_probe, mgadrm_attach, drm_detach, drm_activate);
+
+#ifdef _MODULE
+
+MODULE(MODULE_CLASS_DRIVER, mgadrm, NULL);
+
+CFDRIVER_DECL(mgadrm, DV_DULL, NULL);
+extern struct cfattach mgadrm_ca;
+static int drmloc[] = { -1 };
+static struct cfparent drmparent = {
+       "drm", "vga", DVUNIT_ANY
+};
+static struct cfdata mgadrm_cfdata[] = {
+       {
+               .cf_name = "mgadrm",
+               .cf_atname = "mgadrm",
+               .cf_unit = 0,
+               .cf_fstate = FSTATE_STAR,
+               .cf_loc = drmloc,
+               .cf_flags = 0,
+               .cf_pspec = &drmparent,
+       },
+       { NULL }
+};
+
+static int
+mgadrm_modcmd(modcmd_t cmd, void *arg)
+{
+       int err;
+
+       switch (cmd) {
+       case MODULE_CMD_INIT:
+               err = config_cfdriver_attach(&mgadrm_cd);
+               if (err)
+                       return err;
+               err = config_cfattach_attach("mgadrm", &mgadrm_ca);
+               if (err) {
+                       config_cfdriver_detach(&mgadrm_cd);
+                       return err;
+               }
+               err = config_cfdata_attach(mgadrm_cfdata, 1);
+               if (err) {
+                       config_cfattach_detach("mgadrm", &mgadrm_ca);
+                       config_cfdriver_detach(&mgadrm_cd);
+                       return err;
+               }
+               return 0;
+       case MODULE_CMD_FINI:
+               err = config_cfdata_detach(mgadrm_cfdata);
+               if (err)
+                       return err;
+               config_cfattach_detach("mgadrm", &mgadrm_ca);
+               config_cfdriver_detach(&mgadrm_cd);
+               return 0;
+       default:
+               return ENOTTY;
+       }
+}
+#endif /* _MODULE */
+
+#endif
diff --git a/sys/external/bsd/drm/dist/bsd-core/r128_drv.c 
b/sys/external/bsd/drm/dist/bsd-core/r128_drv.c
index a783d58..ccdc3a0 100644
--- a/sys/external/bsd/drm/dist/bsd-core/r128_drv.c
+++ b/sys/external/bsd/drm/dist/bsd-core/r128_drv.c
@@ -42,6 +42,11 @@ static drm_pci_id_list_t r128_pciidlist[] = {
        r128_PCI_IDS
 };
 
+int r128_driver_load(struct drm_device * dev, unsigned long flags)
+{
+       return drm_vblank_init(dev, 1);
+}
+
 static void r128_configure(struct drm_device *dev)
 {
        dev->driver->driver_features =
@@ -72,6 +77,8 @@ static void r128_configure(struct drm_device *dev)
        dev->driver->patchlevel         = DRIVER_PATCHLEVEL;
 }
 
+#if defined(__FreeBSD__)
+
 static int
 r128_probe(device_t kdev)
 {
@@ -91,11 +98,6 @@ r128_attach(device_t kdev)
        return drm_attach(kdev, r128_pciidlist);
 }
 
-int r128_driver_load(struct drm_device * dev, unsigned long flags)
-{
-       return drm_vblank_init(dev, 1);
-}
-
 static int
 r128_detach(device_t kdev)
 {
@@ -131,3 +133,89 @@ DRIVER_MODULE(r128, vgapci, r128_driver, drm_devclass, 0, 
0);
 DRIVER_MODULE(r128, pci, r128_driver, drm_devclass, 0, 0);
 #endif
 MODULE_DEPEND(r128, drm, 1, 1, 1);
+
+#elif   defined(__NetBSD__)
+
+static int
+r128drm_probe(device_t parent, cfdata_t match, void *aux)
+{
+       struct pci_attach_args *pa = aux;
+       return drm_probe(pa, r128_pciidlist);
+}
+
+static void
+r128drm_attach(device_t parent, device_t self, void *aux)
+{
+       struct pci_attach_args *pa = aux;
+       struct drm_device *dev = device_private(self);
+
+       dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER,
+           M_WAITOK | M_ZERO);
+
+       r128_configure(dev);
+
+       drm_attach(self, pa, r128_pciidlist);
+}
+
+CFATTACH_DECL_NEW(r128drm, sizeof(struct drm_device),
+    r128drm_probe, r128drm_attach, drm_detach, drm_activate);
+
+#ifdef _MODULE
+
+MODULE(MODULE_CLASS_DRIVER, r128drm, NULL);
+
+CFDRIVER_DECL(r128drm, DV_DULL, NULL);
+extern struct cfattach r128drm_ca;
+static int drmloc[] = { -1 };
+static struct cfparent drmparent = {
+       "drm", "vga", DVUNIT_ANY
+};
+static struct cfdata r128drm_cfdata[] = {
+       {
+               .cf_name = "r128drm",
+               .cf_atname = "r128drm",
+               .cf_unit = 0,
+               .cf_fstate = FSTATE_STAR,
+               .cf_loc = drmloc,
+               .cf_flags = 0,
+               .cf_pspec = &drmparent,
+       },
+       { NULL }
+};
+
+static int
+r128drm_modcmd(modcmd_t cmd, void *arg)
+{
+       int err;
+
+       switch (cmd) {
+       case MODULE_CMD_INIT:
+               err = config_cfdriver_attach(&r128drm_cd);
+               if (err)
+                       return err;
+               err = config_cfattach_attach("r128drm", &r128drm_ca);
+               if (err) {
+                       config_cfdriver_detach(&r128drm_cd);
+                       return err;
+               }
+               err = config_cfdata_attach(r128drm_cfdata, 1);
+               if (err) {
+                       config_cfattach_detach("r128drm", &r128drm_ca);
+                       config_cfdriver_detach(&r128drm_cd);
+                       return err;
+               }
+               return 0;
+       case MODULE_CMD_FINI:
+               err = config_cfdata_detach(r128drm_cfdata);
+               if (err)
+                       return err;
+               config_cfattach_detach("r128drm", &r128drm_ca);
+               config_cfdriver_detach(&r128drm_cd);
+               return 0;
+       default:
+               return ENOTTY;
+       }
+}
+#endif /* _MODULE */
+
+#endif
diff --git a/sys/external/bsd/drm/dist/bsd-core/savage_drv.c 
b/sys/external/bsd/drm/dist/bsd-core/savage_drv.c
index c5376e7..b3bbc40 100644
--- a/sys/external/bsd/drm/dist/bsd-core/savage_drv.c
+++ b/sys/external/bsd/drm/dist/bsd-core/savage_drv.c
@@ -62,6 +62,8 @@ static void savage_configure(struct drm_device *dev)
        dev->driver->patchlevel         = DRIVER_PATCHLEVEL;
 }
 
+#if defined(__FreeBSD__)
+
 static int
 savage_probe(device_t kdev)
 {
@@ -116,3 +118,89 @@ DRIVER_MODULE(savage, vgapci, savage_driver, drm_devclass, 
0, 0);
 DRIVER_MODULE(savage, pci, savage_driver, drm_devclass, 0, 0);
 #endif
 MODULE_DEPEND(savage, drm, 1, 1, 1);
+
+#elif   defined(__NetBSD__)
+
+static int
+savagedrm_probe(device_t parent, cfdata_t match, void *aux)
+{
+       struct pci_attach_args *pa = aux;
+       return drm_probe(pa, savage_pciidlist);
+}
+
+static void
+savagedrm_attach(device_t parent, device_t self, void *aux)
+{
+       struct pci_attach_args *pa = aux;
+       struct drm_device *dev = device_private(self);
+
+       dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER,
+           M_WAITOK | M_ZERO);
+
+       savage_configure(dev);
+
+       drm_attach(self, pa, savage_pciidlist);
+}
+
+CFATTACH_DECL_NEW(savagedrm, sizeof(struct drm_device),
+    savagedrm_probe, savagedrm_attach, drm_detach, drm_activate);
+
+#ifdef _MODULE
+
+MODULE(MODULE_CLASS_DRIVER, savagedrm, NULL);
+
+CFDRIVER_DECL(savagedrm, DV_DULL, NULL);
+extern struct cfattach savagedrm_ca;
+static int drmloc[] = { -1 };
+static struct cfparent drmparent = {
+       "drm", "vga", DVUNIT_ANY
+};
+static struct cfdata savagedrm_cfdata[] = {
+       {
+               .cf_name = "savagedrm",
+               .cf_atname = "savagedrm",
+               .cf_unit = 0,
+               .cf_fstate = FSTATE_STAR,
+               .cf_loc = drmloc,
+               .cf_flags = 0,
+               .cf_pspec = &drmparent,
+       },
+       { NULL }
+};
+
+static int
+savagedrm_modcmd(modcmd_t cmd, void *arg)
+{
+       int err;
+
+       switch (cmd) {
+       case MODULE_CMD_INIT:
+               err = config_cfdriver_attach(&savagedrm_cd);
+               if (err)
+                       return err;
+               err = config_cfattach_attach("savagedrm", &savagedrm_ca);
+               if (err) {
+                       config_cfdriver_detach(&savagedrm_cd);
+                       return err;
+               }
+               err = config_cfdata_attach(savagedrm_cfdata, 1);
+               if (err) {
+                       config_cfattach_detach("savagedrm", &savagedrm_ca);
+                       config_cfdriver_detach(&savagedrm_cd);
+                       return err;
+               }
+               return 0;
+       case MODULE_CMD_FINI:
+               err = config_cfdata_detach(savagedrm_cfdata);
+               if (err)
+                       return err;
+               config_cfattach_detach("savagedrm", &savagedrm_ca);
+               config_cfdriver_detach(&savagedrm_cd);
+               return 0;
+       default:
+               return ENOTTY;
+       }
+}
+#endif /* _MODULE */
+
+#endif
diff --git a/sys/external/bsd/drm/dist/bsd-core/sis_drv.c 
b/sys/external/bsd/drm/dist/bsd-core/sis_drv.c
index a294246..e054247 100644
--- a/sys/external/bsd/drm/dist/bsd-core/sis_drv.c
+++ b/sys/external/bsd/drm/dist/bsd-core/sis_drv.c
@@ -56,6 +56,8 @@ static void sis_configure(struct drm_device *dev)
        dev->driver->patchlevel         = DRIVER_PATCHLEVEL;
 }
 
+#if defined(__FreeBSD__)
+
 static int
 sis_probe(device_t kdev)
 {
@@ -110,3 +112,89 @@ DRIVER_MODULE(sisdrm, vgapci, sis_driver, drm_devclass, 0, 
0);
 DRIVER_MODULE(sisdrm, pci, sis_driver, drm_devclass, 0, 0);
 #endif
 MODULE_DEPEND(sisdrm, drm, 1, 1, 1);
+
+#elif   defined(__NetBSD__)
+
+static int
+sisdrm_probe(device_t parent, cfdata_t match, void *aux)
+{
+       struct pci_attach_args *pa = aux;
+       return drm_probe(pa, sis_pciidlist);
+}
+
+static void
+sisdrm_attach(device_t parent, device_t self, void *aux)
+{
+       struct pci_attach_args *pa = aux;
+       struct drm_device *dev = device_private(self);
+
+       dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER,
+           M_WAITOK | M_ZERO);
+
+       sis_configure(dev);
+
+       drm_attach(self, pa, sis_pciidlist);
+}
+
+CFATTACH_DECL_NEW(sisdrm, sizeof(struct drm_device),
+    sisdrm_probe, sisdrm_attach, drm_detach, drm_activate);
+
+#ifdef _MODULE
+
+MODULE(MODULE_CLASS_DRIVER, sisdrm, NULL);
+
+CFDRIVER_DECL(sisdrm, DV_DULL, NULL);
+extern struct cfattach sisdrm_ca;
+static int drmloc[] = { -1 };
+static struct cfparent drmparent = {
+       "drm", "vga", DVUNIT_ANY
+};
+static struct cfdata sisdrm_cfdata[] = {
+       {
+               .cf_name = "sisdrm",
+               .cf_atname = "sisdrm",
+               .cf_unit = 0,
+               .cf_fstate = FSTATE_STAR,
+               .cf_loc = drmloc,
+               .cf_flags = 0,
+               .cf_pspec = &drmparent,
+       },
+       { NULL }
+};
+
+static int
+sisdrm_modcmd(modcmd_t cmd, void *arg)
+{
+       int err;
+
+       switch (cmd) {
+       case MODULE_CMD_INIT:
+               err = config_cfdriver_attach(&sisdrm_cd);
+               if (err)
+                       return err;
+               err = config_cfattach_attach("sisdrm", &sisdrm_ca);
+               if (err) {
+                       config_cfdriver_detach(&sisdrm_cd);
+                       return err;
+               }
+               err = config_cfdata_attach(sisdrm_cfdata, 1);
+               if (err) {
+                       config_cfattach_detach("sisdrm", &sisdrm_ca);
+                       config_cfdriver_detach(&sisdrm_cd);
+                       return err;
+               }
+               return 0;
+       case MODULE_CMD_FINI:
+               err = config_cfdata_detach(sisdrm_cfdata);
+               if (err)
+                       return err;
+               config_cfattach_detach("sisdrm", &sisdrm_ca);
+               config_cfdriver_detach(&sisdrm_cd);
+               return 0;
+       default:
+               return ENOTTY;
+       }
+}
+#endif /* _MODULE */
+
+#endif
diff --git a/sys/external/bsd/drm/dist/bsd-core/tdfx_drv.c 
b/sys/external/bsd/drm/dist/bsd-core/tdfx_drv.c
index f293f4b..455ce07 100644
--- a/sys/external/bsd/drm/dist/bsd-core/tdfx_drv.c
+++ b/sys/external/bsd/drm/dist/bsd-core/tdfx_drv.c
@@ -58,6 +58,8 @@ static void tdfx_configure(struct drm_device *dev)
        dev->driver->patchlevel         = DRIVER_PATCHLEVEL;
 }
 
+#if defined(__FreeBSD__)
+
 static int
 tdfx_probe(device_t kdev)
 {
@@ -112,3 +114,89 @@ DRIVER_MODULE(tdfx, vgapci, tdfx_driver, drm_devclass, 0, 
0);
 DRIVER_MODULE(tdfx, pci, tdfx_driver, drm_devclass, 0, 0);
 #endif
 MODULE_DEPEND(tdfx, drm, 1, 1, 1);
+
+#elif   defined(__NetBSD__)
+
+static int
+tdfxdrm_probe(device_t parent, cfdata_t match, void *aux)
+{
+       struct pci_attach_args *pa = aux;
+       return drm_probe(pa, tdfx_pciidlist);
+}
+
+static void
+tdfxdrm_attach(device_t parent, device_t self, void *aux)
+{
+       struct pci_attach_args *pa = aux;
+       struct drm_device *dev = device_private(self);
+
+       dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER,
+           M_WAITOK | M_ZERO);
+
+       tdfx_configure(dev);
+
+       drm_attach(self, pa, tdfx_pciidlist);
+}
+
+CFATTACH_DECL_NEW(tdfxdrm, sizeof(struct drm_device),
+    tdfxdrm_probe, tdfxdrm_attach, drm_detach, drm_activate);
+
+#ifdef _MODULE
+
+MODULE(MODULE_CLASS_DRIVER, tdfxdrm, NULL);
+
+CFDRIVER_DECL(tdfxdrm, DV_DULL, NULL);
+extern struct cfattach tdfxdrm_ca;
+static int drmloc[] = { -1 };
+static struct cfparent drmparent = {
+       "drm", "vga", DVUNIT_ANY
+};
+static struct cfdata tdfxdrm_cfdata[] = {
+       {
+               .cf_name = "tdfxdrm",
+               .cf_atname = "tdfxdrm",
+               .cf_unit = 0,
+               .cf_fstate = FSTATE_STAR,
+               .cf_loc = drmloc,
+               .cf_flags = 0,
+               .cf_pspec = &drmparent,
+       },
+       { NULL }
+};
+
+static int
+tdfxdrm_modcmd(modcmd_t cmd, void *arg)
+{
+       int err;
+
+       switch (cmd) {
+       case MODULE_CMD_INIT:
+               err = config_cfdriver_attach(&tdfxdrm_cd);
+               if (err)
+                       return err;
+               err = config_cfattach_attach("tdfxdrm", &tdfxdrm_ca);
+               if (err) {
+                       config_cfdriver_detach(&tdfxdrm_cd);
+                       return err;
+               }
+               err = config_cfdata_attach(tdfxdrm_cfdata, 1);
+               if (err) {
+                       config_cfattach_detach("tdfxdrm", &tdfxdrm_ca);
+                       config_cfdriver_detach(&tdfxdrm_cd);
+                       return err;
+               }
+               return 0;
+       case MODULE_CMD_FINI:
+               err = config_cfdata_detach(tdfxdrm_cfdata);
+               if (err)
+                       return err;
+               config_cfattach_detach("tdfxdrm", &tdfxdrm_ca);
+               config_cfdriver_detach(&tdfxdrm_cd);
+               return 0;
+       default:
+               return ENOTTY;
+       }
+}
+#endif /* _MODULE */
+
+#endif
diff --git a/sys/external/bsd/drm/dist/shared-core/mach64_dma.c 
b/sys/external/bsd/drm/dist/shared-core/mach64_dma.c
index 3f2367b..a674971 100644
--- a/sys/external/bsd/drm/dist/shared-core/mach64_dma.c
+++ b/sys/external/bsd/drm/dist/shared-core/mach64_dma.c
@@ -509,7 +509,7 @@ void mach64_dump_ring_info(drm_mach64_private_t *dev_priv)
 
        DRM_INFO("\n");
 
-       if (ring->head >= 0 && ring->head < ring->size / sizeof(u32)) {
+       if (ring->head < ring->size / sizeof(u32)) {
                struct list_head *ptr;
                u32 addr = le32_to_cpu(((u32 *) ring->start)[ring->head + 1]);
 
@@ -1273,7 +1273,7 @@ int mach64_do_dispatch_pseudo_dma(drm_mach64_private_t 
*dev_priv)
                        entry = list_entry(ptr, drm_mach64_freelist_t, list);
                        buf = entry->buf;
                        offset = buf_addr - GETBUFADDR(buf);
-                       if (offset >= 0 && offset < MACH64_BUFFER_SIZE) {
+                       if (offset < MACH64_BUFFER_SIZE) {
                                found = 1;
                                break;
                        }
diff --git a/sys/external/bsd/drm/dist/shared-core/mach64_drv.h 
b/sys/external/bsd/drm/dist/shared-core/mach64_drv.h
index 6b0020e..570b9d3 100644
--- a/sys/external/bsd/drm/dist/shared-core/mach64_drv.h
+++ b/sys/external/bsd/drm/dist/shared-core/mach64_drv.h
@@ -504,7 +504,7 @@ extern void mach64_driver_irq_uninstall(struct drm_device 
*dev);
 #define MMREG0         0x0000
 #define MMREG0_END     0x00ff
 
-#define ISMMREG0(r)    (((r) >= MMREG0) && ((r) <= MMREG0_END))
+#define ISMMREG0(r)    ((r) <= MMREG0_END)
 #define MMSELECT0(r)   (((r) << 2) + DWMREG0)
 #define MMSELECT1(r)   (((((r) & 0xff) << 2) + DWMREG1))
 #define MMSELECT(r)    (ISMMREG0(r) ? MMSELECT0(r) : MMSELECT1(r))
@@ -776,8 +776,8 @@ do {                                                        
        \
 
 #define DMAADVANCE( dev_priv, _discard )                               \
        do {                                                            \
-               struct list_head *ptr;                                  \
-               int ret;                                                \
+               struct list_head *_ptr;                                 \
+               int _ret;                                               \
                                                                        \
                if ( MACH64_VERBOSE ) {                                 \
                        DRM_INFO( "DMAADVANCE() in \n" );               \
@@ -790,9 +790,9 @@ do {                                                        
        \
                }                                                       \
                if (_buf->pending) {                                    \
                        /* This is a resued buffer, so we need to find it in 
the pending list */ \
-                       if ((ret = mach64_find_pending_buf_entry(dev_priv, 
&_entry, _buf))) { \
+                       if ((_ret = mach64_find_pending_buf_entry(dev_priv, 
&_entry, _buf))) { \
                                DRM_ERROR( "DMAADVANCE(): couldn't find pending 
buf %d\n", _buf->idx ); \
-                               return ret;                             \
+                               return _ret;                            \
                        }                                               \
                        if (_entry->discard) {                          \
                                DRM_ERROR( "DMAADVANCE(): sending discarded 
pending buf %d\n", _buf->idx ); \
@@ -803,26 +803,26 @@ do {                                                      
        \
                                DRM_ERROR( "DMAADVANCE(): empty placeholder 
list\n"); \
                                return -EFAULT;                         \
                        }                                               \
-                       ptr = dev_priv->placeholders.next;              \
-                       list_del(ptr);                                  \
-                       _entry = list_entry(ptr, drm_mach64_freelist_t, list); \
+                       _ptr = dev_priv->placeholders.next;             \
+                       list_del(_ptr);                                 \
+                       _entry = list_entry(_ptr, drm_mach64_freelist_t, list); 
\
                        _buf->pending = 1;                              \
                        _entry->buf = _buf;                             \
-                       list_add_tail(ptr, &dev_priv->pending);         \
+                       list_add_tail(_ptr, &dev_priv->pending);        \
                }                                                       \
                _entry->discard = (_discard);                           \
-               if ((ret = mach64_add_buf_to_ring( dev_priv, _entry ))) \
-                       return ret;                                     \
+               if ((_ret = mach64_add_buf_to_ring( dev_priv, _entry ))) \
+                       return _ret;                                    \
        } while (0)
 
 #define DMADISCARDBUF()                                                        
\
        do {                                                            \
                if (_entry == NULL) {                                   \
-                       int ret;                                        \
-                       if ((ret = mach64_find_pending_buf_entry(dev_priv, 
&_entry, _buf))) { \
+                       int _ret;                                       \
+                       if ((_ret = mach64_find_pending_buf_entry(dev_priv, 
&_entry, _buf))) { \
                                DRM_ERROR( "couldn't find pending buf %d\n", \
                                           _buf->idx );                 \
-                               return ret;                             \
+                               return _ret;                            \
                        }                                               \
                }                                                       \
                _entry->discard = 1;                                    \
@@ -831,7 +831,7 @@ do {                                                        
        \
 #define DMAADVANCEHOSTDATA( dev_priv )                                 \
        do {                                                            \
                struct list_head *ptr;                                  \
-               int ret;                                                \
+               int _ret;                                               \
                                                                        \
                if ( MACH64_VERBOSE ) {                                 \
                        DRM_INFO( "DMAADVANCEHOSTDATA() in \n" );       \
@@ -853,8 +853,8 @@ do {                                                        
        \
                _entry->buf->pending = 1;                               \
                list_add_tail(ptr, &dev_priv->pending);                 \
                _entry->discard = 1;                                    \
-               if ((ret = mach64_add_hostdata_buf_to_ring( dev_priv, _entry 
))) \
-                       return ret;                                     \
+               if ((_ret = mach64_add_hostdata_buf_to_ring( dev_priv, _entry 
))) \
+                       return _ret;                                    \
        } while (0)
 
 #endif                         /* __MACH64_DRV_H__ */
diff --git a/sys/external/bsd/drm/dist/shared-core/savage_bci.c 
b/sys/external/bsd/drm/dist/shared-core/savage_bci.c
index 4b8a89f..3b657ab 100644
--- a/sys/external/bsd/drm/dist/shared-core/savage_bci.c
+++ b/sys/external/bsd/drm/dist/shared-core/savage_bci.c
@@ -661,9 +661,14 @@ void savage_driver_lastclose(struct drm_device *dev)
 
        for (i = 0; i < 3; ++i)
                if (dev_priv->mtrr[i].handle >= 0)
+#if defined(__FreeBSD__)
                        drm_mtrr_del(dev_priv->mtrr[i].handle,
                                     dev_priv->mtrr[i].base,
                                     dev_priv->mtrr[i].size, DRM_MTRR_WC);
+#elif defined(__NetBSD__)
+                       drm_mtrr_del(dev_priv->mtrr[i].base,
+                                    dev_priv->mtrr[i].size, DRM_MTRR_WC);
+#endif
 }
 
 int savage_driver_unload(struct drm_device *dev)
diff --git a/sys/external/bsd/drm/dist/shared-core/savage_state.c 
b/sys/external/bsd/drm/dist/shared-core/savage_state.c
index 1c5a0e2..38e5f5c 100644
--- a/sys/external/bsd/drm/dist/shared-core/savage_state.c
+++ b/sys/external/bsd/drm/dist/shared-core/savage_state.c
@@ -374,18 +374,18 @@ static int savage_dispatch_dma_prim(drm_savage_private_t 
*dev_priv,
                        /* Need to reorder indices for correct flat
                         * shading while preserving the clock sense
                         * for correct culling. Only on Savage3D. */
-                       int reorder[3] = { -1, -1, -1 };
-                       reorder[start % 3] = 2;
+                       int reorderarr[3] = { -1, -1, -1 };
+                       reorderarr[start % 3] = 2;
 
                        BEGIN_BCI((count + 1 + 1) / 2);
                        BCI_DRAW_INDICES_S3D(count, prim, start + 2);
 
                        for (i = start + 1; i + 1 < start + count; i += 2)
-                               BCI_WRITE((i + reorder[i % 3]) |
+                               BCI_WRITE((i + reorderarr[i % 3]) |
                                          ((i + 1 +
-                                           reorder[(i + 1) % 3]) << 16));
+                                           reorderarr[(i + 1) % 3]) << 16));
                        if (i < start + count)
-                               BCI_WRITE(i + reorder[i % 3]);
+                               BCI_WRITE(i + reorderarr[i % 3]);
                } else if (S3_SAVAGE3D_SERIES(dev_priv->chipset)) {
                        BEGIN_BCI((count + 1 + 1) / 2);
                        BCI_DRAW_INDICES_S3D(count, prim, start);
@@ -493,14 +493,14 @@ static int savage_dispatch_vb_prim(drm_savage_private_t 
*dev_priv,
                        /* Need to reorder vertices for correct flat
                         * shading while preserving the clock sense
                         * for correct culling. Only on Savage3D. */
-                       int reorder[3] = { -1, -1, -1 };
-                       reorder[start % 3] = 2;
+                       int reorderarr[3] = { -1, -1, -1 };
+                       reorderarr[start % 3] = 2;
 
                        BEGIN_DMA(count * vtx_size + 1);
                        DMA_DRAW_PRIMITIVE(count, prim, skip);
 
                        for (i = start; i < start + count; ++i) {
-                               unsigned int j = i + reorder[i % 3];
+                               unsigned int j = i + reorderarr[i % 3];
                                DMA_COPY(&vtxbuf[vb_stride * j], vtx_size);
                        }
 
@@ -634,17 +634,17 @@ static int savage_dispatch_dma_idx(drm_savage_private_t 
*dev_priv,
                        /* Need to reorder indices for correct flat
                         * shading while preserving the clock sense
                         * for correct culling. Only on Savage3D. */
-                       int reorder[3] = { 2, -1, -1 };
+                       int reorderarr[3] = { 2, -1, -1 };
 
                        BEGIN_BCI((count + 1 + 1) / 2);
                        BCI_DRAW_INDICES_S3D(count, prim, idx[2]);
 
                        for (i = 1; i + 1 < count; i += 2)
-                               BCI_WRITE(idx[i + reorder[i % 3]] |
+                               BCI_WRITE(idx[i + reorderarr[i % 3]] |
                                          (idx[i + 1 +
-                                          reorder[(i + 1) % 3]] << 16));
+                                          reorderarr[(i + 1) % 3]] << 16));
                        if (i < count)
-                               BCI_WRITE(idx[i + reorder[i % 3]]);
+                               BCI_WRITE(idx[i + reorderarr[i % 3]]);
                } else if (S3_SAVAGE3D_SERIES(dev_priv->chipset)) {
                        BEGIN_BCI((count + 1 + 1) / 2);
                        BCI_DRAW_INDICES_S3D(count, prim, idx[0]);
@@ -754,13 +754,13 @@ static int savage_dispatch_vb_idx(drm_savage_private_t 
*dev_priv,
                        /* Need to reorder vertices for correct flat
                         * shading while preserving the clock sense
                         * for correct culling. Only on Savage3D. */
-                       int reorder[3] = { 2, -1, -1 };
+                       int reorderarr[3] = { 2, -1, -1 };
 
                        BEGIN_DMA(count * vtx_size + 1);
                        DMA_DRAW_PRIMITIVE(count, prim, skip);
 
                        for (i = 0; i < count; ++i) {
-                               unsigned int j = idx[i + reorder[i % 3]];
+                               unsigned int j = idx[i + reorderarr[i % 3]];
                                DMA_COPY(&vtxbuf[vb_stride * j], vtx_size);
                        }
 
diff --git a/sys/external/bsd/drm/dist/shared-core/sis_ds.c 
b/sys/external/bsd/drm/dist/shared-core/sis_ds.c
index 2e485d4..b6a84a3 100644
--- a/sys/external/bsd/drm/dist/shared-core/sis_ds.c
+++ b/sys/external/bsd/drm/dist/shared-core/sis_ds.c
@@ -57,18 +57,18 @@ set_t *setInit(void)
 
 int setAdd(set_t * set, ITEM_TYPE item)
 {
-       int free = set->free;
+       int freeidx = set->free;
 
-       if (free != -1) {
-               set->list[free].val = item;
-               set->free = set->list[free].free_next;
+       if (freeidx != -1) {
+               set->list[freeidx].val = item;
+               set->free = set->list[freeidx].free_next;
        } else {
                return 0;
        }
 
-       set->list[free].alloc_next = set->alloc;
-       set->alloc = free;
-       set->list[free].free_next = -1;
+       set->list[freeidx].alloc_next = set->alloc;
+       set->alloc = freeidx;
+       set->list[freeidx].free_next = -1;
 
        return 1;
 }


Home | Main Index | Thread Index | Old Index