Source-Changes-HG archive

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

[src/trunk]: src/sys/external/bsd/drm2 Add the missing viadrm files omitted l...



details:   https://anonhg.NetBSD.org/src/rev/93c53d5fc669
branches:  trunk
changeset: 807963:93c53d5fc669
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Apr 29 11:25:36 2015 +0000

description:
Add the missing viadrm files omitted last night.

diffstat:

 sys/external/bsd/drm2/dist/drm/via/via_video.c |    6 +-
 sys/external/bsd/drm2/via/via_module.c         |  139 ++++++++++++++++++++++++
 sys/external/bsd/drm2/via/via_pci.c            |  141 +++++++++++++++++++++++++
 3 files changed, 283 insertions(+), 3 deletions(-)

diffs (truncated from 305 to 300 lines):

diff -r 2f4eb7d3e3fd -r 93c53d5fc669 sys/external/bsd/drm2/dist/drm/via/via_video.c
--- a/sys/external/bsd/drm2/dist/drm/via/via_video.c    Wed Apr 29 08:32:00 2015 +0000
+++ b/sys/external/bsd/drm2/dist/drm/via/via_video.c    Wed Apr 29 11:25:36 2015 +0000
@@ -116,10 +116,10 @@
                return ret;
        case VIA_FUTEX_WAKE:
 #ifdef __NetBSD__
-               mutex_lock(&dev_priv->decoder_lock[fx->lock]);
-               DRM_WAKEUP_ALL(&dev_priv->decoder_queue[fx->lock],
+               spin_lock(&dev_priv->decoder_lock[fx->lock]);
+               DRM_SPIN_WAKEUP_ALL(&dev_priv->decoder_queue[fx->lock],
                    &dev_priv->decoder_lock[fx->lock]);
-               mutex_unlock(&dev_priv->decoder_lock[fx->lock]);
+               spin_unlock(&dev_priv->decoder_lock[fx->lock]);
 #else
                wake_up(&(dev_priv->decoder_queue[fx->lock]));
 #endif
diff -r 2f4eb7d3e3fd -r 93c53d5fc669 sys/external/bsd/drm2/via/via_module.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/external/bsd/drm2/via/via_module.c    Wed Apr 29 11:25:36 2015 +0000
@@ -0,0 +1,139 @@
+/*     $NetBSD: via_module.c,v 1.1 2015/04/29 11:25:36 riastradh Exp $ */
+
+/*-
+ * Copyright (c) 2015 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: via_module.c,v 1.1 2015/04/29 11:25:36 riastradh Exp $");
+
+#include <sys/types.h>
+#include <sys/module.h>
+#include <sys/once.h>
+
+#include <drm/drmP.h>
+#include <drm/via_drm.h>
+
+#include "via_drv.h"
+
+MODULE(MODULE_CLASS_DRIVER, viadrmums, "drmkms,drmkms_pci");
+
+#ifdef _MODULE
+#include "ioconf.c"
+#endif
+
+extern struct drm_driver *const via_drm_driver; /* XXX */
+
+static int
+viadrm_init(void)
+{
+       extern int drm_guarantee_initialized(void);
+       int error;
+
+       via_init_command_verifier(); /* idempotent, no unwind needed */
+
+       error = drm_guarantee_initialized();
+       if (error)
+               return error;
+
+       error = drm_pci_init(via_drm_driver, NULL);
+       if (error) {
+               aprint_error("i915drmkms: failed to init pci: %d\n",
+                   error);
+               return error;
+       }
+
+       return 0;
+}
+
+int    viadrm_guarantee_initialized(void); /* XXX */
+int
+viadrm_guarantee_initialized(void)
+{
+#ifdef _MODULE
+       return 0;
+#else
+       static ONCE_DECL(viadrm_init_once);
+
+       return RUN_ONCE(&viadrm_init_once, &viadrm_init);
+#endif
+}
+
+static void
+viadrm_fini(void)
+{
+
+       drm_pci_exit(via_drm_driver, NULL);
+}
+
+static int
+viadrmums_modcmd(modcmd_t cmd, void *arg __unused)
+{
+       int error;
+
+       switch (cmd) {
+       case MODULE_CMD_INIT:
+#ifdef _MODULE
+               error = viadrm_init();
+#else
+               error = viadrm_guarantee_initialized();
+#endif
+               if (error) {
+                       aprint_error("viadrmums: failed to initialize: %d\n",
+                           error);
+                       return error;
+               }
+#ifdef _MODULE
+               error = config_init_component(cfdriver_ioconf_viadrmums,
+                   cfattach_ioconf_viadrmums, cfdata_ioconf_viadrmums);
+               if (error) {
+                       aprint_error("viadrmums: failed to init component"
+                           ": %d\n", error);
+                       viadrm_fini();
+                       return error;
+               }
+#endif
+               return 0;
+
+       case MODULE_CMD_FINI:
+#ifdef _MODULE
+               error = config_fini_component(cfdriver_ioconf_viadrmums,
+                   cfattach_ioconf_viadrmums, cfdata_ioconf_viadrmums);
+               if (error) {
+                       aprint_error("viadrmums: failed to fini component"
+                           ": %d\n", error);
+                       return error;
+               }
+#endif
+               viadrm_fini();
+               return 0;
+
+       default:
+               return ENOTTY;
+       }
+}
diff -r 2f4eb7d3e3fd -r 93c53d5fc669 sys/external/bsd/drm2/via/via_pci.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/external/bsd/drm2/via/via_pci.c       Wed Apr 29 11:25:36 2015 +0000
@@ -0,0 +1,141 @@
+/*     $NetBSD: via_pci.c,v 1.1 2015/04/29 11:25:36 riastradh Exp $    */
+
+/*-
+ * Copyright (c) 2015 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Taylor R. Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: via_pci.c,v 1.1 2015/04/29 11:25:36 riastradh Exp $");
+
+#include <sys/types.h>
+#include <sys/device.h>
+#include <sys/systm.h>
+
+#include <linux/pci.h>
+
+#include <drm/drmP.h>
+#include <drm/drm_pciids.h>
+#include <drm/via_drm.h>
+
+#include "via_drv.h"
+
+struct viadrm_softc {
+       device_t                sc_dev;
+       struct pci_dev          sc_pci_dev;
+       struct drm_device       *sc_drm_dev;
+};
+
+static int     viadrm_match(device_t, cfdata_t, void *);
+static void    viadrm_attach(device_t, device_t, void *);
+static int     viadrm_detach(device_t, int);
+
+extern struct drm_driver *const via_drm_driver; /* XXX */
+
+CFATTACH_DECL_NEW(viadrmums, sizeof(struct viadrm_softc),
+    viadrm_match, viadrm_attach, viadrm_detach, NULL);
+
+static const struct pci_device_id viadrm_pci_ids[] = {
+       viadrv_PCI_IDS
+};
+
+static const unsigned long *
+viadrm_lookup(const struct pci_attach_args *pa)
+{
+       unsigned i;
+
+       for (i = 0; i < __arraycount(viadrm_pci_ids); i++) {
+               KASSERT(viadrm_pci_ids[i].subvendor == PCI_ANY_ID);
+               KASSERT(viadrm_pci_ids[i].subdevice == PCI_ANY_ID);
+               KASSERT(viadrm_pci_ids[i].class == 0);
+               KASSERT(viadrm_pci_ids[i].class_mask == 0);
+               if (PCI_VENDOR(pa->pa_id) != viadrm_pci_ids[i].vendor)
+                       continue;
+               if (PCI_PRODUCT(pa->pa_id) != viadrm_pci_ids[i].device)
+                       continue;
+               return &viadrm_pci_ids[i].driver_data;
+       }
+
+       return NULL;
+}
+
+static int
+viadrm_match(device_t parent, cfdata_t match, void *aux)
+{
+       extern int viadrm_guarantee_initialized(void);
+       const struct pci_attach_args *const pa = aux;
+       int error;
+
+       error = viadrm_guarantee_initialized();
+       if (error) {
+               aprint_error("viadrm: failed to initialize: %d\n", error);
+               return 0;
+       }
+
+       if (viadrm_lookup(pa) == NULL)
+               return 0;
+
+       return 1;
+}
+
+static void
+viadrm_attach(device_t parent, device_t self, void *aux)
+{
+       struct viadrm_softc *const sc = device_private(self);
+       const struct pci_attach_args *const pa = aux;
+       const unsigned long *const cookiep = viadrm_lookup(pa);
+       int error;
+
+       KASSERT(cookiep != NULL);
+
+       /* XXX errno Linux->NetBSD */
+       error = -drm_pci_attach(self, pa, &sc->sc_pci_dev, via_drm_driver,
+           *cookiep, &sc->sc_drm_dev);
+       if (error) {
+               aprint_error_dev(self, "unable to attach drm: %d\n", error);
+               return;
+       }
+}
+
+static int
+viadrm_detach(device_t self, int flags)
+{
+       struct viadrm_softc *const sc = device_private(self);
+       int error;
+
+       error = config_detach_children(self, flags);
+       if (error)
+               return error;
+       if (sc->sc_drm_dev == NULL)
+               goto out;
+       /* XXX errno Linux->NetBSD */
+       error = -drm_pci_detach(sc->sc_drm_dev, flags);



Home | Main Index | Thread Index | Old Index