81,12 → 81,12 |
#include <linux/workqueue.h> |
|
|
#include "drm.h" |
#include <drm/drm.h> |
#include <drm/drm_vma_manager.h> |
|
#include <linux/idr.h> |
|
#define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE))) |
#define __OS_HAS_MTRR (defined(CONFIG_MTRR)) |
|
struct module; |
|
95,6 → 95,14 |
|
struct device_node; |
struct videomode; |
|
struct inode; |
struct poll_table_struct; |
struct drm_lock_data; |
|
struct sg_table; |
struct dma_buf; |
|
//#include <drm/drm_os_linux.h> |
#include <drm/drm_hashtab.h> |
#include <drm/drm_mm.h> |
159,19 → 167,15 |
/* driver capabilities and requirements mask */ |
#define DRIVER_USE_AGP 0x1 |
#define DRIVER_REQUIRE_AGP 0x2 |
#define DRIVER_USE_MTRR 0x4 |
#define DRIVER_PCI_DMA 0x8 |
#define DRIVER_SG 0x10 |
#define DRIVER_HAVE_DMA 0x20 |
#define DRIVER_HAVE_IRQ 0x40 |
#define DRIVER_IRQ_SHARED 0x80 |
#define DRIVER_IRQ_VBL 0x100 |
#define DRIVER_DMA_QUEUE 0x200 |
#define DRIVER_FB_DMA 0x400 |
#define DRIVER_IRQ_VBL2 0x800 |
#define DRIVER_GEM 0x1000 |
#define DRIVER_MODESET 0x2000 |
#define DRIVER_PRIME 0x4000 |
#define DRIVER_RENDER 0x8000 |
|
#define DRIVER_BUS_PCI 0x1 |
#define DRIVER_BUS_PLATFORM 0x2 |
274,9 → 278,6 |
|
#define DRM_ARRAY_SIZE(x) ARRAY_SIZE(x) |
|
#define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1)) |
#define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x)) |
|
#define DRM_IF_VERSION(maj, min) (maj << 16 | min) |
|
/** |
319,6 → 320,7 |
#define DRM_ROOT_ONLY 0x4 |
#define DRM_CONTROL_ALLOW 0x8 |
#define DRM_UNLOCKED 0x10 |
#define DRM_RENDER_ALLOW 0x20 |
|
struct drm_ioctl_desc { |
unsigned int cmd; |
574,7 → 576,6 |
|
typedef struct drm_local_map drm_local_map_t; |
|
#if 0 |
/** |
* Mappings list |
*/ |
584,7 → 585,6 |
struct drm_local_map *map; /**< mapping */ |
uint64_t user_token; |
struct drm_master *master; |
struct drm_mm_node *file_offset_node; /**< fake offset */ |
}; |
|
/** |
619,12 → 619,9 |
* GEM specific mm private for tracking GEM objects |
*/ |
struct drm_gem_mm { |
struct drm_mm offset_manager; /**< Offset mgmt for buffer objects */ |
struct drm_open_hash offset_hash; /**< User token hash table for maps */ |
struct drm_vma_offset_manager vma_manager; |
}; |
|
#endif |
|
/** |
* This structure defines the drm_mm memory object, which will be used by the |
* DRM for its buffer objects. |
633,8 → 630,16 |
/** Reference count of this object */ |
struct kref refcount; |
|
/** Handle count of this object. Each handle also holds a reference */ |
atomic_t handle_count; /* number of handles on this object */ |
/** |
* handle_count - gem file_priv handle count of this object |
* |
* Each handle also holds a reference. Note that when the handle_count |
* drops to 0 any global names (e.g. the id in the flink namespace) will |
* be cleared. |
* |
* Protected by dev->object_name_lock. |
* */ |
unsigned handle_count; |
|
/** Related drm device */ |
struct drm_device *dev; |
643,6 → 648,7 |
struct file *filp; |
|
/* Mapping info for this object */ |
struct drm_vma_offset_node vma_node; |
|
/** |
* Size of the object, in bytes. Immutable over the object's |
731,6 → 737,7 |
int (*irq_by_busid)(struct drm_device *dev, struct drm_irq_busid *p); |
/* hooks that are for PCI */ |
int (*agp_init)(struct drm_device *dev); |
void (*agp_destroy)(struct drm_device *dev); |
|
}; |
|
879,8 → 886,6 |
void (*irq_preinstall) (struct drm_device *dev); |
int (*irq_postinstall) (struct drm_device *dev); |
void (*irq_uninstall) (struct drm_device *dev); |
void (*set_version) (struct drm_device *dev, |
struct drm_set_version *sv); |
|
/* Master routines */ |
int (*master_create)(struct drm_device *dev, struct drm_master *master); |
949,7 → 954,7 |
|
u32 driver_features; |
int dev_priv_size; |
struct drm_ioctl_desc *ioctls; |
const struct drm_ioctl_desc *ioctls; |
int num_ioctls; |
const struct file_operations *fops; |
union { |
968,6 → 973,7 |
#define DRM_IRQ_ARGS int irq, void *arg |
|
struct drm_driver { |
int (*load) (struct drm_device *, unsigned long flags); |
int (*open) (struct drm_device *, struct drm_file *); |
|
irqreturn_t (*irq_handler) (DRM_IRQ_ARGS); |
1126,12 → 1132,7 |
/*@{ */ |
int irq_enabled; /**< True if irq handler is enabled */ |
__volatile__ long context_flag; /**< Context swapping flag */ |
__volatile__ long interrupt_flag; /**< Interruption handler flag */ |
__volatile__ long dma_flag; /**< DMA dispatch flag */ |
// wait_queue_head_t context_wait; /**< Processes waiting on ctx switch */ |
int last_checked; /**< Last context checked for DMA */ |
int last_context; /**< Last current context */ |
unsigned long last_switch; /**< jiffies at last context switch */ |
/*@} */ |
|
// struct work_struct work; |
1169,13 → 1170,7 |
spinlock_t event_lock; |
|
/*@} */ |
// cycles_t ctx_start; |
// cycles_t lck_start; |
|
// struct fasync_struct *buf_async;/**< Processes waiting for SIGIO */ |
// wait_queue_head_t buf_readers; /**< Processes waiting to read */ |
// wait_queue_head_t buf_writers; /**< Processes waiting to ctx switch */ |
|
// struct drm_agp_head *agp; /**< AGP data */ |
|
struct device *dev; /**< Device structure */ |
1199,7 → 1194,7 |
|
/** \name GEM information */ |
/*@{ */ |
spinlock_t object_name_lock; |
struct mutex object_name_lock; |
struct idr object_name_idr; |
/*@} */ |
int switch_power_state; |
1210,6 → 1205,7 |
#define DRM_SWITCH_POWER_ON 0 |
#define DRM_SWITCH_POWER_OFF 1 |
#define DRM_SWITCH_POWER_CHANGING 2 |
#define DRM_SWITCH_POWER_DYNAMIC_OFF 3 |
|
static __inline__ int drm_core_check_feature(struct drm_device *dev, |
int feature) |
1222,26 → 1218,6 |
return dev->pdev->irq; |
} |
|
#if 0 |
|
#if __OS_HAS_AGP |
static inline int drm_core_has_AGP(struct drm_device *dev) |
{ |
return drm_core_check_feature(dev, DRIVER_USE_AGP); |
} |
#else |
#define drm_core_has_AGP(dev) (0) |
#endif |
|
#if __OS_HAS_MTRR |
static inline int drm_core_has_MTRR(struct drm_device *dev) |
{ |
return drm_core_check_feature(dev, DRIVER_USE_MTRR); |
} |
#else |
#define drm_core_has_MTRR(dev) (0) |
#endif |
|
static inline void drm_device_set_unplugged(struct drm_device *dev) |
{ |
smp_wmb(); |
1275,7 → 1251,6 |
extern struct mutex drm_global_mutex; |
extern int drm_open(struct inode *inode, struct file *filp); |
extern int drm_stub_open(struct inode *inode, struct file *filp); |
extern int drm_fasync(int fd, struct file *filp, int on); |
extern ssize_t drm_read(struct file *filp, char __user *buffer, |
size_t count, loff_t *offset); |
extern int drm_release(struct inode *inode, struct file *filp); |
1289,14 → 1264,6 |
|
/* Memory management support (drm_memory.h) */ |
#include <drm/drm_memory.h> |
extern void drm_free_agp(DRM_AGP_MEM * handle, int pages); |
extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start); |
extern DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev, |
struct page **pages, |
unsigned long num_pages, |
uint32_t gtt_offset, |
uint32_t type); |
extern int drm_unbind_agp(DRM_AGP_MEM * handle); |
|
/* Misc. IOCTL support (drm_ioctl.h) */ |
extern int drm_irq_by_busid(struct drm_device *dev, void *data, |
1323,8 → 1290,6 |
struct drm_file *file_priv); |
extern int drm_addctx(struct drm_device *dev, void *data, |
struct drm_file *file_priv); |
extern int drm_modctx(struct drm_device *dev, void *data, |
struct drm_file *file_priv); |
extern int drm_getctx(struct drm_device *dev, void *data, |
struct drm_file *file_priv); |
extern int drm_switchctx(struct drm_device *dev, void *data, |
1396,8 → 1361,8 |
extern int drm_order(unsigned long size); |
|
/* DMA support (drm_dma.h) */ |
extern int drm_dma_setup(struct drm_device *dev); |
extern void drm_dma_takedown(struct drm_device *dev); |
extern int drm_legacy_dma_setup(struct drm_device *dev); |
extern void drm_legacy_dma_takedown(struct drm_device *dev); |
extern void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf); |
extern void drm_core_reclaim_buffers(struct drm_device *dev, |
struct drm_file *filp); |
1411,7 → 1376,6 |
extern int drm_vblank_init(struct drm_device *dev, int num_crtcs); |
extern int drm_wait_vblank(struct drm_device *dev, void *data, |
struct drm_file *filp); |
extern int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq); |
extern u32 drm_vblank_count(struct drm_device *dev, int crtc); |
extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc, |
struct timeval *vblanktime); |
1453,31 → 1417,6 |
struct drm_file *file_priv); |
|
/* AGP/GART support (drm_agpsupport.h) */ |
extern struct drm_agp_head *drm_agp_init(struct drm_device *dev); |
extern int drm_agp_acquire(struct drm_device *dev); |
extern int drm_agp_acquire_ioctl(struct drm_device *dev, void *data, |
struct drm_file *file_priv); |
extern int drm_agp_release(struct drm_device *dev); |
extern int drm_agp_release_ioctl(struct drm_device *dev, void *data, |
struct drm_file *file_priv); |
extern int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode); |
extern int drm_agp_enable_ioctl(struct drm_device *dev, void *data, |
struct drm_file *file_priv); |
extern int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info); |
extern int drm_agp_info_ioctl(struct drm_device *dev, void *data, |
struct drm_file *file_priv); |
extern int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request); |
extern int drm_agp_alloc_ioctl(struct drm_device *dev, void *data, |
struct drm_file *file_priv); |
extern int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request); |
extern int drm_agp_free_ioctl(struct drm_device *dev, void *data, |
struct drm_file *file_priv); |
extern int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request); |
extern int drm_agp_unbind_ioctl(struct drm_device *dev, void *data, |
struct drm_file *file_priv); |
extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request); |
extern int drm_agp_bind_ioctl(struct drm_device *dev, void *data, |
struct drm_file *file_priv); |
|
/* Stub support (drm_stub.h) */ |
extern int drm_setmaster_ioctl(struct drm_device *dev, void *data, |
1491,9 → 1430,8 |
extern void drm_put_dev(struct drm_device *dev); |
extern int drm_put_minor(struct drm_minor **minor); |
extern void drm_unplug_dev(struct drm_device *dev); |
#endif |
|
extern unsigned int drm_debug; |
extern unsigned int drm_rnodes; |
|
#if 0 |
extern unsigned int drm_vblank_offdelay; |
1501,7 → 1439,6 |
extern unsigned int drm_timestamp_monotonic; |
|
extern struct class *drm_class; |
extern struct proc_dir_entry *drm_proc_root; |
extern struct dentry *drm_debugfs_root; |
|
extern struct idr drm_minors_idr; |
1508,10 → 1445,6 |
|
extern struct drm_local_map *drm_getsarea(struct drm_device *dev); |
|
/* Proc support (drm_proc.h) */ |
extern int drm_proc_init(struct drm_minor *minor, struct proc_dir_entry *root); |
extern int drm_proc_cleanup(struct drm_minor *minor, struct proc_dir_entry *root); |
|
/* Debugfs support */ |
#if defined(CONFIG_DEBUG_FS) |
extern int drm_debugfs_init(struct drm_minor *minor, int minor_id, |
1536,10 → 1469,9 |
#endif |
|
/* Scatter Gather Support (drm_scatter.h) */ |
extern void drm_sg_cleanup(struct drm_sg_mem * entry); |
extern int drm_sg_alloc_ioctl(struct drm_device *dev, void *data, |
extern void drm_legacy_sg_cleanup(struct drm_device *dev); |
extern int drm_sg_alloc(struct drm_device *dev, void *data, |
struct drm_file *file_priv); |
extern int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request); |
extern int drm_sg_free(struct drm_device *dev, void *data, |
struct drm_file *file_priv); |
|
1563,14 → 1495,8 |
extern int drm_sysfs_device_add(struct drm_minor *minor); |
extern void drm_sysfs_hotplug_event(struct drm_device *dev); |
extern void drm_sysfs_device_remove(struct drm_minor *minor); |
extern char *drm_get_connector_status_name(enum drm_connector_status status); |
|
static inline int drm_sysfs_connector_add(struct drm_connector *connector) |
{ return 0; }; |
|
static inline void drm_sysfs_connector_remove(struct drm_connector *connector) |
{ }; |
|
extern int drm_sysfs_connector_add(struct drm_connector *connector); |
extern void drm_sysfs_connector_remove(struct drm_connector *connector); |
#endif |
|
/* Graphics Execution Manager library functions (drm_gem.c) */ |
1582,13 → 1508,15 |
size_t size); |
int drm_gem_object_init(struct drm_device *dev, |
struct drm_gem_object *obj, size_t size); |
int drm_gem_private_object_init(struct drm_device *dev, |
void drm_gem_private_object_init(struct drm_device *dev, |
struct drm_gem_object *obj, size_t size); |
void drm_gem_object_handle_free(struct drm_gem_object *obj); |
void drm_gem_vm_open(struct vm_area_struct *vma); |
void drm_gem_vm_close(struct vm_area_struct *vma); |
int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size, |
struct vm_area_struct *vma); |
int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); |
|
#include <drm/drm_global.h> |
|
static inline void |
drm_gem_object_reference(struct drm_gem_object *obj) |
1606,67 → 1534,33 |
static inline void |
drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) |
{ |
if (obj != NULL) { |
if (obj && !atomic_add_unless(&obj->refcount.refcount, -1, 1)) { |
struct drm_device *dev = obj->dev; |
|
mutex_lock(&dev->struct_mutex); |
kref_put(&obj->refcount, drm_gem_object_free); |
if (likely(atomic_dec_and_test(&obj->refcount.refcount))) |
drm_gem_object_free(&obj->refcount); |
mutex_unlock(&dev->struct_mutex); |
} |
} |
|
int drm_gem_handle_create_tail(struct drm_file *file_priv, |
struct drm_gem_object *obj, |
u32 *handlep); |
int drm_gem_handle_create(struct drm_file *file_priv, |
struct drm_gem_object *obj, |
u32 *handlep); |
int drm_gem_handle_delete(struct drm_file *filp, u32 handle); |
|
static inline void |
drm_gem_object_handle_reference(struct drm_gem_object *obj) |
{ |
drm_gem_object_reference(obj); |
atomic_inc(&obj->handle_count); |
} |
|
static inline void |
drm_gem_object_handle_unreference(struct drm_gem_object *obj) |
{ |
if (obj == NULL) |
return; |
|
if (atomic_read(&obj->handle_count) == 0) |
return; |
/* |
* Must bump handle count first as this may be the last |
* ref, in which case the object would disappear before we |
* checked for a name |
*/ |
if (atomic_dec_and_test(&obj->handle_count)) |
drm_gem_object_handle_free(obj); |
drm_gem_object_unreference(obj); |
} |
|
static inline void |
drm_gem_object_handle_unreference_unlocked(struct drm_gem_object *obj) |
{ |
if (obj == NULL) |
return; |
|
if (atomic_read(&obj->handle_count) == 0) |
return; |
|
/* |
* Must bump handle count first as this may be the last |
* ref, in which case the object would disappear before we |
* checked for a name |
*/ |
|
if (atomic_dec_and_test(&obj->handle_count)) |
drm_gem_object_handle_free(obj); |
drm_gem_object_unreference_unlocked(obj); |
} |
|
void drm_gem_free_mmap_offset(struct drm_gem_object *obj); |
int drm_gem_create_mmap_offset(struct drm_gem_object *obj); |
int drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size); |
|
struct page **drm_gem_get_pages(struct drm_gem_object *obj, gfp_t gfpmask); |
void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages, |
bool dirty, bool accessed); |
|
struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev, |
struct drm_file *filp, |
u32 handle); |
1683,8 → 1577,6 |
extern void drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev); |
extern void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev); |
|
#if 0 |
|
static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev, |
unsigned int token) |
{ |
1699,30 → 1591,20 |
{ |
} |
|
//#include <drm/drm_mem_util.h> |
|
extern int drm_fill_in_dev(struct drm_device *dev, |
const struct pci_device_id *ent, |
struct drm_driver *driver); |
int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type); |
/*@}*/ |
|
static __inline__ void *drm_calloc_large(size_t nmemb, size_t size) |
{ |
if (size * nmemb <= PAGE_SIZE) |
return kcalloc(nmemb, size, GFP_KERNEL); |
|
if (size != 0 && nmemb > ULONG_MAX / size) |
return NULL; |
|
return __vmalloc(size * nmemb, |
GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL); |
} |
extern int drm_get_pci_dev(struct pci_dev *pdev, |
const struct pci_device_id *ent, |
struct drm_driver *driver); |
|
static __inline void drm_free_large(void *ptr) |
{ |
if (!is_vmalloc_addr(ptr)) |
return kfree(ptr); |
|
vfree(ptr); |
} |
|
#endif |
|
#define DRM_PCIE_SPEED_25 1 |
#define DRM_PCIE_SPEED_50 2 |
#define DRM_PCIE_SPEED_80 4 |
1744,5 → 1626,7 |
#define drm_sysfs_connector_remove(connector) |
|
#define LFB_SIZE 0xC00000 |
extern struct drm_device *main_device; |
extern struct drm_file *drm_file_handlers[256]; |
|
#endif |