summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Karrenbauer <karrenbauer@users.sourceforge.net>2003-04-12 14:17:17 +0000
committerAndreas Karrenbauer <karrenbauer@users.sourceforge.net>2003-04-12 14:17:17 +0000
commitaf65bd519557e42551bc92330fde892ed086e745 (patch)
tree2859398e57679d68617ac3777d5d7ff2bc1c3086
parentde45708324454267901f00c9876aa691d48eaa45 (diff)
- added function to wait for bci idle and one to enable bci
- copied and pasted a function to dispatch a vertex buffer from the radeon module started to adjust it to savage, but not working yet - added agp support ( basically ) DRM_FINDMAP works in the drm but allocation of buffers in the ddx fails
-rw-r--r--linux-core/savage.h11
-rw-r--r--linux-core/savage_drm.h3
-rw-r--r--linux-core/savage_drv.c3
-rw-r--r--linux-core/savage_drv.h7
-rw-r--r--linux/savage.h11
-rw-r--r--linux/savage_bci.c111
-rw-r--r--linux/savage_drm.h3
-rw-r--r--linux/savage_drv.c3
-rw-r--r--linux/savage_drv.h7
9 files changed, 137 insertions, 22 deletions
diff --git a/linux-core/savage.h b/linux-core/savage.h
index f4544f4e..bf167712 100644
--- a/linux-core/savage.h
+++ b/linux-core/savage.h
@@ -36,11 +36,16 @@
/* General customization:
*/
+#define __HAVE_AGP 1
+#define __MUST_HAVE_AGP 0
#define __HAVE_MTRR 1
#define __HAVE_CTX_BITMAP 1
+#define __HAVE_SG 0
+#define __HAVE_PCI_DMA 1
-#define DRIVER_IOCTLS \
- [DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { savage_bci_buffers, 1, 0 }, \
- [DRM_IOCTL_NR(DRM_IOCTL_SAVAGE_BCI_INIT)] = { savage_bci_init, 1, 1 },
+#define DRIVER_IOCTLS \
+ [DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { savage_bci_buffers, 1, 0 }, \
+ [DRM_IOCTL_NR(DRM_IOCTL_SAVAGE_BCI_INIT)] = { savage_bci_init, 1, 1 }, \
+ [DRM_IOCTL_NR(DRM_IOCTL_SAVAGE_VERTEX)] = { savage_bci_vertex, 1, 0 }, \
#endif
diff --git a/linux-core/savage_drm.h b/linux-core/savage_drm.h
index 673b5d6e..5ae2f5da 100644
--- a/linux-core/savage_drm.h
+++ b/linux-core/savage_drm.h
@@ -148,7 +148,8 @@ typedef struct {
/* Savage specific ioctls
* The device specific ioctl range is 0x40 to 0x79.
*/
-#define DRM_IOCTL_SAVAGE_BCI_INIT DRM_IOW( 0x40, drm_savage_init_t)
+#define DRM_IOCTL_SAVAGE_BCI_INIT DRM_IOW( 0x40, drm_savage_init_t)
+#define DRM_IOCTL_SAVAGE_VERTEX DRM_IOW( 0x49, drm_buf_t)
typedef struct drm_savage_init {
enum {
diff --git a/linux-core/savage_drv.c b/linux-core/savage_drv.c
index e7c1b8f5..8fc636b1 100644
--- a/linux-core/savage_drv.c
+++ b/linux-core/savage_drv.c
@@ -62,6 +62,9 @@ static drm_pci_list_t DRM(idlist)[] = {
#include "savage_drm.h"
#include "savage_drv.h"
+#include "ati_pcigart.h"
+
+#include "drm_agpsupport.h"
#include "drm_auth.h"
#include "drm_bufs.h"
#include "drm_context.h"
diff --git a/linux-core/savage_drv.h b/linux-core/savage_drv.h
index ca53d485..f704ecfa 100644
--- a/linux-core/savage_drv.h
+++ b/linux-core/savage_drv.h
@@ -129,11 +129,18 @@ typedef struct drm_savage_buf_priv {
/* Constants */
#define SAVAGE_MAX_USEC_TIMEOUT 100000 /* 100 ms */
+#define SAVAGE_DRAW_CONTROL_REG0 0x00485e0 /* scissoring */
+#define SAVAGE_DRAW_CONTROL_REG1 0x00485e4
+#define SAVAGE_VERTEX_BUFFER_ADDR_REG 0x0048c20
+
/* savage_bci.c */
extern int savage_bci_init( DRM_IOCTL_ARGS );
extern int savage_bci_buffers( DRM_IOCTL_ARGS );
+extern int savage_bci_vertex( DRM_IOCTL_ARGS );
+extern int savage_do_bci_start( drm_savage_private_t *dev_priv );
extern int savage_do_cleanup_bci( drm_device_t *dev );
+extern int savage_do_bci_idle( drm_savage_private_t *dev_priv );
#define SAVAGE_RING_HIGH_MARK 128
diff --git a/linux/savage.h b/linux/savage.h
index f4544f4e..bf167712 100644
--- a/linux/savage.h
+++ b/linux/savage.h
@@ -36,11 +36,16 @@
/* General customization:
*/
+#define __HAVE_AGP 1
+#define __MUST_HAVE_AGP 0
#define __HAVE_MTRR 1
#define __HAVE_CTX_BITMAP 1
+#define __HAVE_SG 0
+#define __HAVE_PCI_DMA 1
-#define DRIVER_IOCTLS \
- [DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { savage_bci_buffers, 1, 0 }, \
- [DRM_IOCTL_NR(DRM_IOCTL_SAVAGE_BCI_INIT)] = { savage_bci_init, 1, 1 },
+#define DRIVER_IOCTLS \
+ [DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { savage_bci_buffers, 1, 0 }, \
+ [DRM_IOCTL_NR(DRM_IOCTL_SAVAGE_BCI_INIT)] = { savage_bci_init, 1, 1 }, \
+ [DRM_IOCTL_NR(DRM_IOCTL_SAVAGE_VERTEX)] = { savage_bci_vertex, 1, 0 }, \
#endif
diff --git a/linux/savage_bci.c b/linux/savage_bci.c
index 70efe1c2..349e4a65 100644
--- a/linux/savage_bci.c
+++ b/linux/savage_bci.c
@@ -40,8 +40,8 @@
static int savage_do_init_bci( drm_device_t *dev, drm_savage_init_t *init )
{
- drm_savage_private_t *dev_priv;
u32 tmp;
+ drm_savage_private_t *dev_priv;
DRM_INFO( "initializing bci ...\n" );
dev_priv = DRM(alloc)( sizeof(drm_savage_private_t), DRM_MEM_DRIVER );
@@ -126,7 +126,7 @@ static int savage_do_init_bci( drm_device_t *dev, drm_savage_init_t *init )
DRM_INFO( "looking for mmio region ...\n" );
DRM_FIND_MAP( dev_priv->mmio, init->mmio_offset );
- if(!dev_priv->mmio) {
+ if(!dev_priv->mmio->handle) {
DRM_ERROR("could not find mmio region!\n");
dev->dev_private = (void *)dev_priv;
savage_do_cleanup_bci(dev);
@@ -136,13 +136,12 @@ static int savage_do_init_bci( drm_device_t *dev, drm_savage_init_t *init )
DRM_INFO( "looking for bci region ...\n" );
DRM_FIND_MAP( dev_priv->bci, init->bci_offset );
if(!dev_priv->bci) {
- DRM_ERROR("could not find bci region!\n");
+ DRM_ERROR("could not find bci region\n");
dev->dev_private = (void *)dev_priv;
savage_do_cleanup_bci(dev);
return DRM_ERR(EINVAL);
}
-/* FIXME: we do not support this right now */
-#if 0
+
DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset );
if(!dev_priv->buffers) {
DRM_ERROR("could not find dma buffer region!\n");
@@ -163,15 +162,12 @@ static int savage_do_init_bci( drm_device_t *dev, drm_savage_init_t *init )
}
}
-#endif
-
dev_priv->sarea_priv =
(drm_savage_sarea_t *)((u8 *)dev_priv->sarea->handle +
init->sarea_priv_offset);
if ( !dev_priv->is_pci ) {
/* FIXME: we do not support this right now */
-#if 0
DRM_IOREMAP( dev_priv->bci );
DRM_IOREMAP( dev_priv->buffers );
if(!dev_priv->bci->handle ||
@@ -181,20 +177,20 @@ static int savage_do_init_bci( drm_device_t *dev, drm_savage_init_t *init )
savage_do_cleanup_bci(dev);
return DRM_ERR(EINVAL);
}
-#endif
} else {
dev_priv->bci->handle =
(void *)dev_priv->bci->offset;
dev_priv->buffers->handle = (void *)dev_priv->buffers->offset;
- DRM_DEBUG( "dev_priv->bci->handle %p\n",
+ DRM_INFO( "dev_priv->bci->handle %p\n",
dev_priv->bci->handle );
- DRM_DEBUG( "dev_priv->buffers->handle %p\n",
+ DRM_INFO( "dev_priv->buffers->handle %p\n",
dev_priv->buffers->handle );
}
dev_priv->agp_size = init->agp_size;
+ dev_priv->agp_vm_start = 64*1024*1024;
/* FIXME: dev_priv->agp_vm_start = SAVAGE_READ( SAVAGE_CONFIG_APER_SIZE ); */
#if __REALLY_HAVE_AGP
if ( !dev_priv->is_pci )
@@ -207,11 +203,11 @@ static int savage_do_init_bci( drm_device_t *dev, drm_savage_init_t *init )
- dev->sg->handle
+ dev_priv->agp_vm_start);
- DRM_DEBUG( "dev_priv->agp_size %d\n",
+ DRM_INFO( "dev_priv->agp_size %d\n",
dev_priv->agp_size );
- DRM_DEBUG( "dev_priv->agp_vm_start 0x%x\n",
+ DRM_INFO( "dev_priv->agp_vm_start 0x%x\n",
dev_priv->agp_vm_start );
- DRM_DEBUG( "dev_priv->agp_buffers_offset 0x%lx\n",
+ DRM_INFO( "dev_priv->agp_buffers_offset 0x%lx\n",
dev_priv->agp_buffers_offset );
#if __REALLY_HAVE_SG
@@ -260,6 +256,8 @@ static int savage_do_init_bci( drm_device_t *dev, drm_savage_init_t *init )
/* FIXME: savage_do_engine_reset( dev ); */
+ savage_do_bci_start( dev_priv );
+
return 0;
}
@@ -290,6 +288,29 @@ int savage_do_cleanup_bci( drm_device_t *dev )
return 0;
}
+int savage_do_bci_start( drm_savage_private_t *dev_priv )
+{
+ SAVAGE_WRITE( 0x48C18, SAVAGE_READ( 0x48C18 ) | 0x08 );
+ DRM_INFO( "BCI enabled.\n" );
+}
+
+int savage_do_bci_idle( drm_savage_private_t *dev_priv )
+{
+ int i;
+
+ for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) {
+ if ( SAVAGE_READ(0x48C60) & 0x00020000 ) {
+ return 0;
+ }
+ DRM_UDELAY( 1 );
+ }
+
+ DRM_INFO( "timeout %d usec exeeded\n", dev_priv->usec_timeout );
+ DRM_INFO( "alternate status word: 0x%x\n", SAVAGE_READ( 0x48C60 ) );
+ DRM_INFO( "COB Pointers Register: 0x%x\n", SAVAGE_READ( 0x48C18 ) );
+ return DRM_ERR(EBUSY);
+}
+
int savage_bci_init( DRM_IOCTL_ARGS )
{
DRM_DEVICE;
@@ -406,3 +427,65 @@ int savage_bci_buffers( DRM_IOCTL_ARGS )
return ret;
}
+
+static __inline__ void savage_emit_clip_rect( drm_savage_private_t *dev_priv,
+ drm_clip_rect_t *box )
+{
+ DRM_DEBUG( " box: x1=%d y1=%d x2=%d y2=%d\n",
+ box->x1, box->y1, box->x2, box->y2 );
+
+ SAVAGE_WRITE( SAVAGE_DRAW_CONTROL_REG0, (box->y1 << 12) | box->x1 );
+ SAVAGE_WRITE( SAVAGE_DRAW_CONTROL_REG1, 0x05000000 | /* default */
+ (box->y1 << 12) | box->x1 );
+}
+
+static void savage_bci_dispatch_vertex( drm_device_t *dev,
+ drm_buf_t *buf,
+ drm_clip_rect_t *boxes,
+ int nbox )
+{
+ drm_savage_private_t *dev_priv = dev->dev_private;
+ drm_clip_rect_t box;
+ int offset = buf->bus_address;
+ int i = 0;
+
+ if ( savage_do_bci_idle( dev_priv ) ) {
+ DRM_ERROR( "Waiting for idle failed!\n" );
+ return;
+ }
+
+ do {
+ /* Emit the next cliprect */
+ if ( i < nbox ) {
+ if ( DRM_COPY_FROM_USER_UNCHECKED( &box, &boxes[i], sizeof(box) ) )
+ return;
+
+ savage_emit_clip_rect( dev_priv, &box );
+ }
+
+ /* Emit the vertex buffer rendering commands */
+ SAVAGE_WRITE( SAVAGE_VERTEX_BUFFER_ADDR_REG, offset );
+
+ i++;
+ } while ( i < nbox );
+}
+
+int savage_bci_vertex( DRM_IOCTL_ARGS )
+{
+ DRM_DEVICE;
+ drm_savage_private_t *dev_priv = dev->dev_private;
+ drm_buf_t *buf;
+
+ /* FIXME: LOCK_TEST_WITH_RETURN( dev ); */
+
+ if ( !dev_priv ) {
+ DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
+ return DRM_ERR(EINVAL);
+ }
+
+ DRM_COPY_FROM_USER_IOCTL( buf, (drm_buf_t *)data, sizeof(buf) );
+
+ savage_bci_dispatch_vertex( dev, buf, NULL, 0 );
+
+ return 0;
+}
diff --git a/linux/savage_drm.h b/linux/savage_drm.h
index 673b5d6e..5ae2f5da 100644
--- a/linux/savage_drm.h
+++ b/linux/savage_drm.h
@@ -148,7 +148,8 @@ typedef struct {
/* Savage specific ioctls
* The device specific ioctl range is 0x40 to 0x79.
*/
-#define DRM_IOCTL_SAVAGE_BCI_INIT DRM_IOW( 0x40, drm_savage_init_t)
+#define DRM_IOCTL_SAVAGE_BCI_INIT DRM_IOW( 0x40, drm_savage_init_t)
+#define DRM_IOCTL_SAVAGE_VERTEX DRM_IOW( 0x49, drm_buf_t)
typedef struct drm_savage_init {
enum {
diff --git a/linux/savage_drv.c b/linux/savage_drv.c
index e7c1b8f5..8fc636b1 100644
--- a/linux/savage_drv.c
+++ b/linux/savage_drv.c
@@ -62,6 +62,9 @@ static drm_pci_list_t DRM(idlist)[] = {
#include "savage_drm.h"
#include "savage_drv.h"
+#include "ati_pcigart.h"
+
+#include "drm_agpsupport.h"
#include "drm_auth.h"
#include "drm_bufs.h"
#include "drm_context.h"
diff --git a/linux/savage_drv.h b/linux/savage_drv.h
index ca53d485..f704ecfa 100644
--- a/linux/savage_drv.h
+++ b/linux/savage_drv.h
@@ -129,11 +129,18 @@ typedef struct drm_savage_buf_priv {
/* Constants */
#define SAVAGE_MAX_USEC_TIMEOUT 100000 /* 100 ms */
+#define SAVAGE_DRAW_CONTROL_REG0 0x00485e0 /* scissoring */
+#define SAVAGE_DRAW_CONTROL_REG1 0x00485e4
+#define SAVAGE_VERTEX_BUFFER_ADDR_REG 0x0048c20
+
/* savage_bci.c */
extern int savage_bci_init( DRM_IOCTL_ARGS );
extern int savage_bci_buffers( DRM_IOCTL_ARGS );
+extern int savage_bci_vertex( DRM_IOCTL_ARGS );
+extern int savage_do_bci_start( drm_savage_private_t *dev_priv );
extern int savage_do_cleanup_bci( drm_device_t *dev );
+extern int savage_do_bci_idle( drm_savage_private_t *dev_priv );
#define SAVAGE_RING_HIGH_MARK 128