summaryrefslogtreecommitdiff
path: root/bsd-core
diff options
context:
space:
mode:
Diffstat (limited to 'bsd-core')
-rw-r--r--bsd-core/ati_pcigart.c46
-rw-r--r--bsd-core/drmP.h20
2 files changed, 38 insertions, 28 deletions
diff --git a/bsd-core/ati_pcigart.c b/bsd-core/ati_pcigart.c
index 71b08d68..d48d0a80 100644
--- a/bsd-core/ati_pcigart.c
+++ b/bsd-core/ati_pcigart.c
@@ -35,32 +35,34 @@
#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)
{
unsigned long pages;
- u32 *pci_gart = 0, page_base;
+ u32 *pci_gart = NULL, page_base;
int i, j;
- *addr = 0;
- *bus_addr = 0;
-
if (dev->sg == NULL) {
DRM_ERROR( "no scatter/gather memory!\n" );
return 0;
}
- 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;
+ 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;
}
-
- *addr = (long)dev->sg->dmah->vaddr;
- *bus_addr = dev->sg->dmah->busaddr;
- pci_gart = (u32 *)dev->sg->dmah->vaddr;
-
+
pages = DRM_MIN(dev->sg->pages, ATI_MAX_PCIGART_PAGES);
bzero(pci_gart, ATI_PCIGART_TABLE_SIZE);
@@ -71,12 +73,9 @@ int drm_ati_pcigart_init(drm_device_t *dev, unsigned long *addr,
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;
@@ -88,8 +87,7 @@ int drm_ati_pcigart_init(drm_device_t *dev, unsigned long *addr,
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)
{
if (dev->sg == NULL) {
DRM_ERROR( "no scatter/gather memory!\n" );
diff --git a/bsd-core/drmP.h b/bsd-core/drmP.h
index b98049c3..dda12560 100644
--- a/bsd-core/drmP.h
+++ b/bsd-core/drmP.h
@@ -622,6 +622,18 @@ typedef struct drm_vbl_sig {
int pid;
} drm_vbl_sig_t;
+/* location of GART table */
+#define DRM_ATI_GART_MAIN 1
+#define DRM_ATI_GART_FB 2
+
+typedef struct ati_pcigart_info {
+ int gart_table_location;
+ int is_pcie;
+ void *addr;
+ dma_addr_t bus_addr;
+ drm_local_map_t mapping;
+} drm_ati_pcigart_info;
+
struct drm_driver_info {
int (*load)(struct drm_device *, unsigned long flags);
int (*firstopen)(struct drm_device *);
@@ -907,10 +919,10 @@ extern int drm_sysctl_cleanup(drm_device_t *dev);
#endif /* __FreeBSD__ */
/* ATI PCIGART support (ati_pcigart.c) */
-int drm_ati_pcigart_init(drm_device_t *dev, unsigned long *addr,
- dma_addr_t *bus_addr, int is_pcie);
-int drm_ati_pcigart_cleanup(drm_device_t *dev, unsigned long addr,
- dma_addr_t bus_addr);
+int drm_ati_pcigart_init(drm_device_t *dev,
+ drm_ati_pcigart_info *gart_info);
+int drm_ati_pcigart_cleanup(drm_device_t *dev,
+ drm_ati_pcigart_info *gart_info);
/* Locking IOCTL support (drm_drv.c) */
int drm_lock(DRM_IOCTL_ARGS);