summaryrefslogtreecommitdiff
path: root/sys/dev/pci/drm
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2012-09-08 16:42:21 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2012-09-08 16:42:21 +0000
commitbd21f3cf09e5fa9b2898a5d693c6469975a13ba3 (patch)
tree0e9a9d1f15b2c9bada05e75e4c881f235afc036e /sys/dev/pci/drm
parent552991e0fbce97e30bfb0c246e098119f4775fef (diff)
Instead of having yet an other option to compile the drm code without agp
support, wrap all the agp glue with 'if __OS_HAS_AGP' in such form that it is true if the agp(4) driver is present. ok kettenis@
Diffstat (limited to 'sys/dev/pci/drm')
-rw-r--r--sys/dev/pci/drm/drmP.h7
-rw-r--r--sys/dev/pci/drm/drm_agpsupport.c43
-rw-r--r--sys/dev/pci/drm/drm_drv.c10
3 files changed, 26 insertions, 34 deletions
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h
index d14ea9b87b0..6c087a638f7 100644
--- a/sys/dev/pci/drm/drmP.h
+++ b/sys/dev/pci/drm/drmP.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: drmP.h,v 1.131 2012/08/22 08:23:41 mpi Exp $ */
+/* $OpenBSD: drmP.h,v 1.132 2012/09/08 16:42:20 mpi Exp $ */
/* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
*/
@@ -72,6 +72,9 @@
#include "drm.h"
#include "drm_atomic.h"
+#include "agp.h"
+
+#define __OS_HAS_AGP (NAGP > 0)
#if BYTE_ORDER == BIG_ENDIAN
#define __BIG_ENDIAN
@@ -87,8 +90,6 @@
/* Internal types and structures */
#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
-#define __OS_HAS_AGP 1
-
#define DRM_CURRENTPID curproc->p_pid
#define DRM_LOCK() rw_enter_write(&dev->dev_lock)
#define DRM_UNLOCK() rw_exit_write(&dev->dev_lock)
diff --git a/sys/dev/pci/drm/drm_agpsupport.c b/sys/dev/pci/drm/drm_agpsupport.c
index ba110030d03..4539f5070ad 100644
--- a/sys/dev/pci/drm/drm_agpsupport.c
+++ b/sys/dev/pci/drm/drm_agpsupport.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_agpsupport.c,v 1.21 2012/08/22 15:17:05 mpi Exp $ */
+/* $OpenBSD: drm_agpsupport.c,v 1.22 2012/09/08 16:42:20 mpi Exp $ */
/*-
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
@@ -36,6 +36,8 @@
#include "drmP.h"
+#if __OS_HAS_AGP
+
struct drm_agp_mem *drm_agp_lookup_entry(struct drm_device *, void *);
void drm_agp_remove_entry(struct drm_device *,
struct drm_agp_mem *);
@@ -49,9 +51,7 @@ drm_agp_info(struct drm_device * dev, struct drm_agp_info *info)
return (EINVAL);
kern = &dev->agp->info;
-#ifndef DRM_NO_AGP
agp_get_info(dev->agp->agpdev, kern);
-#endif
info->agp_version_major = 1;
info->agp_version_minor = 0;
info->mode = kern->ai_mode;
@@ -84,7 +84,6 @@ drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
int
drm_agp_acquire(struct drm_device *dev)
{
-#ifndef DRM_NO_AGP
int retcode;
if (dev->agp == NULL || dev->agp->acquired)
@@ -95,7 +94,7 @@ drm_agp_acquire(struct drm_device *dev)
return (retcode);
dev->agp->acquired = 1;
-#endif
+
return (0);
}
@@ -109,12 +108,11 @@ drm_agp_release_ioctl(struct drm_device *dev, void *data,
int
drm_agp_release(struct drm_device * dev)
{
-#ifndef DRM_NO_AGP
if (dev->agp == NULL || !dev->agp->acquired)
return (EINVAL);
agp_release(dev->agp->agpdev);
dev->agp->acquired = 0;
-#endif
+
return (0);
}
@@ -122,14 +120,13 @@ int
drm_agp_enable(struct drm_device *dev, drm_agp_mode_t mode)
{
int retcode = 0;
-#ifndef DRM_NO_AGP
+
if (dev->agp == NULL || !dev->agp->acquired)
return (EINVAL);
-
+
dev->agp->mode = mode.mode;
if ((retcode = agp_enable(dev->agp->agpdev, mode.mode)) == 0)
dev->agp->enabled = 1;
-#endif
return (retcode);
}
@@ -145,7 +142,6 @@ drm_agp_enable_ioctl(struct drm_device *dev, void *data,
int
drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
{
-#ifndef DRM_NO_AGP
struct drm_agp_mem *entry;
void *handle;
struct agp_memory_info info;
@@ -168,7 +164,7 @@ drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
drm_free(entry);
return (ENOMEM);
}
-
+
entry->handle = handle;
entry->bound = 0;
entry->pages = pages;
@@ -180,7 +176,6 @@ drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
DRM_LOCK();
TAILQ_INSERT_HEAD(&dev->agp->memory, entry, link);
DRM_UNLOCK();
-#endif
return (0);
}
@@ -212,7 +207,6 @@ drm_agp_lookup_entry(struct drm_device *dev, void *handle)
int
drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request)
{
-#ifndef DRM_NO_AGP
struct drm_agp_mem *entry;
int retcode;
@@ -233,9 +227,6 @@ drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request)
DRM_UNLOCK();
return (retcode);
-#else
- return (0);
-#endif
}
int
@@ -250,7 +241,6 @@ drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
int
drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request)
{
-#ifndef DRM_NO_AGP
struct drm_agp_mem *entry;
int retcode, page;
@@ -275,9 +265,6 @@ drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request)
DRM_UNLOCK();
return (retcode);
-#else
- return (0);
-#endif
}
int
@@ -295,14 +282,12 @@ drm_agp_bind_ioctl(struct drm_device *dev, void *data,
void
drm_agp_remove_entry(struct drm_device *dev, struct drm_agp_mem *entry)
{
-#ifndef DRM_NO_AGP
TAILQ_REMOVE(&dev->agp->memory, entry, link);
if (entry->bound)
agp_unbind_memory(dev->agp->agpdev, entry->handle);
agp_free_memory(dev->agp->agpdev, entry->handle);
drm_free(entry);
-#endif
}
void
@@ -330,7 +315,7 @@ int
drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
{
struct drm_agp_mem *entry;
-
+
if (dev->agp == NULL || !dev->agp->acquired)
return (EINVAL);
@@ -343,7 +328,7 @@ drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
drm_agp_remove_entry(dev, entry);
DRM_UNLOCK();
-
+
return (0);
}
@@ -359,11 +344,10 @@ drm_agp_free_ioctl(struct drm_device *dev, void *data,
struct drm_agp_head *
drm_agp_init(void)
{
-#ifndef DRM_NO_AGP
struct device *agpdev;
struct drm_agp_head *head = NULL;
int agp_available = 1;
-
+
agpdev = agp_find_device(0);
if (agpdev == NULL)
agp_available = 0;
@@ -380,7 +364,6 @@ drm_agp_init(void)
TAILQ_INIT(&head->memory);
}
return (head);
-#else
- return (NULL);
-#endif
}
+
+#endif /* __OS_HAS_AGP */
diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c
index 777a54596cd..e79fbe84107 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.97 2012/08/30 18:01:36 mpi Exp $ */
+/* $OpenBSD: drm_drv.c,v 1.98 2012/09/08 16:42:20 mpi Exp $ */
/*-
* Copyright 2007-2009 Owain G. Ainsworth <oga@openbsd.org>
* Copyright © 2008 Intel Corporation
@@ -185,8 +185,10 @@ drm_attach(struct device *parent, struct device *self, void *aux)
}
if (dev->driver->flags & DRIVER_AGP) {
+#if __OS_HAS_AGP
if (da->is_agp)
dev->agp = drm_agp_init();
+#endif
if (dev->driver->flags & DRIVER_AGP_REQUIRE &&
dev->agp == NULL) {
printf(": couldn't find agp\n");
@@ -346,7 +348,9 @@ drm_lastclose(struct drm_device *dev)
if (dev->irq_enabled)
drm_irq_uninstall(dev);
+#if __OS_HAS_AGP
drm_agp_takedown(dev);
+#endif
drm_dma_takedown(dev);
DRM_LOCK();
@@ -635,8 +639,10 @@ drmioctl(dev_t kdev, u_long cmd, caddr_t data, int flags,
return (drm_freebufs(dev, data, file_priv));
case DRM_IOCTL_DMA:
return (drm_dma(dev, data, file_priv));
+#if __OS_HAS_AGP
case DRM_IOCTL_AGP_INFO:
return (drm_agp_info_ioctl(dev, data, file_priv));
+#endif
case DRM_IOCTL_GEM_FLINK:
return (drm_gem_flink_ioctl(dev, data, file_priv));
case DRM_IOCTL_GEM_OPEN:
@@ -664,6 +670,7 @@ drmioctl(dev_t kdev, u_long cmd, caddr_t data, int flags,
return (drm_addbufs(dev, (struct drm_buf_desc *)data));
case DRM_IOCTL_CONTROL:
return (drm_control(dev, data, file_priv));
+#if __OS_HAS_AGP
case DRM_IOCTL_AGP_ACQUIRE:
return (drm_agp_acquire_ioctl(dev, data, file_priv));
case DRM_IOCTL_AGP_RELEASE:
@@ -678,6 +685,7 @@ drmioctl(dev_t kdev, u_long cmd, caddr_t data, int flags,
return (drm_agp_bind_ioctl(dev, data, file_priv));
case DRM_IOCTL_AGP_UNBIND:
return (drm_agp_unbind_ioctl(dev, data, file_priv));
+#endif
case DRM_IOCTL_SG_ALLOC:
return (drm_sg_alloc_ioctl(dev, data, file_priv));
case DRM_IOCTL_SG_FREE: