summaryrefslogtreecommitdiff
path: root/shared-core
diff options
context:
space:
mode:
Diffstat (limited to 'shared-core')
-rw-r--r--shared-core/drm.h3
-rw-r--r--shared-core/i915_dma.c106
-rw-r--r--shared-core/i915_drv.h3
-rw-r--r--shared-core/i915_init.c132
4 files changed, 79 insertions, 165 deletions
diff --git a/shared-core/drm.h b/shared-core/drm.h
index b5b0aa52..6c626f66 100644
--- a/shared-core/drm.h
+++ b/shared-core/drm.h
@@ -289,7 +289,8 @@ typedef enum drm_map_flags {
_DRM_KERNEL = 0x08, /**< kernel requires access */
_DRM_WRITE_COMBINING = 0x10, /**< use write-combining if available */
_DRM_CONTAINS_LOCK = 0x20, /**< SHM page that contains lock */
- _DRM_REMOVABLE = 0x40 /**< Removable mapping */
+ _DRM_REMOVABLE = 0x40, /**< Removable mapping */
+ _DRM_DRIVER = 0x80 /**< Driver will take care of it */
} drm_map_flags_t;
typedef struct drm_ctx_priv_map {
diff --git a/shared-core/i915_dma.c b/shared-core/i915_dma.c
index cf729c6f..2b29dbe2 100644
--- a/shared-core/i915_dma.c
+++ b/shared-core/i915_dma.c
@@ -88,16 +88,6 @@ int i915_dma_cleanup(drm_device_t * dev)
if (dev->irq)
drm_irq_uninstall(dev);
- if (dev_priv->status_page_dmah) {
- drm_pci_free(dev, dev_priv->status_page_dmah);
- dev_priv->status_page_dmah = NULL;
- dev_priv->hw_status_page = NULL;
- dev_priv->dma_status_page = 0;
- /* Need to rewrite hardware status page */
- I915_WRITE(0x02080, 0x1ffff000);
- }
-
- dev_priv->sarea_priv = NULL;
return 0;
}
@@ -106,39 +96,6 @@ static int i915_initialize(drm_device_t * dev,
drm_i915_private_t * dev_priv,
drm_i915_init_t * init)
{
- DRM_GETSAREA();
- if (!dev_priv->sarea) {
- DRM_ERROR("can not find sarea!\n");
- dev->dev_private = (void *)dev_priv;
- i915_dma_cleanup(dev);
- return DRM_ERR(EINVAL);
- }
-
- dev_priv->sarea_priv = (drm_i915_sarea_t *)
- ((u8 *) dev_priv->sarea->handle + init->sarea_priv_offset);
-
- dev_priv->ring.Start = init->ring_start;
- dev_priv->ring.End = init->ring_end;
- dev_priv->ring.Size = init->ring_size;
- dev_priv->ring.tail_mask = dev_priv->ring.Size - 1;
-
- dev_priv->ring.map.offset = init->ring_start;
- dev_priv->ring.map.size = init->ring_size;
- dev_priv->ring.map.type = 0;
- dev_priv->ring.map.flags = 0;
- dev_priv->ring.map.mtrr = 0;
-
- drm_core_ioremap(&dev_priv->ring.map, dev);
-
- if (dev_priv->ring.map.handle == NULL) {
- dev->dev_private = (void *)dev_priv;
- i915_dma_cleanup(dev);
- DRM_ERROR("can not ioremap virtual address for"
- " ring buffer\n");
- return DRM_ERR(ENOMEM);
- }
-
- dev_priv->ring.virtual_start = dev_priv->ring.map.handle;
dev_priv->cpp = init->cpp;
dev_priv->sarea_priv->pf_current_page = 0;
@@ -152,27 +109,6 @@ static int i915_initialize(drm_device_t * dev,
*/
dev_priv->allow_batchbuffer = 1;
- /* Program Hardware Status Page */
- dev_priv->status_page_dmah = drm_pci_alloc(dev, PAGE_SIZE, PAGE_SIZE,
- 0xffffffff);
-
- if (!dev_priv->status_page_dmah) {
- dev->dev_private = (void *)dev_priv;
- i915_dma_cleanup(dev);
- DRM_ERROR("Can not allocate hardware status page\n");
- return DRM_ERR(ENOMEM);
- }
- dev_priv->hw_status_page = dev_priv->status_page_dmah->vaddr;
- dev_priv->dma_status_page = dev_priv->status_page_dmah->busaddr;
-
- memset(dev_priv->hw_status_page, 0, PAGE_SIZE);
- DRM_DEBUG("hw status page @ %p\n", dev_priv->hw_status_page);
-
- I915_WRITE(0x02080, dev_priv->dma_status_page);
- DRM_DEBUG("Enabled hardware status page\n");
-
-//drm_set_desired_modes(dev);
-
return 0;
}
@@ -182,29 +118,6 @@ static int i915_dma_resume(drm_device_t * dev)
DRM_DEBUG("%s\n", __FUNCTION__);
- if (!dev_priv->sarea) {
- DRM_ERROR("can not find sarea!\n");
- return DRM_ERR(EINVAL);
- }
-
- if (!dev_priv->mmio_map) {
- DRM_ERROR("can not find mmio map!\n");
- return DRM_ERR(EINVAL);
- }
-
- if (dev_priv->ring.map.handle == NULL) {
- DRM_ERROR("can not ioremap virtual address for"
- " ring buffer\n");
- return DRM_ERR(ENOMEM);
- }
-
- /* Program Hardware Status Page */
- if (!dev_priv->hw_status_page) {
- DRM_ERROR("Can not find hardware status page\n");
- return DRM_ERR(EINVAL);
- }
- DRM_DEBUG("hw status page @ %p\n", dev_priv->hw_status_page);
-
I915_WRITE(0x02080, dev_priv->dma_status_page);
DRM_DEBUG("Enabled hardware status page\n");
@@ -889,23 +802,4 @@ int i915_driver_device_is_agp(drm_device_t * dev)
return 1;
}
-int i915_driver_firstopen(struct drm_device *dev)
-{
- drm_i915_private_t *dev_priv = dev->dev_private;
- int ret;
- DRM_DEBUG("\n");
-
- if (!dev_priv->mmio_map) {
- ret = drm_addmap(dev, dev_priv->mmiobase, dev_priv->mmiolen,
- _DRM_REGISTERS, _DRM_READ_ONLY, &dev_priv->mmio_map);
- if (ret != 0) {
- DRM_ERROR("Cannot add mapping for MMIO registers\n");
- return ret;
- }
- }
-
- DRM_DEBUG("dev_priv->mmio map is %p\n", dev_priv->mmio_map);
-
- return 0;
-}
diff --git a/shared-core/i915_drv.h b/shared-core/i915_drv.h
index c22ab843..f4343014 100644
--- a/shared-core/i915_drv.h
+++ b/shared-core/i915_drv.h
@@ -89,6 +89,7 @@ typedef struct _drm_i915_vbl_swap {
} drm_i915_vbl_swap_t;
typedef struct drm_i915_private {
+ drm_buffer_object_t *ring_buffer;
drm_local_map_t *sarea;
drm_local_map_t *mmio_map;
@@ -922,4 +923,6 @@ extern int i915_wait_ring(drm_device_t * dev, int n, const char *caller);
#define IS_MOBILE(pI810) (IS_I830(pI810) || IS_I85X(pI810) || IS_I915GM(pI810) || IS_I945GM(pI810))
+#define PRIMARY_RINGBUFFER_SIZE (128*1024)
+
#endif
diff --git a/shared-core/i915_init.c b/shared-core/i915_init.c
index f0ab4574..be702624 100644
--- a/shared-core/i915_init.c
+++ b/shared-core/i915_init.c
@@ -151,7 +151,7 @@ int i915_driver_load(drm_device_t *dev, unsigned long flags)
}
ret = drm_addmap(dev, dev_priv->mmiobase, dev_priv->mmiolen,
- _DRM_REGISTERS, _DRM_READ_ONLY, &dev_priv->mmio_map);
+ _DRM_REGISTERS, _DRM_READ_ONLY|_DRM_DRIVER, &dev_priv->mmio_map);
if (ret != 0) {
DRM_ERROR("Cannot add mapping for MMIO registers\n");
return ret;
@@ -159,20 +159,13 @@ int i915_driver_load(drm_device_t *dev, unsigned long flags)
/* prebuild the SAREA */
sareapage = max(SAREA_MAX, PAGE_SIZE);
- ret = drm_addmap(dev, 0, sareapage, _DRM_SHM, _DRM_CONTAINS_LOCK,
- &map);
+ ret = drm_addmap(dev, 0, sareapage, _DRM_SHM, _DRM_CONTAINS_LOCK|_DRM_DRIVER,
+ &dev_priv->sarea);
if (ret) {
DRM_ERROR("SAREA setup failed\n");
return ret;
}
- DRM_GETSAREA();
- if (!dev_priv->sarea) {
- DRM_ERROR("can not find sarea!\n");
- dev->dev_private = (void *)dev_priv;
- i915_dma_cleanup(dev);
- return DRM_ERR(EINVAL);
- }
init_waitqueue_head(&dev->lock.lock_queue);
/* FIXME: assume sarea_priv is right after SAREA */
@@ -187,61 +180,34 @@ int i915_driver_load(drm_device_t *dev, unsigned long flags)
drm_bo_init_mm(dev, DRM_BO_MEM_PRIV0, dev_priv->baseaddr,
prealloc_size);
- /* Allocate scanout buffer and command ring */
- /* FIXME: types and other args correct? */
- hsize = 1280;
- vsize = 800;
- bytes_per_pixel = 4;
- size = hsize * vsize * bytes_per_pixel;
- drm_buffer_object_create(dev, size, drm_bo_type_kernel,
- DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE |
- DRM_BO_FLAG_MEM_PRIV0 | DRM_BO_FLAG_NO_MOVE,
- 0, PAGE_SIZE, 0,
- &entry);
-
- intel_modeset_init(dev);
-
- fb = drm_framebuffer_create(dev);
- if (!fb) {
- DRM_ERROR("failed to allocate fb\n");
+ size = PRIMARY_RINGBUFFER_SIZE;
+ ret = drm_buffer_object_create(dev, size, drm_bo_type_kernel,
+ DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE |
+ DRM_BO_FLAG_MEM_PRIV0 |
+ DRM_BO_FLAG_NO_MOVE,
+ DRM_BO_HINT_DONT_FENCE, 0x1, 0,
+ &dev_priv->ring_buffer);
+ if (ret < 0) {
+ DRM_ERROR("Unable to allocate ring buffer\n");
return -EINVAL;
}
- fb->width = hsize;
- fb->height = vsize;
- fb->pitch = hsize;
- fb->bits_per_pixel = bytes_per_pixel * 8;
- fb->depth = bytes_per_pixel * 8;
- fb->offset = entry->offset;
- fb->bo = entry;
-
- drm_initial_config(dev, fb, false);
- drmfb_probe(dev, fb);
-#if 0
- /* FIXME: command ring needs AGP space, do we own it at this point? */
- dev_priv->ring.Start = dev_priv->baseaddr;
- dev_priv->ring.End = 128*1024;
- dev_priv->ring.Size = 128*1024;
+ /* remap the buffer object properly */
+ dev_priv->ring.Start = dev_priv->ring_buffer->offset + dev_priv->baseaddr;
+ dev_priv->ring.End = dev_priv->ring.Start + size;
+ dev_priv->ring.Size = size;
dev_priv->ring.tail_mask = dev_priv->ring.Size - 1;
- dev_priv->ring.map.offset = dev_priv->ring.Start;
- dev_priv->ring.map.size = dev_priv->ring.Size;
- dev_priv->ring.map.type = 0;
- dev_priv->ring.map.flags = 0;
- dev_priv->ring.map.mtrr = 0;
+ dev_priv->ring.virtual_start = ioremap((dev_priv->ring.Start), (dev_priv->ring_buffer->mem.num_pages * PAGE_SIZE));
- drm_core_ioremap(&dev_priv->ring.map, dev);
- if (dev_priv->ring.map.handle == NULL) {
- dev->dev_private = (void *)dev_priv;
- i915_dma_cleanup(dev);
- DRM_ERROR("can not ioremap virtual address for"
- " ring buffer\n");
- return DRM_ERR(ENOMEM);
- }
+ DRM_DEBUG("ring start %08X, %08X, %08X\n", dev_priv->ring.Start, dev_priv->ring.virtual_start, dev_priv->ring.Size);
+ I915_WRITE(LP_RING + RING_HEAD, 0);
+ I915_WRITE(LP_RING + RING_TAIL, 0);
+ I915_WRITE(LP_RING + RING_START, dev_priv->ring.Start);
+ I915_WRITE(LP_RING + RING_LEN, ((dev_priv->ring.Size - 4096) & RING_NR_PAGES) |
+ (RING_NO_REPORT | RING_VALID));
- dev_priv->ring.virtual_start = dev_priv->ring.map.handle;
- dev_priv->cpp = 4;
dev_priv->sarea_priv->pf_current_page = 0;
/* We are using separate values as placeholders for mechanisms for
@@ -271,8 +237,40 @@ int i915_driver_load(drm_device_t *dev, unsigned long flags)
I915_WRITE(0x02080, dev_priv->dma_status_page);
DRM_DEBUG("Enabled hardware status page\n");
+
+#if 1
+ /* Allocate scanout buffer and command ring */
+ /* FIXME: types and other args correct? */
+ hsize = 1280;
+ vsize = 800;
+ bytes_per_pixel = 4;
+ size = hsize * vsize * bytes_per_pixel;
+ drm_buffer_object_create(dev, size, drm_bo_type_kernel,
+ DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE |
+ DRM_BO_FLAG_MEM_PRIV0 | DRM_BO_FLAG_NO_MOVE,
+ 0, PAGE_SIZE, 0,
+ &entry);
#endif
+ intel_modeset_init(dev);
+
+#if 1
+ fb = drm_framebuffer_create(dev);
+ if (!fb) {
+ DRM_ERROR("failed to allocate fb\n");
+ return -EINVAL;
+ }
+ fb->width = hsize;
+ fb->height = vsize;
+ fb->pitch = hsize;
+ fb->bits_per_pixel = bytes_per_pixel * 8;
+ fb->depth = bytes_per_pixel * 8;
+ fb->offset = entry->offset;
+ fb->bo = entry;
+
+ drm_initial_config(dev, fb, false);
+ drmfb_probe(dev, fb);
+#endif
return 0;
}
@@ -281,7 +279,26 @@ int i915_driver_unload(drm_device_t *dev)
drm_i915_private_t *dev_priv = dev->dev_private;
struct drm_framebuffer *fb;
+ if (dev_priv->status_page_dmah) {
+ drm_pci_free(dev, dev_priv->status_page_dmah);
+ dev_priv->status_page_dmah = NULL;
+ dev_priv->hw_status_page = NULL;
+ dev_priv->dma_status_page = 0;
+ /* Need to rewrite hardware status page */
+ I915_WRITE(0x02080, 0x1ffff000);
+ }
+
+ I915_WRITE(LP_RING + RING_LEN, 0);
+
+ iounmap(dev_priv->ring.virtual_start);
+
+ drm_bo_driver_finish(dev);
+
intel_modeset_cleanup(dev);
+ DRM_DEBUG("%p, %p\n", dev_priv->mmio_map, dev_priv->sarea);
+ drm_rmmap(dev, dev_priv->mmio_map);
+ drm_rmmap(dev, dev_priv->sarea);
+
drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER);
dev->dev_private = NULL;
@@ -296,7 +313,6 @@ void i915_driver_lastclose(drm_device_t * dev)
i915_dma_cleanup(dev);
- dev_priv->mmio_map = NULL;
}
void i915_driver_preclose(drm_device_t * dev, DRMFILE filp)