/*
* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
*/
/*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* Copyright (c) 2009, Intel Corporation.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Rickard E. (Rik) Faith <faith@valinux.com>
* Gareth Hughes <gareth@valinux.com>
*
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _DRMP_H
#define _DRMP_H
#include <sys/sysmacros.h>
#include <sys/sysmacros.h>
#include "drm_atomic.h"
#include "drm.h"
#include "queue.h"
#include "drm_linux_list.h"
#ifndef __inline__
#define __inline__ inline
#endif
#if !defined(__FUNCTION__)
#if defined(C99)
#else
#endif
#endif
/* DRM space units */
#define DRM_UNOPENED 0
#define DRM_MEM_DMA 0
/* Internal types and structures */
#define DRM_ARRAY_SIZE(x) (sizeof (x) / sizeof (x[0]))
#define DRM_MIN(a, b) ((a) < (b) ? (a) : (b))
#define DRM_MAX(a, b) ((a) > (b) ? (a) : (b))
#define DRM_DEV_UID 0
#define DRM_DEV_GID 0
#define DRM_SPINLOCK_ASSERT(l)
#define DRM_MEMORYBARRIER()
#define DRM_IOCTL_ARGS \
return (EFAULT); \
}
return (EFAULT); \
}
typedef struct drm_wait_queue {
{ \
}
#define DRM_FINI_WAITQUEUE(q) \
{ \
mutex_destroy(&(q)->lock); \
cv_destroy(&(q)->cv); \
}
#define DRM_WAKEUP(q) \
{ \
mutex_enter(&(q)->lock); \
cv_broadcast(&(q)->cv); \
mutex_exit(&(q)->lock); \
}
mutex_enter(&(q)->lock); \
while (!(condition)) { \
TR_CLOCK_TICK); \
if (ret == -1) { \
break; \
} else if (ret == 0) { \
break; \
} else { \
ret = 0; \
} \
} \
mutex_exit(&(q)->lock);
mutex_enter(&(q)->lock); \
if (!(condition)) { \
if (ret == -1) { \
/* gfx maybe hang */ \
if (!(condition)) \
ret = -2; \
} else { \
ret = 0; \
} \
} \
mutex_exit(&(q)->lock);
#define DRM_GETSAREA() \
{ \
drm_local_map_t *map; \
break; \
} \
} \
}
return (EINVAL); \
}
enum {
};
#ifndef PCIY_AGP
#endif
#ifndef PCIY_EXPRESS
#endif
/*
* wait for 400 milliseconds
*/
typedef unsigned long dma_addr_t;
#define DRM_UNSUPPORT 0
typedef struct drm_pci_id_list
{
int vendor;
int device;
long driver_private;
char *name;
typedef struct drm_ioctl_desc {
int flags;
typedef struct drm_magic_entry {
typedef struct drm_magic_head {
typedef struct drm_buf {
/* Uniq. identifier of holding process */
enum {
DRM_LIST_NONE = 0,
} drm_buf_t;
typedef struct drm_freelist {
typedef struct drm_buf_entry {
int buf_size;
int buf_count;
int seg_count;
int page_order;
unsigned long *seglist_bus;
/* BEGIN CSTYLED */
typedef struct drm_local_map {
/* Kernel-space: kernel-virtual address */
/* Private data */
/* END CSTYLED */
/*
* This structure defines the drm_mm memory object, which will be used by the
* DRM for its buffer objects.
*/
struct drm_gem_object {
/* Reference count of this object */
/* Handle count of this object. Each handle also holds a reference */
/* Related drm device */
int flink;
/*
* Size of the object, in bytes. Immutable over the object's
* lifetime.
*/
/*
* Global name for this object, starts at 1. 0 means unnamed.
* Access is covered by the object_name_lock in the related drm_device
*/
int name;
/*
* related to the object. When transitioning from one set of domains
* to another, the driver is called to ensure that caches are suitably
* flushed and invalidated
*/
/*
* While validating an exec operation, the
* They will be transferred to the above values
* at the point that any cache flushing occurs
*/
void *driver_private;
};
struct idr_list {
};
struct drm_file {
int authenticated;
int master;
int minor;
int refs;
unsigned long ioctl_count;
void *driver_priv;
/* Mapping of mm object handles to object pointers. */
/* Lock for synchronization of access to object_idr. */
};
typedef struct drm_lock_data {
/* Uniq. identifier of holding process */
/*
* This structure, in drm_device_t, is always initialized while the device
* is open. dev->dma_lock protects the incrementing of dev->buf_use, which
* when set marks that no further bufs may be allocated until device teardown
* watermarks of bufs are only touched by the X Server, and thus not
* concurrently accessed, so no locking is needed.
*/
typedef struct drm_device_dma {
int buf_count;
int seg_count;
int page_count;
unsigned long *pagelist;
unsigned long byte_count;
enum {
} flags;
typedef struct drm_agp_mem {
void *handle;
int pages;
typedef struct drm_agp_head {
const char *chipset;
unsigned long mode;
int enabled;
int acquired;
unsigned long base;
int mtrr;
int cant_use_aperture;
unsigned long page_mask;
typedef struct drm_dma_handle {
typedef struct drm_sg_mem {
unsigned long handle;
void *virtual;
int pages;
} drm_sg_mem_t;
/*
* Generic memory manager structs
*/
struct drm_mm_node {
int free;
unsigned long start;
unsigned long size;
void *private;
};
struct drm_mm {
};
typedef struct drm_vbl_sig {
unsigned int sequence;
int signo;
int pid;
/* used for clone device */
typedef struct drm_cminor {
int minor;
} drm_cminor_t;
/* location of GART table */
typedef struct ati_pcigart_info {
int gart_table_location;
int is_pcie;
void *addr;
/* DRM device structure */
struct drm_device;
struct drm_driver_info {
int, drm_lock_flags_t);
/* added for intel minimized vblank */
/*
* Driver-specific constructor for drm_gem_objects, to set up
* obj->driver_private.
*
* Returns 0 on success.
*/
int max_driver_ioctl;
int buf_priv_size;
int driver_major;
int driver_minor;
int driver_patchlevel;
unsigned use_gem;
};
/*
* hardware-specific code needs to initialize mutexes which
* can be used in interrupt context, so they need to know
* the interrupt priority. Interrupt cookie in drm_device
* structure is the intr_block field.
*/
struct drm_device {
void *drm_handle;
int drm_supported;
/* Locks */
/* Usage Counters */
/* Performance counters */
unsigned long counters;
/* Authentication */
/* Linked list of mappable regions. Protected by dev_lock */
int max_context;
/* DMA queues (contexts) */
/* Context support */
int pci_domain;
int pci_bus;
int pci_slot;
int pci_func;
/* Only used for Radeon */
/*
* At load time, disabling the vblank interrupt won't be allowed since
* old clients may not call the modeset ioctl and therefore misbehave.
* Once the modeset ioctl *has* been called though, we can safely
* disable them when unused.
*/
/* vbl wait channel array */
/* number of VBLANK interrupts */
/* (driver must alloc the right number of counters) */
/* signal list to send on VBLANK */
/* number of signals pending on all crtcs */
/* number of users of vblank interrupts per crtc */
/* protected by dev->vbl_lock, used for wraparound handling */
/* so we don't call enable more than */
/* Display driver is setting mode */
int *vblank_inmodeset;
/* Don't wait while crtc is likely disabled */
int *vblank_suspend;
/* size of vblank counter register */
int num_crtcs;
void *dev_private;
unsigned int agp_buffer_token;
/* name Drawable information */
unsigned int drw_bitfield_length;
unsigned int drw_info_length;
/* \name GEM information */
/* @{ */
/* @} */
/*
* Saving S3 context
*/
void *s3_private;
};
/* Memory management support (drm_memory.c) */
void drm_mem_init(void);
void drm_mem_uninit(void);
void drm_ioremapfree(drm_local_map_t *);
int drm_context_switch(drm_device_t *, int, int);
int drm_context_switch_complete(drm_device_t *, int);
int drm_ctxbitmap_init(drm_device_t *);
void drm_ctxbitmap_cleanup(drm_device_t *);
void drm_ctxbitmap_free(drm_device_t *, int);
int drm_ctxbitmap_next(drm_device_t *);
/* Locking IOCTL support (drm_lock.c) */
int drm_lock_take(drm_lock_data_t *, unsigned int);
int drm_lock_transfer(drm_device_t *,
drm_lock_data_t *, unsigned int);
int drm_lock_free(drm_device_t *,
volatile unsigned int *, unsigned int);
/* Buffer management support (drm_bufs.c) */
unsigned long drm_get_resource_start(drm_device_t *, unsigned int);
unsigned long drm_get_resource_len(drm_device_t *, unsigned int);
int drm_initmap(drm_device_t *, unsigned long, unsigned long,
unsigned int, int, int);
int drm_addmap(drm_device_t *, unsigned long, unsigned long,
int drm_order(unsigned long);
/* DMA support (drm_dma.c) */
int drm_dma_setup(drm_device_t *);
void drm_dma_takedown(drm_device_t *);
/* IRQ support (drm_irq.c) */
int drm_irq_install(drm_device_t *);
int drm_irq_uninstall(drm_device_t *);
void drm_driver_irq_preinstall(drm_device_t *);
void drm_driver_irq_postinstall(drm_device_t *);
void drm_driver_irq_uninstall(drm_device_t *);
int drm_vblank_wait(drm_device_t *, unsigned int *);
void drm_vbl_send_signals(drm_device_t *);
/* AGP/GART support (drm_agpsupport.c) */
int drm_device_is_agp(drm_device_t *);
int drm_device_is_pcie(drm_device_t *);
void drm_agp_fini(drm_device_t *);
int drm_agp_do_release(drm_device_t *);
int drm_agp_unbind_memory(unsigned long, drm_device_t *);
unsigned long num_pages,
unsigned long num_pages,
/* kstat support (drm_kstats.c) */
int drm_init_kstats(drm_device_t *);
void drm_fini_kstats(drm_device_t *);
/* Scatter Gather Support (drm_scatter.c) */
/* ATI PCIGART support (ati_pcigart.c) */
/* Locking IOCTL support (drm_drv.c) */
int drm_lock(DRM_IOCTL_ARGS);
int drm_unlock(DRM_IOCTL_ARGS);
int drm_version(DRM_IOCTL_ARGS);
int drm_setversion(DRM_IOCTL_ARGS);
/* Cache management (drm_cache.c) */
/* Misc. IOCTL support (drm_ioctl.c) */
int drm_getunique(DRM_IOCTL_ARGS);
int drm_setunique(DRM_IOCTL_ARGS);
int drm_getmap(DRM_IOCTL_ARGS);
int drm_getclient(DRM_IOCTL_ARGS);
int drm_getstats(DRM_IOCTL_ARGS);
int drm_noop(DRM_IOCTL_ARGS);
/* Context IOCTL support (drm_context.c) */
int drm_resctx(DRM_IOCTL_ARGS);
int drm_addctx(DRM_IOCTL_ARGS);
int drm_modctx(DRM_IOCTL_ARGS);
int drm_getctx(DRM_IOCTL_ARGS);
int drm_switchctx(DRM_IOCTL_ARGS);
int drm_newctx(DRM_IOCTL_ARGS);
int drm_rmctx(DRM_IOCTL_ARGS);
/* Drawable IOCTL support (drm_drawable.c) */
int drm_adddraw(DRM_IOCTL_ARGS);
int drm_rmdraw(DRM_IOCTL_ARGS);
/* Authentication IOCTL support (drm_auth.c) */
int drm_getmagic(DRM_IOCTL_ARGS);
int drm_authmagic(DRM_IOCTL_ARGS);
/* Buffer management support (drm_bufs.c) */
int drm_infobufs(DRM_IOCTL_ARGS);
int drm_markbufs(DRM_IOCTL_ARGS);
int drm_freebufs(DRM_IOCTL_ARGS);
int drm_mapbufs(DRM_IOCTL_ARGS);
/* DMA support (drm_dma.c) */
int drm_dma(DRM_IOCTL_ARGS);
/* IRQ support (drm_irq.c) */
int drm_control(DRM_IOCTL_ARGS);
/* AGP/GART support (drm_agpsupport.c) */
int drm_agp_enable(DRM_IOCTL_ARGS);
int drm_agp_info(DRM_IOCTL_ARGS);
int drm_agp_alloc(DRM_IOCTL_ARGS);
int drm_agp_free(DRM_IOCTL_ARGS);
int drm_agp_unbind(DRM_IOCTL_ARGS);
int drm_agp_bind(DRM_IOCTL_ARGS);
/* Scatter Gather Support (drm_scatter.c) */
int drm_sg_alloc(DRM_IOCTL_ARGS);
int drm_sg_free(DRM_IOCTL_ARGS);
/* drm_mm.c */
unsigned long size,
unsigned alignment, int best_match);
extern int drm_debug_flag;
/* We add function to support DRM_DEBUG,DRM_ERROR,DRM_INFO */
#ifdef DEBUG
#else
#define DRM_DEBUG(...)
#define DRM_INFO(...)
#endif
extern int drm_dev_to_instance(dev_t);
extern int drm_dev_to_minor(dev_t);
extern int drm_supp_unregister(void *);
extern int drm_attach(drm_device_t *);
extern int drm_detach(drm_device_t *);
extern int drm_pci_init(drm_device_t *);
extern void drm_pci_end(drm_device_t *);
extern int pci_get_info(drm_device_t *, int *, int *, int *);
extern int pci_get_irq(drm_device_t *);
extern int pci_get_vendor(drm_device_t *);
extern int pci_get_device(drm_device_t *);
/* File Operations helpers (drm_fops.c) */
cred_t *);
/* Graphics Execution Manager library functions (drm_gem.c) */
struct drm_gem_object *obj,
int *handlep);
int handle);
#endif /* _DRMP_H */