summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <anholt@freebsd.org>2005-08-15 18:07:12 +0000
committerEric Anholt <anholt@freebsd.org>2005-08-15 18:07:12 +0000
commit8c21b783c3e38aa2c2d16e11ec01cf695f8e7f8a (patch)
treec40ed75e583b24b7a9947221766c82d5a4cd061d
parent4f5961eeeee806a2d6e08e159c56262d4f060cba (diff)
Port the VIA DRM to FreeBSD. Original patch by Jake, with some cleanup by
me to match other drivers and avoid ifdeffing. The linux via_drv.c will be moved from shared-core to linux-core soon by repocopy. Submitted by: Jake Burkholder <jake@FreeBSD.org> Tested by: unichrome
-rw-r--r--bsd-core/Makefile10
-rw-r--r--bsd-core/via/.cvsignore8
-rw-r--r--bsd-core/via/Makefile24
-rw-r--r--bsd-core/via_drv.c118
-rw-r--r--linux-core/drm_os_linux.h1
-rw-r--r--shared-core/drm_pciids.txt2
-rw-r--r--shared-core/via_dma.c31
-rw-r--r--shared-core/via_drm.h18
-rw-r--r--shared-core/via_drv.c27
-rw-r--r--shared-core/via_drv.h31
-rw-r--r--shared-core/via_ds.c10
-rw-r--r--shared-core/via_irq.c13
-rw-r--r--shared-core/via_map.c44
-rw-r--r--shared-core/via_verifier.c10
-rw-r--r--shared-core/via_verifier.h6
-rw-r--r--shared-core/via_video.c4
16 files changed, 267 insertions, 90 deletions
diff --git a/bsd-core/Makefile b/bsd-core/Makefile
index 33dcc2f5e..57189e9a4 100644
--- a/bsd-core/Makefile
+++ b/bsd-core/Makefile
@@ -41,8 +41,9 @@ SHAREDFILES= drm.h \
sis_ds.h \
sis_mm.c \
tdfx_drv.h \
+ via_3d_reg.h \
+ via_dma.c \
via_drm.h \
- via_drv.c \
via_drv.h \
via_ds.c \
via_ds.h \
@@ -50,10 +51,11 @@ SHAREDFILES= drm.h \
via_map.c \
via_mm.c \
via_mm.h \
- via_3d_reg.h \
- via_dma.c
+ via_verifier.c \
+ via_verifier.h \
+ via_video.c
-SUBDIR = drm mach64 mga r128 radeon sis tdfx # i915
+SUBDIR = drm mach64 mga r128 radeon sis tdfx via # i915
CLEANFILES+= ${SHAREDFILES}
diff --git a/bsd-core/via/.cvsignore b/bsd-core/via/.cvsignore
new file mode 100644
index 000000000..7a23987a5
--- /dev/null
+++ b/bsd-core/via/.cvsignore
@@ -0,0 +1,8 @@
+.depend
+bus_if.h
+device_if.h
+export_syms
+opt_drm.h
+pci_if.h
+via.kld
+via.ko
diff --git a/bsd-core/via/Makefile b/bsd-core/via/Makefile
new file mode 100644
index 000000000..7aaa01dfe
--- /dev/null
+++ b/bsd-core/via/Makefile
@@ -0,0 +1,24 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/..
+KMOD = via
+NO_MAN = YES
+SRCS = via_dma.c via_drv.c via_ds.c via_irq.c via_map.c via_mm.c \
+ via_verifier.c via_video.c
+SRCS += device_if.h bus_if.h pci_if.h opt_drm.h
+CFLAGS += ${DEBUG_FLAGS} -I. -I..
+
+.if defined(DRM_DEBUG)
+DRM_DEBUG_OPT= "\#define DRM_DEBUG 1"
+.endif
+
+.if !defined(DRM_NOLINUX)
+DRM_LINUX_OPT= "\#define DRM_LINUX 1"
+.endif
+
+opt_drm.h:
+ touch opt_drm.h
+ echo $(DRM_DEBUG_OPT) >> opt_drm.h
+ echo $(DRM_LINUX_OPT) >> opt_drm.h
+
+.include <bsd.kmod.mk>
diff --git a/bsd-core/via_drv.c b/bsd-core/via_drv.c
new file mode 100644
index 000000000..c90af66d0
--- /dev/null
+++ b/bsd-core/via_drv.c
@@ -0,0 +1,118 @@
+/* via_drv.c -- VIA unichrome driver -*- linux-c -*-
+ * Created: Fri Aug 12 2005 by anholt@FreeBSD.org
+ */
+/*-
+ * Copyright 2005 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.
+ *
+ * Authors:
+ * Eric Anholt <anholt@FreeBSD.org>
+ *
+ */
+
+#include "drmP.h"
+#include "drm.h"
+#include "via_drm.h"
+#include "via_drv.h"
+#include "drm_pciids.h"
+
+/* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
+static drm_pci_id_list_t via_pciidlist[] = {
+ viadrv_PCI_IDS
+};
+
+extern drm_ioctl_desc_t via_ioctls[];
+extern int via_max_ioctl;
+
+static void via_configure(drm_device_t *dev)
+{
+ dev->driver.buf_priv_size = 1;
+ dev->driver.load = via_driver_load;
+ dev->driver.unload = via_driver_unload;
+ dev->driver.context_ctor = via_init_context;
+ dev->driver.context_dtor = via_final_context;
+ dev->driver.vblank_wait = via_driver_vblank_wait;
+ dev->driver.irq_preinstall = via_driver_irq_preinstall;
+ dev->driver.irq_postinstall = via_driver_irq_postinstall;
+ dev->driver.irq_uninstall = via_driver_irq_uninstall;
+ dev->driver.irq_handler = via_driver_irq_handler;
+ dev->driver.dma_quiescent = via_driver_dma_quiescent;
+
+ dev->driver.ioctls = via_ioctls;
+ dev->driver.max_ioctl = via_max_ioctl;
+
+ dev->driver.name = DRIVER_NAME;
+ dev->driver.desc = DRIVER_DESC;
+ dev->driver.date = DRIVER_DATE;
+ dev->driver.major = DRIVER_MAJOR;
+ dev->driver.minor = DRIVER_MINOR;
+ dev->driver.patchlevel = DRIVER_PATCHLEVEL;
+
+ dev->driver.use_agp = 1;
+ dev->driver.use_mtrr = 1;
+ dev->driver.use_irq = 1;
+ dev->driver.use_vbl_irq = 1;
+}
+
+#ifdef __FreeBSD__
+static int
+via_probe(device_t dev)
+{
+ return drm_probe(dev, via_pciidlist);
+}
+
+static int
+via_attach(device_t nbdev)
+{
+ drm_device_t *dev = device_get_softc(nbdev);
+
+ bzero(dev, sizeof(drm_device_t));
+ via_configure(dev);
+ return drm_attach(nbdev, via_pciidlist);
+}
+
+static device_method_t via_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, via_probe),
+ DEVMETHOD(device_attach, via_attach),
+ DEVMETHOD(device_detach, drm_detach),
+
+ { 0, 0 }
+};
+
+static driver_t via_driver = {
+ "drm",
+ via_methods,
+ sizeof(drm_device_t)
+};
+
+extern devclass_t drm_devclass;
+DRIVER_MODULE(via, pci, via_driver, drm_devclass, 0, 0);
+MODULE_DEPEND(via, drm, 1, 1, 1);
+
+#elif defined(__NetBSD__) || defined(__OpenBSD__)
+#ifdef _LKM
+CFDRIVER_DECL(via, DV_TTY, NULL);
+#else
+CFATTACH_DECL(via, sizeof(drm_device_t), drm_probe, drm_attach, drm_detach,
+ drm_activate);
+#endif
+#endif
diff --git a/linux-core/drm_os_linux.h b/linux-core/drm_os_linux.h
index 1ed1cca42..d3fb67e60 100644
--- a/linux-core/drm_os_linux.h
+++ b/linux-core/drm_os_linux.h
@@ -13,6 +13,7 @@
#define DRM_ERR(d) -(d)
/** Current process ID */
#define DRM_CURRENTPID current->pid
+#define DRM_SUSER(p) capable(CAP_SYS_ADMIN)
#define DRM_UDELAY(d) udelay(d)
#if LINUX_VERSION_CODE <= 0x020608 /* KERNEL_VERSION(2,6,8) */
/** Read a byte from a MMIO region */
diff --git a/shared-core/drm_pciids.txt b/shared-core/drm_pciids.txt
index cda53d945..50b3d6a1e 100644
--- a/shared-core/drm_pciids.txt
+++ b/shared-core/drm_pciids.txt
@@ -166,7 +166,7 @@
[viadrv]
0x1106 0x3022 0 "VIA CLE266 3022"
-0x1106 0x3118 0 "VIA CN400 / PM8X0"
+0x1106 0x3118 VIA_PRO_GROUP_A "VIA CN400 / PM8X0"
0x1106 0x3122 0 "VIA CLE266"
0x1106 0x7205 0 "VIA KM400"
0x1106 0x3108 0 "VIA K8M800"
diff --git a/shared-core/via_dma.c b/shared-core/via_dma.c
index 4f60f7f41..a3d4e3d67 100644
--- a/shared-core/via_dma.c
+++ b/shared-core/via_dma.c
@@ -217,7 +217,9 @@ static int via_initialize(drm_device_t * dev,
dev_priv->dma_wrap = init->size;
dev_priv->dma_offset = init->offset;
dev_priv->last_pause_ptr = NULL;
- dev_priv->hw_addr_ptr = dev_priv->mmio->handle + init->reg_pause_addr;
+ dev_priv->hw_addr_ptr =
+ (volatile uint32_t *)((char *)dev_priv->mmio->handle +
+ init->reg_pause_addr);
via_cmdbuf_start(dev_priv);
@@ -236,13 +238,13 @@ int via_dma_init(DRM_IOCTL_ARGS)
switch (init.func) {
case VIA_INIT_DMA:
- if (!capable(CAP_SYS_ADMIN))
+ if (!DRM_SUSER(DRM_CURPROC))
retcode = DRM_ERR(EPERM);
else
retcode = via_initialize(dev, dev_priv, &init);
break;
case VIA_CLEANUP_DMA:
- if (!capable(CAP_SYS_ADMIN))
+ if (!DRM_SUSER(DRM_CURPROC))
retcode = DRM_ERR(EPERM);
else
retcode = via_dma_cleanup(dev);
@@ -356,8 +358,6 @@ int via_cmdbuffer(DRM_IOCTL_ARGS)
return 0;
}
-extern int
-via_parse_command_stream(drm_device_t *dev, const uint32_t * buf, unsigned int size);
static int via_dispatch_pci_cmdbuffer(drm_device_t * dev,
drm_via_cmdbuffer_t * cmd)
{
@@ -455,7 +455,7 @@ static int via_hook_segment(drm_via_private_t *dev_priv,
if ((count <= 8) && (count >= 0)) {
uint32_t rgtr, ptr;
rgtr = *(dev_priv->hw_addr_ptr);
- ptr = ((char *)dev_priv->last_pause_ptr - dev_priv->dma_ptr) +
+ ptr = ((volatile char *)dev_priv->last_pause_ptr - dev_priv->dma_ptr) +
dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr + 4 -
CMDBUF_ALIGNMENT_SIZE;
if (rgtr <= ptr) {
@@ -475,7 +475,7 @@ static int via_hook_segment(drm_via_private_t *dev_priv,
while ((VIA_READ(VIA_REG_STATUS) & VIA_CMD_RGTR_BUSY) && count--);
rgtr = *(dev_priv->hw_addr_ptr);
- ptr = ((char *)paused_at - dev_priv->dma_ptr) +
+ ptr = ((volatile char *)paused_at - dev_priv->dma_ptr) +
dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr + 4;
@@ -739,3 +739,20 @@ via_cmdbuf_size(DRM_IOCTL_ARGS)
sizeof(d_siz));
return ret;
}
+
+drm_ioctl_desc_t via_ioctls[] = {
+ [DRM_IOCTL_NR(DRM_VIA_ALLOCMEM)] = {via_mem_alloc, 1, 0, 0},
+ [DRM_IOCTL_NR(DRM_VIA_FREEMEM)] = {via_mem_free, 1, 0, 0},
+ [DRM_IOCTL_NR(DRM_VIA_AGP_INIT)] = {via_agp_init, 1, 1, 0},
+ [DRM_IOCTL_NR(DRM_VIA_FB_INIT)] = {via_fb_init, 1, 1, 0},
+ [DRM_IOCTL_NR(DRM_VIA_MAP_INIT)] = {via_map_init, 1, 1, 0},
+ [DRM_IOCTL_NR(DRM_VIA_DEC_FUTEX)] = {via_decoder_futex, 1, 0, 0},
+ [DRM_IOCTL_NR(DRM_VIA_DMA_INIT)] = {via_dma_init, 1, 0, 0},
+ [DRM_IOCTL_NR(DRM_VIA_CMDBUFFER)] = {via_cmdbuffer, 1, 0, 0},
+ [DRM_IOCTL_NR(DRM_VIA_FLUSH)] = {via_flush_ioctl, 1, 0, 0},
+ [DRM_IOCTL_NR(DRM_VIA_PCICMD)] = {via_pci_cmdbuffer, 1, 0, 0},
+ [DRM_IOCTL_NR(DRM_VIA_CMDBUF_SIZE)] = {via_cmdbuf_size, 1, 0, 0},
+ [DRM_IOCTL_NR(DRM_VIA_WAIT_IRQ)] = {via_wait_irq, 1, 0, 0}
+};
+
+int via_max_ioctl = DRM_ARRAY_SIZE(via_ioctls);
diff --git a/shared-core/via_drm.h b/shared-core/via_drm.h
index be346bb0a..cc129a367 100644
--- a/shared-core/via_drm.h
+++ b/shared-core/via_drm.h
@@ -31,7 +31,7 @@
#ifndef _VIA_DEFINES_
#define _VIA_DEFINES_
-#ifndef __KERNEL__
+#if !defined(__KERNEL__) && !defined(_KERNEL)
#include "via_drmclient.h"
#endif
@@ -224,20 +224,4 @@ typedef union drm_via_irqwait {
struct drm_wait_vblank_reply reply;
} drm_via_irqwait_t;
-#ifdef __KERNEL__
-
-int via_fb_init(DRM_IOCTL_ARGS);
-int via_mem_alloc(DRM_IOCTL_ARGS);
-int via_mem_free(DRM_IOCTL_ARGS);
-int via_agp_init(DRM_IOCTL_ARGS);
-int via_map_init(DRM_IOCTL_ARGS);
-int via_decoder_futex(DRM_IOCTL_ARGS);
-int via_dma_init(DRM_IOCTL_ARGS);
-int via_cmdbuffer(DRM_IOCTL_ARGS);
-int via_flush_ioctl(DRM_IOCTL_ARGS);
-int via_pci_cmdbuffer(DRM_IOCTL_ARGS);
-int via_cmdbuf_size(DRM_IOCTL_ARGS);
-int via_wait_irq(DRM_IOCTL_ARGS);
-
-#endif
#endif /* _VIA_DRM_H_ */
diff --git a/shared-core/via_drv.c b/shared-core/via_drv.c
index fd0dbcc96..8291ae8e0 100644
--- a/shared-core/via_drv.c
+++ b/shared-core/via_drv.c
@@ -39,30 +39,16 @@ static struct pci_device_id pciidlist[] = {
viadrv_PCI_IDS
};
-/*
- * {function, auth_needed, master, root_only}
- */
-
-static drm_ioctl_desc_t ioctls[] = {
- [DRM_IOCTL_NR(DRM_VIA_ALLOCMEM)] = {via_mem_alloc, 1, 0, 0},
- [DRM_IOCTL_NR(DRM_VIA_FREEMEM)] = {via_mem_free, 1, 0, 0},
- [DRM_IOCTL_NR(DRM_VIA_AGP_INIT)] = {via_agp_init, 1, 1, 0},
- [DRM_IOCTL_NR(DRM_VIA_FB_INIT)] = {via_fb_init, 1, 1, 0},
- [DRM_IOCTL_NR(DRM_VIA_MAP_INIT)] = {via_map_init, 1, 1, 0},
- [DRM_IOCTL_NR(DRM_VIA_DEC_FUTEX)] = {via_decoder_futex, 1, 0, 0},
- [DRM_IOCTL_NR(DRM_VIA_DMA_INIT)] = {via_dma_init, 1, 0, 0},
- [DRM_IOCTL_NR(DRM_VIA_CMDBUFFER)] = {via_cmdbuffer, 1, 0, 0},
- [DRM_IOCTL_NR(DRM_VIA_FLUSH)] = {via_flush_ioctl, 1, 0, 0},
- [DRM_IOCTL_NR(DRM_VIA_PCICMD)] = {via_pci_cmdbuffer, 1, 0, 0},
- [DRM_IOCTL_NR(DRM_VIA_CMDBUF_SIZE)] = {via_cmdbuf_size, 1, 0, 0},
- [DRM_IOCTL_NR(DRM_VIA_WAIT_IRQ)] = {via_wait_irq, 1, 0, 0}
-};
+extern drm_ioctl_desc_t via_ioctls[];
+extern int via_max_ioctl;
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent);
static struct drm_driver driver = {
.driver_features =
DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_IRQ |
DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL,
+ .load = via_driver_load,
+ .unload = via_driver_unload,
.context_ctor = via_init_context,
.context_dtor = via_final_context,
.vblank_wait = via_driver_vblank_wait,
@@ -75,8 +61,7 @@ static struct drm_driver driver = {
.reclaim_buffers = drm_core_reclaim_buffers,
.get_map_ofs = drm_core_get_map_ofs,
.get_reg_ofs = drm_core_get_reg_ofs,
- .ioctls = ioctls,
- .num_ioctls = DRM_ARRAY_SIZE(ioctls),
+ .ioctls = via_ioctls,
.fops = {
.owner = THIS_MODULE,
.open = drm_open,
@@ -108,6 +93,8 @@ static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
static int __init via_init(void)
{
+ driver.num_ioctls = via_max_ioctl;
+
via_init_command_verifier();
return drm_init(&driver, pciidlist);
}
diff --git a/shared-core/via_drv.h b/shared-core/via_drv.h
index ba1c6d78e..acbf17e1d 100644
--- a/shared-core/via_drv.h
+++ b/shared-core/via_drv.h
@@ -43,7 +43,7 @@
typedef struct drm_via_ring_buffer {
- drm_map_t map;
+ drm_local_map_t map;
char *virtual_start;
} drm_via_ring_buffer_t;
@@ -58,9 +58,9 @@ typedef struct drm_via_irq {
typedef struct drm_via_private {
drm_via_sarea_t *sarea_priv;
- drm_map_t *sarea;
- drm_map_t *fb;
- drm_map_t *mmio;
+ drm_local_map_t *sarea;
+ drm_local_map_t *fb;
+ drm_local_map_t *mmio;
unsigned long agpAddr;
wait_queue_head_t decoder_queue[VIA_NR_XVMC_LOCKS];
char *dma_ptr;
@@ -86,6 +86,11 @@ typedef struct drm_via_private {
uint32_t irq_pending_mask;
} drm_via_private_t;
+enum via_family {
+ VIA_OTHER = 0,
+ VIA_PRO_GROUP_A,
+};
+
/* VIA MMIO register access */
#define VIA_BASE ((dev_priv->mmio))
@@ -94,12 +99,25 @@ typedef struct drm_via_private {
#define VIA_READ8(reg) DRM_READ8(VIA_BASE, reg)
#define VIA_WRITE8(reg,val) DRM_WRITE8(VIA_BASE, reg, val)
+extern int via_fb_init(DRM_IOCTL_ARGS);
+extern int via_mem_alloc(DRM_IOCTL_ARGS);
+extern int via_mem_free(DRM_IOCTL_ARGS);
+extern int via_agp_init(DRM_IOCTL_ARGS);
+extern int via_map_init(DRM_IOCTL_ARGS);
+extern int via_decoder_futex(DRM_IOCTL_ARGS);
+extern int via_dma_init(DRM_IOCTL_ARGS);
+extern int via_cmdbuffer(DRM_IOCTL_ARGS);
+extern int via_flush_ioctl(DRM_IOCTL_ARGS);
+extern int via_pci_cmdbuffer(DRM_IOCTL_ARGS);
+extern int via_cmdbuf_size(DRM_IOCTL_ARGS);
+extern int via_wait_irq(DRM_IOCTL_ARGS);
+
+extern int via_driver_load(drm_device_t *dev, unsigned long chipset);
+extern int via_driver_unload(drm_device_t *dev);
extern int via_init_context(drm_device_t * dev, int context);
extern int via_final_context(drm_device_t * dev, int context);
extern int via_do_cleanup_map(drm_device_t * dev);
-extern int via_map_init(struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg);
extern int via_driver_vblank_wait(drm_device_t * dev, unsigned int *sequence);
extern irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS);
@@ -114,5 +132,4 @@ extern void via_init_futex(drm_via_private_t *dev_priv);
extern void via_cleanup_futex(drm_via_private_t *dev_priv);
extern void via_release_futex(drm_via_private_t *dev_priv, int context);
-
#endif
diff --git a/shared-core/via_ds.c b/shared-core/via_ds.c
index 5c71e0892..9091fb5b3 100644
--- a/shared-core/via_ds.c
+++ b/shared-core/via_ds.c
@@ -22,14 +22,8 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
-#include <linux/module.h>
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/poll.h>
-#include <linux/pci.h>
-#include <asm/io.h>
+
+#include "drmP.h"
#include "via_ds.h"
extern unsigned int VIA_DEBUG;
diff --git a/shared-core/via_irq.c b/shared-core/via_irq.c
index e8027f3a9..f87b2f2c2 100644
--- a/shared-core/via_irq.c
+++ b/shared-core/via_irq.c
@@ -87,7 +87,11 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
if (status & VIA_IRQ_VBLANK_PENDING) {
atomic_inc(&dev->vbl_received);
if (!(atomic_read(&dev->vbl_received) & 0x0F)) {
+#ifdef __linux__
do_gettimeofday(&cur_vblank);
+#else
+ microtime(&cur_vblank);
+#endif
if (dev_priv->last_vblank_valid) {
dev_priv->usec_per_vblank =
time_diff( &cur_vblank,&dev_priv->last_vblank) >> 4;
@@ -237,7 +241,7 @@ void via_driver_irq_preinstall(drm_device_t * dev)
dev_priv->last_vblank_valid = 0;
- // Clear VSync interrupt regs
+ /* Clear VSync interrupt regs */
status = VIA_READ(VIA_REG_INTERRUPT);
VIA_WRITE(VIA_REG_INTERRUPT, status &
~(dev_priv->irq_enable_mask));
@@ -287,8 +291,7 @@ void via_driver_irq_uninstall(drm_device_t * dev)
int via_wait_irq(DRM_IOCTL_ARGS)
{
- drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->head->dev;
+ DRM_DEVICE;
drm_via_irqwait_t __user *argp = (void __user *)data;
drm_via_irqwait_t irqwait;
struct timeval now;
@@ -329,7 +332,11 @@ int via_wait_irq(DRM_IOCTL_ARGS)
ret = via_driver_irq_wait(dev, irqwait.request.irq, force_sequence,
&irqwait.request.sequence);
+#ifdef __linux__
do_gettimeofday(&now);
+#else
+ microtime(&now);
+#endif
irqwait.reply.tval_sec = now.tv_sec;
irqwait.reply.tval_usec = now.tv_usec;
diff --git a/shared-core/via_map.c b/shared-core/via_map.c
index bb171139e..8e4054187 100644
--- a/shared-core/via_map.c
+++ b/shared-core/via_map.c
@@ -27,16 +27,10 @@
static int via_do_init_map(drm_device_t * dev, drm_via_init_t * init)
{
- drm_via_private_t *dev_priv;
+ drm_via_private_t *dev_priv = dev->dev_private;
DRM_DEBUG("%s\n", __FUNCTION__);
- dev_priv = drm_alloc(sizeof(drm_via_private_t), DRM_MEM_DRIVER);
- if (dev_priv == NULL)
- return -ENOMEM;
-
- memset(dev_priv, 0, sizeof(drm_via_private_t));
-
DRM_GETSAREA();
if (!dev_priv->sarea) {
DRM_ERROR("could not find sarea!\n");
@@ -67,7 +61,6 @@ static int via_do_init_map(drm_device_t * dev, drm_via_init_t * init)
dev_priv->agpAddr = init->agpAddr;
via_init_futex( dev_priv );
- dev_priv->pro_group_a = (dev->pdev->device == 0x3118);
dev->dev_private = (void *)dev_priv;
return 0;
@@ -75,19 +68,12 @@ static int via_do_init_map(drm_device_t * dev, drm_via_init_t * init)
int via_do_cleanup_map(drm_device_t * dev)
{
- if (dev->dev_private) {
-
- drm_via_private_t *dev_priv = dev->dev_private;
-
- via_dma_cleanup(dev);
-
- drm_free(dev_priv, sizeof(drm_via_private_t), DRM_MEM_DRIVER);
- dev->dev_private = NULL;
- }
+ via_dma_cleanup(dev);
return 0;
}
+
int via_map_init(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
@@ -108,4 +94,28 @@ int via_map_init(DRM_IOCTL_ARGS)
return -EINVAL;
}
+int via_driver_load(drm_device_t *dev, unsigned long chipset)
+{
+ drm_via_private_t *dev_priv;
+
+ dev_priv = drm_calloc(1, sizeof(drm_via_private_t), DRM_MEM_DRIVER);
+ if (dev_priv == NULL)
+ return DRM_ERR(ENOMEM);
+
+ dev->dev_private = (void *)dev_priv;
+
+ if (chipset == VIA_PRO_GROUP_A)
+ dev_priv->pro_group_a = 1;
+
+ return 0;
+}
+
+int via_driver_unload(drm_device_t *dev)
+{
+ drm_via_private_t *dev_priv = dev->dev_private;
+
+ drm_free(dev_priv, sizeof(drm_via_private_t), DRM_MEM_DRIVER);
+
+ return 0;
+}
diff --git a/shared-core/via_verifier.c b/shared-core/via_verifier.c
index 65a7b9e7d..6b70be218 100644
--- a/shared-core/via_verifier.c
+++ b/shared-core/via_verifier.c
@@ -259,23 +259,29 @@ eat_words(const uint32_t **buf, const uint32_t *buf_end, unsigned num_words)
* Partially stolen from drm_memory.h
*/
-static __inline__ drm_map_t *
+static __inline__ drm_local_map_t *
via_drm_lookup_agp_map (drm_via_state_t *seq, unsigned long offset, unsigned long size,
drm_device_t *dev)
{
+#ifdef __linux__
struct list_head *list;
drm_map_list_t *r_list;
- drm_map_t *map = seq->map_cache;
+#endif
+ drm_local_map_t *map = seq->map_cache;
if (map && map->offset <= offset && (offset + size) <= (map->offset + map->size)) {
return map;
}
+#ifdef __linux__
list_for_each(list, &dev->maplist->head) {
r_list = (drm_map_list_t *) list;
map = r_list->map;
if (!map)
continue;
+#else
+ TAILQ_FOREACH(map, &dev->maplist, link) {
+#endif
if (map->offset <= offset && (offset + size) <= (map->offset + map->size) &&
!(map->flags & _DRM_RESTRICTED) && (map->type == _DRM_AGP)) {
seq->map_cache = map;
diff --git a/shared-core/via_verifier.h b/shared-core/via_verifier.h
index a8e135926..c0ffc97f8 100644
--- a/shared-core/via_verifier.h
+++ b/shared-core/via_verifier.h
@@ -49,13 +49,15 @@ typedef struct{
int agp_texture;
int multitex;
drm_device_t *dev;
- drm_map_t *map_cache;
+ drm_local_map_t *map_cache;
uint32_t vertex_count;
int agp;
const uint32_t *buf_start;
} drm_via_state_t;
extern int via_verify_command_stream(const uint32_t * buf, unsigned int size,
- drm_device_t *dev, int agp);
+ drm_device_t *dev, int agp);
+extern int via_parse_command_stream(drm_device_t *dev, const uint32_t * buf,
+ unsigned int size);
#endif
diff --git a/shared-core/via_video.c b/shared-core/via_video.c
index 8ba096741..04d37cae1 100644
--- a/shared-core/via_video.c
+++ b/shared-core/via_video.c
@@ -57,7 +57,7 @@ via_release_futex(drm_via_private_t *dev_priv, int context)
return;
for (i=0; i < VIA_NR_XVMC_LOCKS; ++i) {
- lock = (int *) XVMCLOCKPTR(dev_priv->sarea_priv, i);
+ lock = (volatile int *) XVMCLOCKPTR(dev_priv->sarea_priv, i);
if ( (_DRM_LOCKING_CONTEXT( *lock ) == context)) {
if (_DRM_LOCK_IS_HELD( *lock ) && (*lock & _DRM_LOCK_CONT)) {
DRM_WAKEUP( &(dev_priv->decoder_queue[i]));
@@ -85,7 +85,7 @@ via_decoder_futex(DRM_IOCTL_ARGS)
if (fx.lock > VIA_NR_XVMC_LOCKS)
return -EFAULT;
- lock = (int *)XVMCLOCKPTR(sAPriv, fx.lock);
+ lock = (volatile int *)XVMCLOCKPTR(sAPriv, fx.lock);
switch (fx.func) {
case VIA_FUTEX_WAIT: