return 0;
}
-#if defined(I915_HAVE_BUFFER)
-#define DRI2_SAREA_BLOCK_TYPE(b) ((b) >> 16)
-#define DRI2_SAREA_BLOCK_SIZE(b) ((b) & 0xffff)
-#define DRI2_SAREA_BLOCK_NEXT(p) \
- ((void *) ((unsigned char *) (p) + \
- DRI2_SAREA_BLOCK_SIZE(*(unsigned int *) p)))
-
-#define DRI2_SAREA_BLOCK_END 0x0000
-#define DRI2_SAREA_BLOCK_LOCK 0x0001
-#define DRI2_SAREA_BLOCK_EVENT_BUFFER 0x0002
-
-static int
-setup_dri2_sarea(struct drm_device * dev,
- struct drm_file *file_priv,
- drm_i915_init_t * init)
-{
- drm_i915_private_t *dev_priv = dev->dev_private;
- int ret;
- unsigned int *p, *end, *next;
-
- mutex_lock(&dev->struct_mutex);
- dev_priv->sarea_bo =
- drm_lookup_buffer_object(file_priv,
- init->sarea_handle, 1);
- mutex_unlock(&dev->struct_mutex);
-
- if (!dev_priv->sarea_bo) {
- DRM_ERROR("did not find sarea bo\n");
- return -EINVAL;
- }
-
- ret = drm_bo_kmap(dev_priv->sarea_bo, 0,
- dev_priv->sarea_bo->num_pages,
- &dev_priv->sarea_kmap);
- if (ret) {
- DRM_ERROR("could not map sarea bo\n");
- return ret;
- }
-
- p = dev_priv->sarea_kmap.virtual;
- end = (void *) p + (dev_priv->sarea_bo->num_pages << PAGE_SHIFT);
- while (p < end && DRI2_SAREA_BLOCK_TYPE(*p) != DRI2_SAREA_BLOCK_END) {
- switch (DRI2_SAREA_BLOCK_TYPE(*p)) {
- case DRI2_SAREA_BLOCK_LOCK:
- dev->lock.hw_lock = (void *) (p + 1);
- dev->sigdata.lock = dev->lock.hw_lock;
- break;
- }
- next = DRI2_SAREA_BLOCK_NEXT(p);
- if (next <= p || end < next) {
- DRM_ERROR("malformed dri2 sarea: next is %p should be within %p-%p\n",
- next, p, end);
- return -EINVAL;
- }
- p = next;
- }
-
- return 0;
-}
-#endif
-
static int i915_initialize(struct drm_device * dev,
struct drm_file *file_priv,
drm_i915_init_t * init)
{
drm_i915_private_t *dev_priv = dev->dev_private;
-#if defined(I915_HAVE_BUFFER)
- int ret;
-#endif
+
dev_priv->sarea = drm_getsarea(dev);
if (!dev_priv->sarea) {
DRM_ERROR("can not find sarea!\n");
return -EINVAL;
}
-#ifdef I915_HAVE_BUFFER
- dev_priv->max_validate_buffers = I915_MAX_VALIDATE_BUFFERS;
-#endif
-
if (init->sarea_priv_offset)
dev_priv->sarea_priv = (drm_i915_sarea_t *)
((u8 *) dev_priv->sarea->handle +
I915_WRITE(0x02080, dev_priv->dma_status_page);
}
DRM_DEBUG("Enabled hardware status page\n");
-#ifdef I915_HAVE_BUFFER
- mutex_init(&dev_priv->cmdbuf_mutex);
-#endif
-#if defined(I915_HAVE_BUFFER)
- if (init->func == I915_INIT_DMA2) {
- ret = setup_dri2_sarea(dev, file_priv, init);
- if (ret) {
- i915_dma_cleanup(dev);
- DRM_ERROR("could not set up dri2 sarea\n");
- return ret;
- }
- }
-#endif
return 0;
}
static int i915_dispatch_cmdbuffer(struct drm_device * dev,
drm_i915_cmdbuffer_t * cmd)
{
-#ifdef I915_HAVE_FENCE
- drm_i915_private_t *dev_priv = dev->dev_private;
-#endif
int nbox = cmd->num_cliprects;
int i = 0, count, ret;
}
i915_emit_breadcrumb(dev);
-#ifdef I915_HAVE_FENCE
- if (unlikely((dev_priv->counter & 0xFF) == 0))
- drm_fence_flush_old(dev, 0, dev_priv->counter);
-#endif
return 0;
}
}
i915_emit_breadcrumb(dev);
-#ifdef I915_HAVE_FENCE
- if (unlikely((dev_priv->counter & 0xFF) == 0))
- drm_fence_flush_old(dev, 0, dev_priv->counter);
-#endif
return 0;
}
i915_do_dispatch_flip(dev, i, sync);
i915_emit_breadcrumb(dev);
-#ifdef I915_HAVE_FENCE
- if (unlikely(!sync && ((dev_priv->counter & 0xFF) == 0)))
- drm_fence_flush_old(dev, 0, dev_priv->counter);
-#endif
}
int i915_quiescent(struct drm_device *dev)
if (!dev_priv)
return;
-#ifdef I915_HAVE_BUFFER
- if (dev_priv->val_bufs) {
- vfree(dev_priv->val_bufs);
- dev_priv->val_bufs = NULL;
- }
-#endif
-
if (drm_getsarea(dev) && dev_priv->sarea_priv)
i915_do_cleanup_pageflip(dev);
if (dev_priv->agp_heap)
i915_mem_takedown(&(dev_priv->agp_heap));
-#if defined(I915_HAVE_BUFFER)
- if (dev_priv->sarea_kmap.virtual) {
- drm_bo_kunmap(&dev_priv->sarea_kmap);
- dev_priv->sarea_kmap.virtual = NULL;
- dev->lock.hw_lock = NULL;
- dev->sigdata.lock = NULL;
- }
-
- if (dev_priv->sarea_bo) {
- mutex_lock(&dev->struct_mutex);
- drm_bo_usage_deref_locked(&dev_priv->sarea_bo);
- mutex_unlock(&dev->struct_mutex);
- dev_priv->sarea_bo = NULL;
- }
-#endif
i915_dma_cleanup(dev);
}
DRM_IOCTL_DEF(DRM_I915_VBLANK_SWAP, i915_vblank_swap, DRM_AUTH),
DRM_IOCTL_DEF(DRM_I915_MMIO, i915_mmio, DRM_AUTH),
DRM_IOCTL_DEF(DRM_I915_HWS_ADDR, i915_set_status_page, DRM_AUTH),
-#ifdef I915_HAVE_BUFFER
- DRM_IOCTL_DEF(DRM_I915_EXECBUFFER, i915_execbuffer, DRM_AUTH),
-#endif
};
int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
int i915_driver_firstopen(struct drm_device *dev)
{
-#ifdef I915_HAVE_BUFFER
- drm_bo_driver_init(dev);
-#endif
return 0;
}
#define DRIVER_DESC "Intel Graphics"
#define DRIVER_DATE "20080312"
-#if defined(__linux__)
-#define I915_HAVE_FENCE
-#define I915_HAVE_BUFFER
-#endif
-
/* Interface history:
*
* 1.1: Original.
* 1.12: TTM relocation optimization
*/
#define DRIVER_MAJOR 1
-#if defined(I915_HAVE_FENCE) && defined(I915_HAVE_BUFFER)
-#define DRIVER_MINOR 13
-#else
#define DRIVER_MINOR 6
-#endif
#define DRIVER_PATCHLEVEL 0
enum pipe {
PIPE_B,
};
-#ifdef I915_HAVE_BUFFER
-#define I915_MAX_VALIDATE_BUFFERS 4096
-struct drm_i915_validate_buffer;
-#endif
-
typedef struct _drm_i915_ring_buffer {
int tail_mask;
unsigned long Start;
uint32_t irq_enable_reg;
int irq_enabled;
-#ifdef I915_HAVE_FENCE
- uint32_t flush_sequence;
- uint32_t flush_flags;
- uint32_t flush_pending;
- uint32_t saved_flush_status;
-#endif
-#ifdef I915_HAVE_BUFFER
- void *agp_iomap;
- unsigned int max_validate_buffers;
- struct mutex cmdbuf_mutex;
- struct drm_i915_validate_buffer *val_bufs;
-#endif
-
DRM_SPINTYPE swaps_lock;
drm_i915_vbl_swap_t vbl_swaps;
unsigned int swaps_pending;
-#if defined(I915_HAVE_BUFFER)
- /* DRI2 sarea */
- struct drm_buffer_object *sarea_bo;
- struct drm_bo_kmap_obj sarea_kmap;
-#endif
#ifdef __linux__
struct intel_opregion opregion;
extern int i915_save_state(struct drm_device *dev);
extern int i915_restore_state(struct drm_device *dev);
-#ifdef I915_HAVE_FENCE
-/* i915_fence.c */
-extern void i915_fence_handler(struct drm_device *dev);
-extern void i915_invalidate_reported_sequence(struct drm_device *dev);
-
-#endif
-
-#ifdef I915_HAVE_BUFFER
-/* i915_buffer.c */
-extern struct drm_ttm_backend *i915_create_ttm_backend_entry(struct drm_device *dev);
-extern int i915_fence_type(struct drm_buffer_object *bo, uint32_t *fclass,
- uint32_t *type);
-extern int i915_invalidate_caches(struct drm_device *dev, uint64_t buffer_flags);
-extern int i915_init_mem_type(struct drm_device *dev, uint32_t type,
- struct drm_mem_type_manager *man);
-extern uint64_t i915_evict_flags(struct drm_buffer_object *bo);
-extern int i915_move(struct drm_buffer_object *bo, int evict,
- int no_wait, struct drm_bo_mem_reg *new_mem);
-void i915_flush_ttm(struct drm_ttm *ttm);
-/* i915_execbuf.c */
-int i915_execbuffer(struct drm_device *dev, void *data,
- struct drm_file *file_priv);
-
-#endif
-
#ifdef __linux__
/* i915_opregion.c */
extern int intel_opregion_init(struct drm_device *dev);