9,6 → 9,7 |
/* |
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. |
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. |
* Copyright (c) 2009-2010, Code Aurora Forum. |
* All rights reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
93,6 → 94,12 |
|
#define KHZ2PICOS(a) (1000000000UL/(a)) |
|
/* get_scanout_position() return flags */ |
#define DRM_SCANOUTPOS_VALID (1 << 0) |
#define DRM_SCANOUTPOS_INVBL (1 << 1) |
#define DRM_SCANOUTPOS_ACCURATE (1 << 2) |
|
|
extern void drm_ut_debug_printk(unsigned int request_level, |
const char *prefix, |
const char *function_name, |
203,6 → 210,7 |
#define DRIVER_IRQ_VBL2 0x800 |
#define DRIVER_GEM 0x1000 |
#define DRIVER_MODESET 0x2000 |
#define DRIVER_USE_PLATFORM_DEVICE 0x4000 |
|
/***********************************************************************/ |
/** \name Begin the DRM... */ |
362,6 → 370,7 |
unsigned int cmd; |
int flags; |
drm_ioctl_t *func; |
unsigned int cmd_drv; |
}; |
|
/** |
368,9 → 377,10 |
* Creates a driver or general drm_ioctl_desc array entry for the given |
* ioctl, for use by drm_ioctl(). |
*/ |
#define DRM_IOCTL_DEF(ioctl, _func, _flags) \ |
[DRM_IOCTL_NR(ioctl)] = {.cmd = ioctl, .func = _func, .flags = _flags} |
|
#define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \ |
[DRM_IOCTL_NR(DRM_##ioctl)] = {.cmd = DRM_##ioctl, .func = _func, .flags = _flags, .cmd_drv = DRM_IOCTL_##ioctl} |
|
struct drm_magic_entry { |
struct list_head head; |
struct drm_hash_item hash_item; |
462,6 → 472,8 |
struct drm_event *event; |
struct list_head link; |
struct drm_file *file_priv; |
pid_t pid; /* pid of requester, no guarantee it's valid by the time |
we deliver the event, for tracing only */ |
void (*destroy)(struct drm_pending_event *event); |
}; |
|
665,7 → 677,7 |
struct kref refcount; |
|
/** Handle count of this object. Each handle also holds a reference */ |
struct kref handlecount; |
atomic_t handle_count; /* number of handles on this object */ |
|
/** Related drm device */ |
struct drm_device *dev; |
736,6 → 748,34 |
void *driver_priv; /**< Private structure for driver to use */ |
}; |
|
/* Size of ringbuffer for vblank timestamps. Just double-buffer |
* in initial implementation. |
*/ |
#define DRM_VBLANKTIME_RBSIZE 2 |
|
/* Flags and return codes for get_vblank_timestamp() driver function. */ |
#define DRM_CALLED_FROM_VBLIRQ 1 |
#define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0) |
#define DRM_VBLANKTIME_INVBL (1 << 1) |
|
/* get_scanout_position() return flags */ |
#define DRM_SCANOUTPOS_VALID (1 << 0) |
#define DRM_SCANOUTPOS_INVBL (1 << 1) |
#define DRM_SCANOUTPOS_ACCURATE (1 << 2) |
|
struct drm_bus { |
int bus_type; |
int (*get_irq)(struct drm_device *dev); |
const char *(*get_name)(struct drm_device *dev); |
int (*set_busid)(struct drm_device *dev, struct drm_master *master); |
int (*set_unique)(struct drm_device *dev, struct drm_master *master, |
struct drm_unique *unique); |
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); |
|
}; |
|
/** |
* DRM driver structure. This structure represent the common code for |
* a family of cards. There will one drm_device for each card present |
752,13 → 792,8 |
int (*suspend) (struct drm_device *, pm_message_t state); |
int (*resume) (struct drm_device *); |
int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv); |
void (*dma_ready) (struct drm_device *); |
int (*dma_quiescent) (struct drm_device *); |
int (*context_ctor) (struct drm_device *dev, int context); |
int (*context_dtor) (struct drm_device *dev, int context); |
int (*kernel_context_switch) (struct drm_device *dev, int old, |
int new); |
void (*kernel_context_switch_unlock) (struct drm_device *dev); |
|
/** |
* get_vblank_counter - get raw hardware vblank counter |
818,6 → 853,68 |
*/ |
int (*device_is_agp) (struct drm_device *dev); |
|
/** |
* Called by vblank timestamping code. |
* |
* Return the current display scanout position from a crtc. |
* |
* \param dev DRM device. |
* \param crtc Id of the crtc to query. |
* \param *vpos Target location for current vertical scanout position. |
* \param *hpos Target location for current horizontal scanout position. |
* |
* Returns vpos as a positive number while in active scanout area. |
* Returns vpos as a negative number inside vblank, counting the number |
* of scanlines to go until end of vblank, e.g., -1 means "one scanline |
* until start of active scanout / end of vblank." |
* |
* \return Flags, or'ed together as follows: |
* |
* DRM_SCANOUTPOS_VALID = Query successful. |
* DRM_SCANOUTPOS_INVBL = Inside vblank. |
* DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of |
* this flag means that returned position may be offset by a constant |
* but unknown small number of scanlines wrt. real scanout position. |
* |
*/ |
int (*get_scanout_position) (struct drm_device *dev, int crtc, |
int *vpos, int *hpos); |
|
/** |
* Called by \c drm_get_last_vbltimestamp. Should return a precise |
* timestamp when the most recent VBLANK interval ended or will end. |
* |
* Specifically, the timestamp in @vblank_time should correspond as |
* closely as possible to the time when the first video scanline of |
* the video frame after the end of VBLANK will start scanning out, |
* the time immmediately after end of the VBLANK interval. If the |
* @crtc is currently inside VBLANK, this will be a time in the future. |
* If the @crtc is currently scanning out a frame, this will be the |
* past start time of the current scanout. This is meant to adhere |
* to the OpenML OML_sync_control extension specification. |
* |
* \param dev dev DRM device handle. |
* \param crtc crtc for which timestamp should be returned. |
* \param *max_error Maximum allowable timestamp error in nanoseconds. |
* Implementation should strive to provide timestamp |
* with an error of at most *max_error nanoseconds. |
* Returns true upper bound on error for timestamp. |
* \param *vblank_time Target location for returned vblank timestamp. |
* \param flags 0 = Defaults, no special treatment needed. |
* \param DRM_CALLED_FROM_VBLIRQ = Function is called from vblank |
* irq handler. Some drivers need to apply some workarounds |
* for gpu-specific vblank irq quirks if flag is set. |
* |
* \returns |
* Zero if timestamping isn't supported in current display mode or a |
* negative number on failure. A positive status code on success, |
* which describes how the vblank_time timestamp was computed. |
*/ |
int (*get_vblank_timestamp) (struct drm_device *dev, int crtc, |
int *max_error, |
struct timeval *vblank_time, |
unsigned flags); |
|
/* these have to be filled in */ |
|
irqreturn_t(*irq_handler) (DRM_IRQ_ARGS); |
830,8 → 927,6 |
struct drm_file *file_priv); |
void (*reclaim_buffers_idlelocked) (struct drm_device *dev, |
struct drm_file *file_priv); |
resource_size_t (*get_map_ofs) (struct drm_local_map * map); |
resource_size_t (*get_reg_ofs) (struct drm_device *dev); |
void (*set_version) (struct drm_device *dev, |
struct drm_set_version *sv); |
|
848,8 → 943,6 |
void (*master_drop)(struct drm_device *dev, struct drm_file *file_priv, |
bool from_release); |
|
int (*proc_init)(struct drm_minor *minor); |
void (*proc_cleanup)(struct drm_minor *minor); |
int (*debugfs_init)(struct drm_minor *minor); |
void (*debugfs_cleanup)(struct drm_minor *minor); |
|
952,12 → 1045,25 |
struct drm_mode_group mode_group; |
}; |
|
#endif |
|
/* mode specified on the command line */ |
struct drm_cmdline_mode { |
bool specified; |
bool refresh_specified; |
bool bpp_specified; |
int xres, yres; |
int bpp; |
int refresh; |
bool rb; |
bool interlace; |
bool cvt; |
bool margins; |
enum drm_connector_force force; |
}; |
|
|
#endif |
|
|
/** |
* DRM device structure. This structure represent a complete card that |
* may contain multiple heads. |
1003,7 → 1109,7 |
int ctx_count; /**< Number of context handles */ |
struct mutex ctxlist_mutex; /**< For ctxlist */ |
|
// struct idr ctx_idr; |
struct idr ctx_idr; |
|
struct list_head vmalist; /**< List of vmas (for debugging) */ |
|
1024,7 → 1130,6 |
__volatile__ long context_flag; /**< Context swapping flag */ |
__volatile__ long interrupt_flag; /**< Interruption handler flag */ |
__volatile__ long dma_flag; /**< DMA dispatch flag */ |
// struct timer_list timer; /**< Timer for delaying ctx switch */ |
// 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 */ |
1045,6 → 1150,8 |
|
// wait_queue_head_t *vbl_queue; /**< VBLANK wait queue */ |
atomic_t *_vblank_count; /**< number of VBLANK interrupts (driver must alloc the right number of counters) */ |
struct timeval *_vblank_time; /**< timestamp of current vblank_count (drivers must alloc right number of fields) */ |
spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */ |
spinlock_t vbl_lock; |
atomic_t *vblank_refcount; /* number of users of vblank interruptsper crtc */ |
u32 *last_vblank; /* protected by dev->vbl_lock, used */ |
1057,6 → 1164,12 |
|
u32 max_vblank_count; /**< size of vblank counter register */ |
|
/** |
* List of events |
*/ |
struct list_head vblank_event_list; |
spinlock_t event_lock; |
|
/*@} */ |
// cycles_t ctx_start; |
// cycles_t lck_start; |
1067,11 → 1180,11 |
|
// struct drm_agp_head *agp; /**< AGP data */ |
|
struct device *dev; /**< Device structure */ |
struct pci_dev *pdev; /**< PCI device structure */ |
int pci_vendor; /**< PCI vendor id */ |
int pci_device; /**< PCI device id */ |
// struct drm_sg_mem *sg; /**< Scatter gather memory */ |
int num_crtcs; /**< Number of CRTCs on this device */ |
unsigned int num_crtcs; /**< Number of CRTCs on this device */ |
void *dev_private; /**< device private data */ |
void *mm_private; |
struct address_space *dev_mapping; |
1084,31 → 1197,29 |
// struct drm_minor *control; /**< Control node for card */ |
// struct drm_minor *primary; /**< render type primary screen head */ |
|
/** \name Drawable information */ |
/*@{ */ |
spinlock_t drw_lock; |
// struct idr drw_idr; |
/*@} */ |
|
struct drm_mode_config mode_config; /**< Current mode config */ |
|
/** \name GEM information */ |
/*@{ */ |
spinlock_t object_name_lock; |
// struct idr object_name_idr; |
atomic_t object_count; |
atomic_t object_memory; |
atomic_t pin_count; |
atomic_t pin_memory; |
atomic_t gtt_count; |
atomic_t gtt_memory; |
uint32_t gtt_total; |
uint32_t invalidate_domains; /* domains pending invalidation */ |
uint32_t flush_domains; /* domains pending flush */ |
struct idr object_name_idr; |
/*@} */ |
|
int switch_power_state; |
}; |
|
#define DRM_SWITCH_POWER_ON 0 |
#define DRM_SWITCH_POWER_OFF 1 |
#define DRM_SWITCH_POWER_CHANGING 2 |
|
|
|
|
|
|
|
|
|
|
static __inline__ int drm_device_is_agp(struct drm_device *dev) |
{ |
return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP); |
1191,8 → 1302,6 |
/*@{*/ |
|
/* Driver support (drm_drv.h) */ |
extern int drm_init(struct drm_driver *driver); |
extern void drm_exit(struct drm_driver *driver); |
extern long drm_ioctl(struct file *filp, |
unsigned int cmd, unsigned long arg); |
extern long drm_compat_ioctl(struct file *filp, |
1200,6 → 1309,7 |
extern int drm_lastclose(struct drm_device *dev); |
|
/* Device support (drm_fops.h) */ |
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); |
1211,8 → 1321,7 |
extern int drm_mmap(struct file *filp, struct vm_area_struct *vma); |
extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma); |
extern void drm_vm_open_locked(struct vm_area_struct *vma); |
extern resource_size_t drm_core_get_map_ofs(struct drm_local_map * map); |
extern resource_size_t drm_core_get_reg_ofs(struct drm_device *dev); |
extern void drm_vm_close_locked(struct vm_area_struct *vma); |
extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); |
|
/* Memory management support (drm_memory.h) */ |
1222,8 → 1331,7 |
int request, int *eof, void *data); |
extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area); |
|
extern DRM_AGP_MEM *drm_alloc_agp(struct drm_device *dev, int pages, u32 type); |
extern int drm_free_agp(DRM_AGP_MEM * handle, int pages); |
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, |
1245,6 → 1353,8 |
struct drm_file *file_priv); |
extern int drm_getstats(struct drm_device *dev, void *data, |
struct drm_file *file_priv); |
extern int drm_getcap(struct drm_device *dev, void *data, |
struct drm_file *file_priv); |
extern int drm_setversion(struct drm_device *dev, void *data, |
struct drm_file *file_priv); |
extern int drm_noop(struct drm_device *dev, void *data, |
1275,17 → 1385,6 |
extern int drm_getsareactx(struct drm_device *dev, void *data, |
struct drm_file *file_priv); |
|
/* Drawable IOCTL support (drm_drawable.h) */ |
extern int drm_adddraw(struct drm_device *dev, void *data, |
struct drm_file *file_priv); |
extern int drm_rmdraw(struct drm_device *dev, void *data, |
struct drm_file *file_priv); |
extern int drm_update_drawable_info(struct drm_device *dev, void *data, |
struct drm_file *file_priv); |
extern struct drm_drawable_info *drm_get_drawable_info(struct drm_device *dev, |
drm_drawable_t id); |
extern void drm_drawable_free_all(struct drm_device *dev); |
|
/* Authentication IOCTL support (drm_auth.h) */ |
extern int drm_getmagic(struct drm_device *dev, void *data, |
struct drm_file *file_priv); |
1300,7 → 1399,6 |
struct drm_file *file_priv); |
extern int drm_unlock(struct drm_device *dev, void *data, |
struct drm_file *file_priv); |
extern int drm_lock_take(struct drm_lock_data *lock_data, unsigned int context); |
extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context); |
extern void drm_idlelock_take(struct drm_lock_data *lock_data); |
extern void drm_idlelock_release(struct drm_lock_data *lock_data); |
1335,10 → 1433,6 |
extern int drm_mapbufs(struct drm_device *dev, void *data, |
struct drm_file *file_priv); |
extern int drm_order(unsigned long size); |
extern resource_size_t drm_get_resource_start(struct drm_device *dev, |
unsigned int resource); |
extern resource_size_t drm_get_resource_len(struct drm_device *dev, |
unsigned int resource); |
|
/* DMA support (drm_dma.h) */ |
extern int drm_dma_setup(struct drm_device *dev); |
1362,11 → 1456,31 |
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 void drm_handle_vblank(struct drm_device *dev, int crtc); |
extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc, |
struct timeval *vblanktime); |
extern bool drm_handle_vblank(struct drm_device *dev, int crtc); |
extern int drm_vblank_get(struct drm_device *dev, int crtc); |
extern void drm_vblank_put(struct drm_device *dev, int crtc); |
extern void drm_vblank_off(struct drm_device *dev, int crtc); |
extern void drm_vblank_cleanup(struct drm_device *dev); |
extern u32 drm_get_last_vbltimestamp(struct drm_device *dev, int crtc, |
struct timeval *tvblank, unsigned flags); |
extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, |
int crtc, int *max_error, |
struct timeval *vblank_time, |
unsigned flags, |
struct drm_crtc *refcrtc); |
extern void drm_calc_timestamping_constants(struct drm_crtc *crtc); |
|
extern bool |
drm_mode_parse_command_line_for_connector(const char *mode_option, |
struct drm_connector *connector, |
struct drm_cmdline_mode *mode); |
|
extern struct drm_display_mode * |
drm_mode_create_from_cmdline_mode(struct drm_device *dev, |
struct drm_cmdline_mode *cmd); |
|
/* Modesetting support */ |
extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc); |
extern void drm_vblank_post_modeset(struct drm_device *dev, int crtc); |
1399,11 → 1513,6 |
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); |
extern DRM_AGP_MEM *drm_agp_allocate_memory(struct agp_bridge_data *bridge, size_t pages, u32 type); |
extern int drm_agp_free_memory(DRM_AGP_MEM * handle); |
extern int drm_agp_bind_memory(DRM_AGP_MEM * handle, off_t start); |
extern int drm_agp_unbind_memory(DRM_AGP_MEM * handle); |
extern void drm_agp_chipset_flush(struct drm_device *dev); |
|
/* Stub support (drm_stub.h) */ |
extern int drm_setmaster_ioctl(struct drm_device *dev, void *data, |
1413,12 → 1522,14 |
struct drm_master *drm_master_create(struct drm_minor *minor); |
extern struct drm_master *drm_master_get(struct drm_master *master); |
extern void drm_master_put(struct drm_master **master); |
extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent, |
struct drm_driver *driver); |
|
extern void drm_put_dev(struct drm_device *dev); |
extern int drm_put_minor(struct drm_minor **minor); |
extern unsigned int drm_debug; |
|
extern unsigned int drm_vblank_offdelay; |
extern unsigned int drm_timestamp_precision; |
|
extern struct class *drm_class; |
extern struct proc_dir_entry *drm_proc_root; |
extern struct dentry *drm_debugfs_root; |
1451,7 → 1562,6 |
extern int drm_vblank_info(struct seq_file *m, void *data); |
extern int drm_clients_info(struct seq_file *m, void* data); |
extern int drm_gem_name_info(struct seq_file *m, void *data); |
extern int drm_gem_object_info(struct seq_file *m, void* data); |
|
#if DRM_DEBUG_CODE |
extern int drm_vma_info(struct seq_file *m, void *data); |
1494,10 → 1604,13 |
/* Graphics Execution Manager library functions (drm_gem.c) */ |
int drm_gem_init(struct drm_device *dev); |
void drm_gem_destroy(struct drm_device *dev); |
void drm_gem_object_release(struct drm_gem_object *obj); |
void drm_gem_object_free(struct kref *kref); |
struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev, |
size_t size); |
void drm_gem_object_handle_free(struct kref *kref); |
int drm_gem_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(struct file *filp, struct vm_area_struct *vma); |