summaryrefslogtreecommitdiffstats
path: root/sys/dev/drm/ati_pcigart.c
diff options
context:
space:
mode:
authoranholt <anholt@FreeBSD.org>2005-11-28 23:13:57 +0000
committeranholt <anholt@FreeBSD.org>2005-11-28 23:13:57 +0000
commit3de8a0378fe9d46d02eec1b0054452fdcdee5327 (patch)
tree1cdf797deb33b0b51180c1ae0a987558664b1077 /sys/dev/drm/ati_pcigart.c
parente6a12190f6e28e22e3376a0729d6dd9cee1982bc (diff)
downloadFreeBSD-src-3de8a0378fe9d46d02eec1b0054452fdcdee5327.zip
FreeBSD-src-3de8a0378fe9d46d02eec1b0054452fdcdee5327.tar.gz
Update DRM to CVS snapshot as of 2005-11-28. Notable changes:
- S3 Savage driver ported. - Added support for ATI_fragment_shader registers for r200. - Improved r300 support, needed for latest r300 DRI driver. - (possibly) r300 PCIE support, needs X.Org server from CVS. - Added support for PCI Matrox cards. - Software fallbacks fixed for Rage 128, which used to render badly or hang. - Some issues reported by WITNESS are fixed. - i915 module Makefile added, as the driver may now be working, but is untested. - Added scripts for copying and preprocessing DRM CVS for inclusion in the kernel. Thanks to Daniel Stone for getting me started on that.
Diffstat (limited to 'sys/dev/drm/ati_pcigart.c')
-rw-r--r--sys/dev/drm/ati_pcigart.c98
1 files changed, 39 insertions, 59 deletions
diff --git a/sys/dev/drm/ati_pcigart.c b/sys/dev/drm/ati_pcigart.c
index 1442247..386702c 100644
--- a/sys/dev/drm/ati_pcigart.c
+++ b/sys/dev/drm/ati_pcigart.c
@@ -27,66 +27,58 @@
* Authors:
* Gareth Hughes <gareth@valinux.com>
*
- * $FreeBSD$
*/
-#include "dev/drm/drmP.h"
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
-#if PAGE_SIZE == 8192
-# define ATI_PCIGART_TABLE_ORDER 2
-# define ATI_PCIGART_TABLE_PAGES (1 << 2)
-#elif PAGE_SIZE == 4096
-# define ATI_PCIGART_TABLE_ORDER 3
-# define ATI_PCIGART_TABLE_PAGES (1 << 3)
-#elif
-# error - PAGE_SIZE not 8K or 4K
-#endif
+#include "dev/drm/drmP.h"
-# define ATI_MAX_PCIGART_PAGES 8192 /* 32 MB aperture, 4K pages */
-# define ATI_PCIGART_PAGE_SIZE 4096 /* PCI GART page size */
+#define ATI_PCIGART_PAGE_SIZE 4096 /* PCI GART page size */
+#define ATI_MAX_PCIGART_PAGES 8192 /* 32 MB aperture, 4K pages */
+#define ATI_PCIGART_TABLE_SIZE 32768
-int drm_ati_pcigart_init(drm_device_t *dev, unsigned long *addr,
- dma_addr_t *bus_addr, int is_pcie)
+int drm_ati_pcigart_init(drm_device_t *dev, drm_ati_pcigart_info *gart_info)
{
- drm_sg_mem_t *entry = dev->sg;
- unsigned long address = 0;
unsigned long pages;
- u32 *pci_gart=0, page_base, bus_address = 0;
- int i, j, ret = 0;
+ u32 *pci_gart = NULL, page_base;
+ int i, j;
- if ( !entry ) {
+ if (dev->sg == NULL) {
DRM_ERROR( "no scatter/gather memory!\n" );
- goto done;
+ return 0;
}
- address = (long)contigmalloc((1 << ATI_PCIGART_TABLE_ORDER) * PAGE_SIZE,
- M_DRM, M_NOWAIT, 0ul, 0xfffffffful, PAGE_SIZE, 0);
- if ( !address ) {
- DRM_ERROR( "cannot allocate PCI GART page!\n" );
- goto done;
+ if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) {
+ /* GART table in system memory */
+ dev->sg->dmah = drm_pci_alloc(dev, ATI_PCIGART_TABLE_SIZE, 0,
+ 0xfffffffful);
+ if (dev->sg->dmah == NULL) {
+ DRM_ERROR("cannot allocate PCI GART table!\n");
+ return 0;
+ }
+
+ gart_info->addr = (void *)dev->sg->dmah->vaddr;
+ gart_info->bus_addr = dev->sg->dmah->busaddr;
+ pci_gart = (u32 *)dev->sg->dmah->vaddr;
+ } else {
+ /* GART table in framebuffer memory */
+ pci_gart = gart_info->addr;
}
+
+ pages = DRM_MIN(dev->sg->pages, ATI_MAX_PCIGART_PAGES);
- /* XXX: we need to busdma this */
- bus_address = vtophys( address );
-
- pci_gart = (u32 *)address;
+ bzero(pci_gart, ATI_PCIGART_TABLE_SIZE);
- pages = ( entry->pages <= ATI_MAX_PCIGART_PAGES )
- ? entry->pages : ATI_MAX_PCIGART_PAGES;
-
- bzero( pci_gart, ATI_MAX_PCIGART_PAGES * sizeof(u32) );
+ KASSERT(PAGE_SIZE >= ATI_PCIGART_PAGE_SIZE, ("page size too small"));
for ( i = 0 ; i < pages ; i++ ) {
- entry->busaddr[i] = vtophys( entry->handle + (i*PAGE_SIZE) );
- page_base = (u32) entry->busaddr[i];
+ page_base = (u32) dev->sg->busaddr[i];
for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) {
- if (is_pcie) {
- *pci_gart = (cpu_to_le32(page_base)>>8) | 0xc;
- DRM_DEBUG("PCIE: %d %08X %08X to %p\n", i,
- page_base, (cpu_to_le32(page_base)>>8)|0xc,
- pci_gart);
- } else
+ if (gart_info->is_pcie)
+ *pci_gart = (cpu_to_le32(page_base) >> 8) | 0xc;
+ else
*pci_gart = cpu_to_le32(page_base);
pci_gart++;
page_base += ATI_PCIGART_PAGE_SIZE;
@@ -95,29 +87,17 @@ int drm_ati_pcigart_init(drm_device_t *dev, unsigned long *addr,
DRM_MEMORYBARRIER();
- ret = 1;
-
-done:
- *addr = address;
- *bus_addr = bus_address;
- return ret;
+ return 1;
}
-int drm_ati_pcigart_cleanup(drm_device_t *dev, unsigned long addr,
- dma_addr_t bus_addr)
+int drm_ati_pcigart_cleanup(drm_device_t *dev, drm_ati_pcigart_info *gart_info)
{
- drm_sg_mem_t *entry = dev->sg;
-
- /* we need to support large memory configurations */
- if ( !entry ) {
+ if (dev->sg == NULL) {
DRM_ERROR( "no scatter/gather memory!\n" );
return 0;
}
-#if __FreeBSD_version > 500000
- /* Not available on 4.x */
- contigfree((void *)addr, (1 << ATI_PCIGART_TABLE_ORDER) * PAGE_SIZE,
- M_DRM);
-#endif
+ drm_pci_free(dev, dev->sg->dmah);
+
return 1;
}
OpenPOWER on IntegriCloud