summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2009-01-29 11:44:06 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2009-01-29 11:44:06 +0000
commit9f03bbe3d64a70fba8bbf1c0be15296551939b4d (patch)
tree820870cacbf304bd6b122bb6dedafa7cffd93ff7 /sys
parenta808bb676372db0da9ec61d7050b82b6b0bf6c6f (diff)
Move drmmmap to the main driver file. It's stupid to have a file with
one (not particlarly large) function in it.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/drm/drmP.h2
-rw-r--r--sys/dev/pci/drm/drm_drv.c89
-rw-r--r--sys/dev/pci/drm/drm_vm.c118
-rw-r--r--sys/dev/pci/drm/files.drm3
4 files changed, 90 insertions, 122 deletions
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h
index 9c5892be2d2..fd3f9b05e4b 100644
--- a/sys/dev/pci/drm/drmP.h
+++ b/sys/dev/pci/drm/drmP.h
@@ -558,8 +558,6 @@ struct device *drm_attach_pci(const struct drm_driver_info *,
dev_type_ioctl(drmioctl);
dev_type_open(drmopen);
dev_type_close(drmclose);
-dev_type_read(drmread);
-dev_type_poll(drmpoll);
dev_type_mmap(drmmmap);
extern drm_local_map_t *drm_getsarea(struct drm_device *);
diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c
index f85a91fce30..9b9d72bdd9f 100644
--- a/sys/dev/pci/drm/drm_drv.c
+++ b/sys/dev/pci/drm/drm_drv.c
@@ -1,4 +1,5 @@
/*-
+ * Copyright 2003 Eric Anholt
* Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
@@ -696,3 +697,91 @@ drm_getsarea(struct drm_device *dev)
DRM_UNLOCK();
return (map);
}
+
+paddr_t
+drmmmap(dev_t kdev, off_t offset, int prot)
+{
+ struct drm_device *dev = drm_get_device_from_kdev(kdev);
+ drm_local_map_t *map;
+ struct drm_file *priv;
+ enum drm_map_type type;
+
+ DRM_LOCK();
+ priv = drm_find_file_by_minor(dev, minor(kdev));
+ DRM_UNLOCK();
+ if (priv == NULL) {
+ DRM_ERROR("can't find authenticator\n");
+ return (-1);
+ }
+
+ if (!priv->authenticated)
+ return (-1);
+
+ if (dev->dma && offset >= 0 && offset < ptoa(dev->dma->page_count)) {
+ drm_device_dma_t *dma = dev->dma;
+
+ DRM_SPINLOCK(&dev->dma_lock);
+
+ if (dma->pagelist != NULL) {
+ paddr_t phys = dma->pagelist[offset >> PAGE_SHIFT];
+
+ DRM_SPINUNLOCK(&dev->dma_lock);
+ return (atop(phys));
+ } else {
+ DRM_SPINUNLOCK(&dev->dma_lock);
+ return (-1);
+ }
+ }
+
+ /*
+ * A sequential search of a linked list is
+ * fine here because: 1) there will only be
+ * about 5-10 entries in the list and, 2) a
+ * DRI client only has to do this mapping
+ * once, so it doesn't have to be optimized
+ * for performance, even if the list was a
+ * bit longer.
+ */
+ DRM_LOCK();
+ TAILQ_FOREACH(map, &dev->maplist, link) {
+ if (offset >= map->ext &&
+ offset < map->ext + map->size) {
+ offset -= map->ext;
+ break;
+ }
+ }
+
+ if (map == NULL) {
+ DRM_UNLOCK();
+ DRM_DEBUG("can't find map\n");
+ return (-1);
+ }
+ if (((map->flags & _DRM_RESTRICTED) && priv->master == 0)) {
+ DRM_UNLOCK();
+ DRM_DEBUG("restricted map\n");
+ return (-1);
+ }
+ type = map->type;
+ DRM_UNLOCK();
+
+ switch (type) {
+ case _DRM_FRAME_BUFFER:
+ case _DRM_REGISTERS:
+ case _DRM_AGP:
+ return (atop(offset + map->offset));
+ break;
+ /* XXX unify all the bus_dmamem_mmap bits */
+ case _DRM_SCATTER_GATHER:
+ return (bus_dmamem_mmap(dev->dmat, dev->sg->mem->sg_segs,
+ dev->sg->mem->sg_nsegs, map->offset - dev->sg->handle +
+ offset, prot, BUS_DMA_NOWAIT));
+ case _DRM_SHM:
+ case _DRM_CONSISTENT:
+ return (bus_dmamem_mmap(dev->dmat, &map->dmah->seg, 1,
+ offset, prot, BUS_DMA_NOWAIT));
+ default:
+ DRM_ERROR("bad map type %d\n", type);
+ return (-1); /* This should never happen. */
+ }
+ /* NOTREACHED */
+}
diff --git a/sys/dev/pci/drm/drm_vm.c b/sys/dev/pci/drm/drm_vm.c
deleted file mode 100644
index a459f3a9e2d..00000000000
--- a/sys/dev/pci/drm/drm_vm.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/*-
- * Copyright 2003 Eric Anholt
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * ERIC ANHOLT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/** @file drm_vm.c
- * Support code for mmaping of DRM maps.
- */
-
-#include "drmP.h"
-#include "drm.h"
-
-paddr_t
-drmmmap(dev_t kdev, off_t offset, int prot)
-{
- struct drm_device *dev = drm_get_device_from_kdev(kdev);
- drm_local_map_t *map;
- struct drm_file *priv;
- enum drm_map_type type;
-
- DRM_LOCK();
- priv = drm_find_file_by_minor(dev, minor(kdev));
- DRM_UNLOCK();
- if (priv == NULL) {
- DRM_ERROR("can't find authenticator\n");
- return (-1);
- }
-
- if (!priv->authenticated)
- return (-1);
-
- if (dev->dma && offset >= 0 && offset < ptoa(dev->dma->page_count)) {
- drm_device_dma_t *dma = dev->dma;
-
- DRM_SPINLOCK(&dev->dma_lock);
-
- if (dma->pagelist != NULL) {
- paddr_t phys = dma->pagelist[offset >> PAGE_SHIFT];
-
- DRM_SPINUNLOCK(&dev->dma_lock);
- return (atop(phys));
- } else {
- DRM_SPINUNLOCK(&dev->dma_lock);
- return (-1);
- }
- }
-
- /*
- * A sequential search of a linked list is
- * fine here because: 1) there will only be
- * about 5-10 entries in the list and, 2) a
- * DRI client only has to do this mapping
- * once, so it doesn't have to be optimized
- * for performance, even if the list was a
- * bit longer.
- */
- DRM_LOCK();
- TAILQ_FOREACH(map, &dev->maplist, link) {
- if (offset >= map->ext &&
- offset < map->ext + map->size) {
- offset -= map->ext;
- break;
- }
- }
-
- if (map == NULL) {
- DRM_UNLOCK();
- DRM_DEBUG("can't find map\n");
- return (-1);
- }
- if (((map->flags & _DRM_RESTRICTED) && priv->master == 0)) {
- DRM_UNLOCK();
- DRM_DEBUG("restricted map\n");
- return (-1);
- }
- type = map->type;
- DRM_UNLOCK();
-
- switch (type) {
- case _DRM_FRAME_BUFFER:
- case _DRM_REGISTERS:
- case _DRM_AGP:
- return (atop(offset + map->offset));
- break;
- /* XXX unify all the bus_dmamem_mmap bits */
- case _DRM_SCATTER_GATHER:
- return (bus_dmamem_mmap(dev->dmat, dev->sg->mem->sg_segs,
- dev->sg->mem->sg_nsegs, map->offset - dev->sg->handle +
- offset, prot, BUS_DMA_NOWAIT));
- case _DRM_SHM:
- case _DRM_CONSISTENT:
- return (bus_dmamem_mmap(dev->dmat, &map->dmah->seg, 1,
- offset, prot, BUS_DMA_NOWAIT));
- default:
- DRM_ERROR("bad map type %d\n", type);
- return (-1); /* This should never happen. */
- }
- /* NOTREACHED */
-}
-
diff --git a/sys/dev/pci/drm/files.drm b/sys/dev/pci/drm/files.drm
index d541ad9d66a..e4da9d91bf2 100644
--- a/sys/dev/pci/drm/files.drm
+++ b/sys/dev/pci/drm/files.drm
@@ -1,5 +1,5 @@
# $NetBSD: files.drm,v 1.2 2007/03/28 11:29:37 jmcneill Exp $
-# $OpenBSD: files.drm,v 1.8 2009/01/29 11:18:16 oga Exp $
+# $OpenBSD: files.drm,v 1.9 2009/01/29 11:44:05 oga Exp $
# direct rendering modules
define drmbase {}
@@ -17,7 +17,6 @@ file dev/pci/drm/drm_lock.c drm
file dev/pci/drm/drm_memory.c drm
file dev/pci/drm/drm_pci.c drm
file dev/pci/drm/drm_scatter.c drm
-file dev/pci/drm/drm_vm.c drm
device inteldrm: drmbase
attach inteldrm at drmdev