Merge commit 'origin/master' into drm-gem

Conflicts:

	linux-core/Makefile.kernel
	shared-core/i915_drv.h
	shared-core/nouveau_state.c
This commit is contained in:
Eric Anholt 2008-05-30 14:42:08 -07:00
commit 461bfa3da6
56 changed files with 19017 additions and 16856 deletions

View file

@ -35,7 +35,8 @@
#define ATI_PCIGART_PAGE_SIZE 4096 /* PCI GART page size */
int drm_ati_pcigart_init(drm_device_t *dev, struct drm_ati_pcigart_info *gart_info)
int drm_ati_pcigart_init(struct drm_device *dev,
struct drm_ati_pcigart_info *gart_info)
{
unsigned long pages;
u32 *pci_gart = NULL, page_base;
@ -94,7 +95,8 @@ int drm_ati_pcigart_init(drm_device_t *dev, struct drm_ati_pcigart_info *gart_in
return 1;
}
int drm_ati_pcigart_cleanup(drm_device_t *dev, struct drm_ati_pcigart_info *gart_info)
int drm_ati_pcigart_cleanup(struct drm_device *dev,
struct drm_ati_pcigart_info *gart_info)
{
if (dev->sg == NULL) {
DRM_ERROR( "no scatter/gather memory!\n" );

View file

@ -36,7 +36,7 @@
#if defined(_KERNEL) || defined(__KERNEL__)
typedef struct drm_device drm_device_t;
struct drm_device;
typedef struct drm_file drm_file_t;
#include <sys/param.h>
@ -265,7 +265,7 @@ enum {
#define DRM_MTRR_WC MTRR_TYPE_WC
#define jiffies hardclock_ticks
typedef drm_device_t *device_t;
typedef struct drm_device *device_t;
extern struct cfdriver drm_cd;
#endif /* !__FreeBSD__ */
@ -430,7 +430,8 @@ typedef struct drm_pci_id_list
#define DRM_ROOT_ONLY 0x4
typedef struct drm_ioctl_desc {
unsigned long cmd;
int (*func)(drm_device_t *dev, void *data, struct drm_file *file_priv);
int (*func)(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int flags;
} drm_ioctl_desc_t;
/**
@ -528,7 +529,8 @@ typedef struct drm_lock_data {
unsigned long lock_time; /* Time of last lock in jiffies */
} drm_lock_data_t;
/* This structure, in the drm_device_t, is always initialized while the device
/* This structure, in the struct drm_device, 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
* occurs (when the last open of the device has closed). The high/low
@ -619,10 +621,19 @@ struct drm_ati_pcigart_info {
int gart_reg_if;
void *addr;
dma_addr_t bus_addr;
dma_addr_t table_mask;
dma_addr_t member_mask;
struct drm_dma_handle *table_handle;
drm_local_map_t mapping;
int table_size;
};
#ifndef DMA_BIT_MASK
#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : (1ULL<<(n)) - 1)
#endif
#define upper_32_bits(_val) (((u64)(_val)) >> 32)
struct drm_driver_info {
int (*load)(struct drm_device *, unsigned long flags);
int (*firstopen)(struct drm_device *);
@ -633,7 +644,8 @@ struct drm_driver_info {
int (*unload)(struct drm_device *);
void (*reclaim_buffers_locked)(struct drm_device *,
struct drm_file *file_priv);
int (*dma_ioctl)(drm_device_t *dev, void *data, struct drm_file *file_priv);
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 (*dma_flush_block_and_flush)(struct drm_device *, int context,
@ -645,12 +657,13 @@ struct drm_driver_info {
int (*kernel_context_switch)(struct drm_device *dev, int old,
int new);
int (*kernel_context_switch_unlock)(struct drm_device *dev);
void (*irq_preinstall)(drm_device_t *dev);
void (*irq_postinstall)(drm_device_t *dev);
void (*irq_uninstall)(drm_device_t *dev);
void (*irq_preinstall)(struct drm_device *dev);
int (*irq_postinstall)(struct drm_device *dev);
void (*irq_uninstall)(struct drm_device *dev);
void (*irq_handler)(DRM_IRQ_ARGS);
int (*vblank_wait)(drm_device_t *dev, unsigned int *sequence);
int (*vblank_wait2)(drm_device_t *dev, unsigned int *sequence);
u32 (*get_vblank_counter)(struct drm_device *dev, int crtc);
int (*enable_vblank)(struct drm_device *dev, int crtc);
void (*disable_vblank)(struct drm_device *dev, int crtc);
drm_pci_id_list_t *id_entry; /* PCI ID, name, and chipset private */
@ -772,9 +785,25 @@ struct drm_device {
atomic_t context_flag; /* Context swapping flag */
int last_context; /* Last current context */
int vbl_queue; /* vbl wait channel */
atomic_t vbl_received;
atomic_t vbl_received2;
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 mtx vbl_lock;
struct drm_vbl_sig_list *vbl_sigs; /* signal list to send on VBLANK */
atomic_t vbl_signal_pending; /* number of signals pending on all crtcs*/
atomic_t *vblank_refcount; /* number of users of vblank interrupts per crtc */
u32 *last_vblank; /* protected by dev->vbl_lock, used */
/* for wraparound handling */
u32 *vblank_offset; /* used to track how many vblanks */
int *vblank_enabled; /* so we don't call enable more than */
/* once per disable */
u32 *vblank_premodeset; /* were lost during modeset */
struct callout vblank_disable_timer;
unsigned long max_vblank_count; /* size of vblank counter register */
int num_crtcs;
atomic_t vbl_received;
atomic_t vbl_received2;
#ifdef __FreeBSD__
struct sigio *buf_sigio; /* Processes waiting for SIGIO */
@ -797,7 +826,7 @@ struct drm_device {
RB_HEAD(drawable_tree, bsd_drm_drawable_info) drw_head;
struct task locked_task;
void (*locked_task_call)(drm_device_t *dev);
void (*locked_task_call)(struct drm_device *dev);
};
extern int drm_debug_flag;
@ -823,18 +852,20 @@ dev_type_read(drm_read);
dev_type_poll(drm_poll);
dev_type_mmap(drm_mmap);
#endif
extern drm_local_map_t *drm_getsarea(drm_device_t *dev);
extern drm_local_map_t *drm_getsarea(struct drm_device *dev);
/* File operations helpers (drm_fops.c) */
#ifdef __FreeBSD__
extern int drm_open_helper(struct cdev *kdev, int flags, int fmt,
DRM_STRUCTPROC *p, drm_device_t *dev);
extern drm_file_t *drm_find_file_by_proc(drm_device_t *dev,
DRM_STRUCTPROC *p);
extern int drm_open_helper(struct cdev *kdev, int flags, int fmt,
DRM_STRUCTPROC *p,
struct drm_device *dev);
extern drm_file_t *drm_find_file_by_proc(struct drm_device *dev,
DRM_STRUCTPROC *p);
#elif defined(__NetBSD__) || defined(__OpenBSD__)
extern int drm_open_helper(dev_t kdev, int flags, int fmt,
DRM_STRUCTPROC *p, drm_device_t *dev);
extern drm_file_t *drm_find_file_by_proc(drm_device_t *dev,
extern int drm_open_helper(dev_t kdev, int flags, int fmt,
DRM_STRUCTPROC *p,
struct drm_device *dev);
extern drm_file_t *drm_find_file_by_proc(struct drm_device *dev,
DRM_STRUCTPROC *p);
#endif /* __NetBSD__ || __OpenBSD__ */
@ -846,176 +877,234 @@ void *drm_calloc(size_t nmemb, size_t size, int area);
void *drm_realloc(void *oldpt, size_t oldsize, size_t size,
int area);
void drm_free(void *pt, size_t size, int area);
void *drm_ioremap(drm_device_t *dev, drm_local_map_t *map);
void *drm_ioremap(struct drm_device *dev, drm_local_map_t *map);
void drm_ioremapfree(drm_local_map_t *map);
int drm_mtrr_add(unsigned long offset, size_t size, int flags);
int drm_mtrr_del(int handle, unsigned long offset, size_t size, int flags);
int drm_context_switch(drm_device_t *dev, int old, int new);
int drm_context_switch_complete(drm_device_t *dev, int new);
int drm_context_switch(struct drm_device *dev, int old, int new);
int drm_context_switch_complete(struct drm_device *dev, int new);
int drm_ctxbitmap_init(drm_device_t *dev);
void drm_ctxbitmap_cleanup(drm_device_t *dev);
void drm_ctxbitmap_free(drm_device_t *dev, int ctx_handle);
int drm_ctxbitmap_next(drm_device_t *dev);
int drm_ctxbitmap_init(struct drm_device *dev);
void drm_ctxbitmap_cleanup(struct drm_device *dev);
void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
int drm_ctxbitmap_next(struct drm_device *dev);
/* Locking IOCTL support (drm_lock.c) */
int drm_lock_take(__volatile__ unsigned int *lock,
unsigned int context);
int drm_lock_transfer(drm_device_t *dev,
__volatile__ unsigned int *lock,
unsigned int context);
int drm_lock_free(drm_device_t *dev,
__volatile__ unsigned int *lock,
unsigned int context);
int drm_lock_transfer(struct drm_device *dev,
__volatile__ unsigned int *lock,
unsigned int context);
int drm_lock_free(struct drm_device *dev,
__volatile__ unsigned int *lock,
unsigned int context);
/* Buffer management support (drm_bufs.c) */
unsigned long drm_get_resource_start(drm_device_t *dev, unsigned int resource);
unsigned long drm_get_resource_len(drm_device_t *dev, unsigned int resource);
void drm_rmmap(drm_device_t *dev, drm_local_map_t *map);
unsigned long drm_get_resource_start(struct drm_device *dev,
unsigned int resource);
unsigned long drm_get_resource_len(struct drm_device *dev,
unsigned int resource);
void drm_rmmap(struct drm_device *dev, drm_local_map_t *map);
int drm_order(unsigned long size);
int drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size,
int drm_addmap(struct drm_device *dev, unsigned long offset,
unsigned long size,
drm_map_type_t type, drm_map_flags_t flags,
drm_local_map_t **map_ptr);
int drm_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request);
int drm_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request);
int drm_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request);
int drm_addbufs_pci(struct drm_device *dev, drm_buf_desc_t *request);
int drm_addbufs_sg(struct drm_device *dev, drm_buf_desc_t *request);
int drm_addbufs_agp(struct drm_device *dev, drm_buf_desc_t *request);
/* DMA support (drm_dma.c) */
int drm_dma_setup(drm_device_t *dev);
void drm_dma_takedown(drm_device_t *dev);
void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf);
void drm_reclaim_buffers(drm_device_t *dev, struct drm_file *file_priv);
int drm_dma_setup(struct drm_device *dev);
void drm_dma_takedown(struct drm_device *dev);
void drm_free_buffer(struct drm_device *dev, drm_buf_t *buf);
void drm_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv);
#define drm_core_reclaim_buffers drm_reclaim_buffers
/* IRQ support (drm_irq.c) */
int drm_irq_install(drm_device_t *dev);
int drm_irq_uninstall(drm_device_t *dev);
int drm_irq_install(struct drm_device *dev);
int drm_irq_uninstall(struct drm_device *dev);
irqreturn_t drm_irq_handler(DRM_IRQ_ARGS);
void drm_driver_irq_preinstall(drm_device_t *dev);
void drm_driver_irq_postinstall(drm_device_t *dev);
void drm_driver_irq_uninstall(drm_device_t *dev);
int drm_vblank_wait(drm_device_t *dev, unsigned int *vbl_seq);
void drm_vbl_send_signals(drm_device_t *dev);
void drm_driver_irq_preinstall(struct drm_device *dev);
void drm_driver_irq_postinstall(struct drm_device *dev);
void drm_driver_irq_uninstall(struct drm_device *dev);
void drm_handle_vblank(struct drm_device *dev, int crtc);
u32 drm_vblank_count(struct drm_device *dev, int crtc);
int drm_vblank_get(struct drm_device *dev, int crtc);
void drm_vblank_put(struct drm_device *dev, int crtc);
void drm_update_vblank_count(struct drm_device *dev, int crtc);
int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq);
int drm_vblank_init(struct drm_device *dev, int num_crtcs);
void drm_vbl_send_signals(struct drm_device *dev, int crtc);
int drm_modeset_ctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
/* AGP/PCI Express/GART support (drm_agpsupport.c) */
int drm_device_is_agp(drm_device_t *dev);
int drm_device_is_pcie(drm_device_t *dev);
int drm_device_is_agp(struct drm_device *dev);
int drm_device_is_pcie(struct drm_device *dev);
drm_agp_head_t *drm_agp_init(void);
int drm_agp_acquire(drm_device_t *dev);
int drm_agp_release(drm_device_t *dev);
int drm_agp_info(drm_device_t * dev, drm_agp_info_t *info);
int drm_agp_enable(drm_device_t *dev, drm_agp_mode_t mode);
int drm_agp_acquire(struct drm_device *dev);
int drm_agp_release(struct drm_device *dev);
int drm_agp_info(struct drm_device * dev, drm_agp_info_t *info);
int drm_agp_enable(struct drm_device *dev, drm_agp_mode_t mode);
void *drm_agp_allocate_memory(size_t pages, u32 type);
int drm_agp_free_memory(void *handle);
int drm_agp_bind_memory(void *handle, off_t start);
int drm_agp_unbind_memory(void *handle);
int drm_agp_alloc(drm_device_t *dev, drm_agp_buffer_t *request);
int drm_agp_free(drm_device_t *dev, drm_agp_buffer_t *request);
int drm_agp_bind(drm_device_t *dev, drm_agp_binding_t *request);
int drm_agp_unbind(drm_device_t *dev, drm_agp_binding_t *request);
int drm_agp_alloc(struct drm_device *dev, drm_agp_buffer_t *request);
int drm_agp_free(struct drm_device *dev, drm_agp_buffer_t *request);
int drm_agp_bind(struct drm_device *dev, drm_agp_binding_t *request);
int drm_agp_unbind(struct drm_device *dev, drm_agp_binding_t *request);
/* Scatter Gather Support (drm_scatter.c) */
void drm_sg_cleanup(drm_sg_mem_t *entry);
int drm_sg_alloc(drm_device_t * dev, drm_scatter_gather_t * request);
int drm_sg_alloc(struct drm_device *dev, drm_scatter_gather_t * request);
#ifdef __FreeBSD__
/* sysctl support (drm_sysctl.h) */
extern int drm_sysctl_init(drm_device_t *dev);
extern int drm_sysctl_cleanup(drm_device_t *dev);
extern int drm_sysctl_init(struct drm_device *dev);
extern int drm_sysctl_cleanup(struct drm_device *dev);
#endif /* __FreeBSD__ */
/* ATI PCIGART support (ati_pcigart.c) */
int drm_ati_pcigart_init(drm_device_t *dev,
int drm_ati_pcigart_init(struct drm_device *dev,
struct drm_ati_pcigart_info *gart_info);
int drm_ati_pcigart_cleanup(drm_device_t *dev,
int drm_ati_pcigart_cleanup(struct drm_device *dev,
struct drm_ati_pcigart_info *gart_info);
/* Locking IOCTL support (drm_drv.c) */
int drm_lock(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_unlock(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_version(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_setversion(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_lock(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_unlock(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_version(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_setversion(struct drm_device *dev, void *data,
struct drm_file *file_priv);
/* Misc. IOCTL support (drm_ioctl.c) */
int drm_irq_by_busid(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_getunique(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_setunique(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_getmap(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_getclient(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_getstats(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_noop(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_irq_by_busid(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_getunique(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_setunique(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_getmap(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_getclient(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_getstats(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_noop(struct drm_device *dev, void *data,
struct drm_file *file_priv);
/* Context IOCTL support (drm_context.c) */
int drm_resctx(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_addctx(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_modctx(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_getctx(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_switchctx(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_newctx(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_rmctx(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_setsareactx(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_getsareactx(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_resctx(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_addctx(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_modctx(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_getctx(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_switchctx(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_newctx(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_rmctx(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_setsareactx(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_getsareactx(struct drm_device *dev, void *data,
struct drm_file *file_priv);
/* Drawable IOCTL support (drm_drawable.c) */
int drm_adddraw(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_rmdraw(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_update_draw(drm_device_t *dev, void *data, struct drm_file *file_priv);
struct drm_drawable_info *drm_get_drawable_info(drm_device_t *dev, int handle);
int drm_adddraw(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_rmdraw(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_update_draw(struct drm_device *dev, void *data,
struct drm_file *file_priv);
struct drm_drawable_info *drm_get_drawable_info(struct drm_device *dev,
int handle);
/* Authentication IOCTL support (drm_auth.c) */
int drm_getmagic(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_authmagic(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_getmagic(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_authmagic(struct drm_device *dev, void *data,
struct drm_file *file_priv);
/* Buffer management support (drm_bufs.c) */
int drm_addmap_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_rmmap_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_addbufs_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_infobufs(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_markbufs(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_freebufs(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_mapbufs(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_addmap_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_rmmap_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_addbufs_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_infobufs(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_markbufs(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_freebufs(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_mapbufs(struct drm_device *dev, void *data,
struct drm_file *file_priv);
/* DMA support (drm_dma.c) */
int drm_dma(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_dma(struct drm_device *dev, void *data, struct drm_file *file_priv);
/* IRQ support (drm_irq.c) */
int drm_control(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_wait_vblank(drm_device_t *dev, void *data, struct drm_file *file_priv);
void drm_locked_tasklet(drm_device_t *dev,
void (*tasklet)(drm_device_t *dev));
int drm_control(struct drm_device *dev, void *data, struct drm_file *file_priv);
int drm_wait_vblank(struct drm_device *dev, void *data,
struct drm_file *file_priv);
void drm_locked_tasklet(struct drm_device *dev,
void (*tasklet)(struct drm_device *dev));
/* AGP/GART support (drm_agpsupport.c) */
int drm_agp_acquire_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_agp_release_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_agp_enable_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_agp_info_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_agp_alloc_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_agp_free_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_agp_unbind_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_agp_bind_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_agp_release_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_agp_enable_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_agp_info_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_agp_alloc_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_agp_free_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
/* Scatter Gather Support (drm_scatter.c) */
int drm_sg_alloc_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_sg_free(drm_device_t *dev, void *data, struct drm_file *file_priv);
int drm_sg_alloc_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_sg_free(struct drm_device *dev, void *data,
struct drm_file *file_priv);
/* consistent PCI memory functions (drm_pci.c) */
drm_dma_handle_t *drm_pci_alloc(drm_device_t *dev, size_t size, size_t align,
dma_addr_t maxaddr);
void drm_pci_free(drm_device_t *dev, drm_dma_handle_t *dmah);
drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size,
size_t align, dma_addr_t maxaddr);
void drm_pci_free(struct drm_device *dev, drm_dma_handle_t *dmah);
/* Inline replacements for DRM_IOREMAP macros */
static __inline__ void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev)
static __inline__ void
drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev)
{
map->handle = drm_ioremap(dev, map);
}
static __inline__ void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev)
static __inline__ void
drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev)
{
if ( map->handle && map->size )
drm_ioremapfree(map);
}
static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev, unsigned long offset)
static __inline__ struct drm_local_map *
drm_core_findmap(struct drm_device *dev, unsigned long offset)
{
drm_local_map_t *map;

View file

@ -46,7 +46,7 @@
/* Returns 1 if AGP or 0 if not. */
static int
drm_device_find_capability(drm_device_t *dev, int cap)
drm_device_find_capability(struct drm_device *dev, int cap)
{
#ifdef __FreeBSD__
#if __FreeBSD_version >= 602102
@ -88,7 +88,7 @@ drm_device_find_capability(drm_device_t *dev, int cap)
#endif
}
int drm_device_is_agp(drm_device_t *dev)
int drm_device_is_agp(struct drm_device *dev)
{
if (dev->driver.device_is_agp != NULL) {
int ret;
@ -104,12 +104,12 @@ int drm_device_is_agp(drm_device_t *dev)
return (drm_device_find_capability(dev, PCIY_AGP));
}
int drm_device_is_pcie(drm_device_t *dev)
int drm_device_is_pcie(struct drm_device *dev)
{
return (drm_device_find_capability(dev, PCIY_EXPRESS));
}
int drm_agp_info(drm_device_t * dev, drm_agp_info_t *info)
int drm_agp_info(struct drm_device * dev, drm_agp_info_t *info)
{
struct agp_info *kern;
@ -131,7 +131,8 @@ int drm_agp_info(drm_device_t * dev, drm_agp_info_t *info)
return 0;
}
int drm_agp_info_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_agp_info_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
int err;
drm_agp_info_t info;
@ -144,13 +145,14 @@ int drm_agp_info_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv
return 0;
}
int drm_agp_acquire_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
return drm_agp_acquire(dev);
}
int drm_agp_acquire(drm_device_t *dev)
int drm_agp_acquire(struct drm_device *dev)
{
int retcode;
@ -165,13 +167,14 @@ int drm_agp_acquire(drm_device_t *dev)
return 0;
}
int drm_agp_release_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_agp_release_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
return drm_agp_release(dev);
}
int drm_agp_release(drm_device_t * dev)
int drm_agp_release(struct drm_device * dev)
{
if (!dev->agp || !dev->agp->acquired)
return EINVAL;
@ -180,7 +183,7 @@ int drm_agp_release(drm_device_t * dev)
return 0;
}
int drm_agp_enable(drm_device_t *dev, drm_agp_mode_t mode)
int drm_agp_enable(struct drm_device *dev, drm_agp_mode_t mode)
{
if (!dev->agp || !dev->agp->acquired)
@ -192,7 +195,8 @@ int drm_agp_enable(drm_device_t *dev, drm_agp_mode_t mode)
return 0;
}
int drm_agp_enable_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_agp_enable_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
drm_agp_mode_t mode;
@ -201,7 +205,7 @@ int drm_agp_enable_ioctl(drm_device_t *dev, void *data, struct drm_file *file_pr
return drm_agp_enable(dev, mode);
}
int drm_agp_alloc(drm_device_t *dev, drm_agp_buffer_t *request)
int drm_agp_alloc(struct drm_device *dev, drm_agp_buffer_t *request)
{
drm_agp_mem_t *entry;
void *handle;
@ -244,7 +248,8 @@ int drm_agp_alloc(drm_device_t *dev, drm_agp_buffer_t *request)
return 0;
}
int drm_agp_alloc_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_agp_alloc_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
drm_agp_buffer_t request;
int retcode;
@ -260,7 +265,8 @@ int drm_agp_alloc_ioctl(drm_device_t *dev, void *data, struct drm_file *file_pri
return retcode;
}
static drm_agp_mem_t * drm_agp_lookup_entry(drm_device_t *dev, void *handle)
static drm_agp_mem_t * drm_agp_lookup_entry(struct drm_device *dev,
void *handle)
{
drm_agp_mem_t *entry;
@ -270,7 +276,7 @@ static drm_agp_mem_t * drm_agp_lookup_entry(drm_device_t *dev, void *handle)
return NULL;
}
int drm_agp_unbind(drm_device_t *dev, drm_agp_binding_t *request)
int drm_agp_unbind(struct drm_device *dev, drm_agp_binding_t *request)
{
drm_agp_mem_t *entry;
int retcode;
@ -292,7 +298,8 @@ int drm_agp_unbind(drm_device_t *dev, drm_agp_binding_t *request)
return retcode;
}
int drm_agp_unbind_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
drm_agp_binding_t request;
int retcode;
@ -306,7 +313,7 @@ int drm_agp_unbind_ioctl(drm_device_t *dev, void *data, struct drm_file *file_pr
return retcode;
}
int drm_agp_bind(drm_device_t *dev, drm_agp_binding_t *request)
int drm_agp_bind(struct drm_device *dev, drm_agp_binding_t *request)
{
drm_agp_mem_t *entry;
int retcode;
@ -332,7 +339,8 @@ int drm_agp_bind(drm_device_t *dev, drm_agp_binding_t *request)
return retcode;
}
int drm_agp_bind_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
drm_agp_binding_t request;
int retcode;
@ -346,7 +354,7 @@ int drm_agp_bind_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv
return retcode;
}
int drm_agp_free(drm_device_t *dev, drm_agp_buffer_t *request)
int drm_agp_free(struct drm_device *dev, drm_agp_buffer_t *request)
{
drm_agp_mem_t *entry;
@ -376,7 +384,8 @@ int drm_agp_free(drm_device_t *dev, drm_agp_buffer_t *request)
}
int drm_agp_free_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_agp_free_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
drm_agp_buffer_t request;
int retcode;

View file

@ -43,7 +43,7 @@ static int drm_hash_magic(drm_magic_t magic)
/**
* Returns the file private associated with the given magic number.
*/
static drm_file_t *drm_find_file(drm_device_t *dev, drm_magic_t magic)
static drm_file_t *drm_find_file(struct drm_device *dev, drm_magic_t magic)
{
drm_magic_entry_t *pt;
int hash = drm_hash_magic(magic);
@ -63,7 +63,8 @@ static drm_file_t *drm_find_file(drm_device_t *dev, drm_magic_t magic)
* Inserts the given magic number into the hash table of used magic number
* lists.
*/
static int drm_add_magic(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic)
static int drm_add_magic(struct drm_device *dev, drm_file_t *priv,
drm_magic_t magic)
{
int hash;
drm_magic_entry_t *entry;
@ -79,7 +80,6 @@ static int drm_add_magic(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic)
entry->priv = priv;
entry->next = NULL;
DRM_LOCK();
if (dev->magiclist[hash].tail) {
dev->magiclist[hash].tail->next = entry;
dev->magiclist[hash].tail = entry;
@ -87,7 +87,6 @@ static int drm_add_magic(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic)
dev->magiclist[hash].head = entry;
dev->magiclist[hash].tail = entry;
}
DRM_UNLOCK();
return 0;
}
@ -96,7 +95,7 @@ static int drm_add_magic(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic)
* Removes the given magic number from the hash table of used magic number
* lists.
*/
static int drm_remove_magic(drm_device_t *dev, drm_magic_t magic)
static int drm_remove_magic(struct drm_device *dev, drm_magic_t magic)
{
drm_magic_entry_t *prev = NULL;
drm_magic_entry_t *pt;
@ -134,7 +133,7 @@ static int drm_remove_magic(drm_device_t *dev, drm_magic_t magic)
* connection that the magic is passed over) to determine if the magic number
* should be authenticated.
*/
int drm_getmagic(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
static drm_magic_t sequence = 0;
drm_auth_t *auth = data;
@ -165,7 +164,8 @@ int drm_getmagic(drm_device_t *dev, void *data, struct drm_file *file_priv)
/**
* Marks the client associated with the given magic number as authenticated.
*/
int drm_authmagic(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_authmagic(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
drm_auth_t *auth = data;
drm_file_t *priv;

View file

@ -56,7 +56,7 @@ int drm_order(unsigned long size)
* drm_get_resource_*. Note that they are not RF_ACTIVE, so there's no virtual
* address for accessing them. Cleaned up at unload.
*/
static int drm_alloc_resource(drm_device_t *dev, int resource)
static int drm_alloc_resource(struct drm_device *dev, int resource)
{
if (resource >= DRM_MAX_PCI_RESOURCE) {
DRM_ERROR("Resource %d too large\n", resource);
@ -82,7 +82,8 @@ static int drm_alloc_resource(drm_device_t *dev, int resource)
return 0;
}
unsigned long drm_get_resource_start(drm_device_t *dev, unsigned int resource)
unsigned long drm_get_resource_start(struct drm_device *dev,
unsigned int resource)
{
if (drm_alloc_resource(dev, resource) != 0)
return 0;
@ -90,7 +91,8 @@ unsigned long drm_get_resource_start(drm_device_t *dev, unsigned int resource)
return rman_get_start(dev->pcir[resource]);
}
unsigned long drm_get_resource_len(drm_device_t *dev, unsigned int resource)
unsigned long drm_get_resource_len(struct drm_device *dev,
unsigned int resource)
{
if (drm_alloc_resource(dev, resource) != 0)
return 0;
@ -98,7 +100,8 @@ unsigned long drm_get_resource_len(drm_device_t *dev, unsigned int resource)
return rman_get_size(dev->pcir[resource]);
}
int drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size,
int drm_addmap(struct drm_device * dev, unsigned long offset,
unsigned long size,
drm_map_type_t type, drm_map_flags_t flags, drm_local_map_t **map_ptr)
{
drm_local_map_t *map;
@ -149,8 +152,10 @@ int drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size,
* initialization necessary.
*/
map = malloc(sizeof(*map), M_DRM, M_ZERO | M_NOWAIT);
if ( !map )
if ( !map ) {
DRM_LOCK();
return ENOMEM;
}
map->offset = offset;
map->size = size;
@ -173,6 +178,7 @@ int drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size,
map->size, drm_order(map->size), map->handle );
if ( !map->handle ) {
free(map, M_DRM);
DRM_LOCK();
return ENOMEM;
}
map->offset = (unsigned long)map->handle;
@ -213,12 +219,14 @@ int drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size,
}
if (!valid) {
free(map, M_DRM);
DRM_LOCK();
return EACCES;
}*/
break;
case _DRM_SCATTER_GATHER:
if (!dev->sg) {
free(map, M_DRM);
DRM_LOCK();
return EINVAL;
}
map->offset = map->offset + dev->sg->handle;
@ -236,6 +244,7 @@ int drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size,
map->dmah = drm_pci_alloc(dev, map->size, align, 0xfffffffful);
if (map->dmah == NULL) {
free(map, M_DRM);
DRM_LOCK();
return ENOMEM;
}
map->handle = map->dmah->vaddr;
@ -244,6 +253,7 @@ int drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size,
default:
DRM_ERROR("Bad map type %d\n", map->type);
free(map, M_DRM);
DRM_LOCK();
return EINVAL;
}
@ -261,7 +271,8 @@ done:
return 0;
}
int drm_addmap_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_addmap_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
drm_map_t *request = data;
drm_local_map_t *map;
@ -294,7 +305,7 @@ int drm_addmap_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv)
return 0;
}
void drm_rmmap(drm_device_t *dev, drm_local_map_t *map)
void drm_rmmap(struct drm_device *dev, drm_local_map_t *map)
{
DRM_SPINLOCK_ASSERT(&dev->dev_lock);
@ -340,7 +351,8 @@ void drm_rmmap(drm_device_t *dev, drm_local_map_t *map)
* isn't in use.
*/
int drm_rmmap_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_rmmap_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
drm_local_map_t *map;
drm_map_t *request = data;
@ -366,7 +378,8 @@ int drm_rmmap_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv)
}
static void drm_cleanup_buf_error(drm_device_t *dev, drm_buf_entry_t *entry)
static void drm_cleanup_buf_error(struct drm_device *dev,
drm_buf_entry_t *entry)
{
int i;
@ -389,7 +402,7 @@ static void drm_cleanup_buf_error(drm_device_t *dev, drm_buf_entry_t *entry)
}
}
static int drm_do_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request)
static int drm_do_addbufs_agp(struct drm_device *dev, drm_buf_desc_t *request)
{
drm_device_dma_t *dma = dev->dma;
drm_buf_entry_t *entry;
@ -520,7 +533,7 @@ static int drm_do_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request)
return 0;
}
static int drm_do_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request)
static int drm_do_addbufs_pci(struct drm_device *dev, drm_buf_desc_t *request)
{
drm_device_dma_t *dma = dev->dma;
int count;
@ -667,7 +680,7 @@ static int drm_do_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request)
}
static int drm_do_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request)
static int drm_do_addbufs_sg(struct drm_device *dev, drm_buf_desc_t *request)
{
drm_device_dma_t *dma = dev->dma;
drm_buf_entry_t *entry;
@ -778,12 +791,10 @@ static int drm_do_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request)
return 0;
}
int drm_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request)
int drm_addbufs_agp(struct drm_device *dev, drm_buf_desc_t *request)
{
int order, ret;
DRM_SPINLOCK(&dev->dma_lock);
if (request->count < 0 || request->count > 4096)
return EINVAL;
@ -791,6 +802,8 @@ int drm_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request)
if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
return EINVAL;
DRM_SPINLOCK(&dev->dma_lock);
/* No more allocations after first buffer-using ioctl. */
if (dev->buf_use != 0) {
DRM_SPINUNLOCK(&dev->dma_lock);
@ -809,18 +822,18 @@ int drm_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request)
return ret;
}
int drm_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request)
int drm_addbufs_sg(struct drm_device *dev, drm_buf_desc_t *request)
{
int order, ret;
DRM_SPINLOCK(&dev->dma_lock);
if (!DRM_SUSER(DRM_CURPROC))
return EACCES;
if (request->count < 0 || request->count > 4096)
return EINVAL;
DRM_SPINLOCK(&dev->dma_lock);
order = drm_order(request->size);
if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
return EINVAL;
@ -843,22 +856,22 @@ int drm_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request)
return ret;
}
int drm_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request)
int drm_addbufs_pci(struct drm_device *dev, drm_buf_desc_t *request)
{
int order, ret;
DRM_SPINLOCK(&dev->dma_lock);
if (!DRM_SUSER(DRM_CURPROC))
return EACCES;
if (request->count < 0 || request->count > 4096)
return EINVAL;
order = drm_order(request->size);
if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
return EINVAL;
DRM_SPINLOCK(&dev->dma_lock);
/* No more allocations after first buffer-using ioctl. */
if (dev->buf_use != 0) {
DRM_SPINUNLOCK(&dev->dma_lock);
@ -877,7 +890,8 @@ int drm_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request)
return ret;
}
int drm_addbufs_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_addbufs_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
drm_buf_desc_t *request = data;
int err;
@ -892,7 +906,7 @@ int drm_addbufs_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv)
return err;
}
int drm_infobufs(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_infobufs(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
drm_device_dma_t *dma = dev->dma;
drm_buf_info_t *request = data;
@ -941,7 +955,7 @@ int drm_infobufs(drm_device_t *dev, void *data, struct drm_file *file_priv)
return retcode;
}
int drm_markbufs(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_markbufs(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
drm_device_dma_t *dma = dev->dma;
drm_buf_desc_t *request = data;
@ -960,6 +974,7 @@ int drm_markbufs(drm_device_t *dev, void *data, struct drm_file *file_priv)
DRM_SPINLOCK(&dev->dma_lock);
if (request->low_mark > dma->bufs[order].buf_count ||
request->high_mark > dma->bufs[order].buf_count) {
DRM_SPINUNLOCK(&dev->dma_lock);
return EINVAL;
}
@ -970,7 +985,7 @@ int drm_markbufs(drm_device_t *dev, void *data, struct drm_file *file_priv)
return 0;
}
int drm_freebufs(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_freebufs(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
drm_device_dma_t *dma = dev->dma;
drm_buf_free_t *request = data;
@ -1007,7 +1022,7 @@ int drm_freebufs(drm_device_t *dev, void *data, struct drm_file *file_priv)
return retcode;
}
int drm_mapbufs(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_mapbufs(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
drm_device_dma_t *dma = dev->dma;
int retcode = 0;

View file

@ -38,7 +38,7 @@
* Context bitmap support
*/
void drm_ctxbitmap_free(drm_device_t *dev, int ctx_handle)
void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle)
{
if (ctx_handle < 0 || ctx_handle >= DRM_MAX_CTXBITMAP ||
dev->ctx_bitmap == NULL) {
@ -54,7 +54,7 @@ void drm_ctxbitmap_free(drm_device_t *dev, int ctx_handle)
return;
}
int drm_ctxbitmap_next(drm_device_t *dev)
int drm_ctxbitmap_next(struct drm_device *dev)
{
int bit;
@ -101,7 +101,7 @@ int drm_ctxbitmap_next(drm_device_t *dev)
return bit;
}
int drm_ctxbitmap_init(drm_device_t *dev)
int drm_ctxbitmap_init(struct drm_device *dev)
{
int i;
int temp;
@ -124,7 +124,7 @@ int drm_ctxbitmap_init(drm_device_t *dev)
return 0;
}
void drm_ctxbitmap_cleanup(drm_device_t *dev)
void drm_ctxbitmap_cleanup(struct drm_device *dev)
{
DRM_LOCK();
if (dev->context_sareas != NULL)
@ -137,7 +137,8 @@ void drm_ctxbitmap_cleanup(drm_device_t *dev)
* Per Context SAREA Support
*/
int drm_getsareactx( drm_device_t *dev, void *data, struct drm_file *file_priv )
int drm_getsareactx(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
drm_ctx_priv_map_t *request = data;
drm_local_map_t *map;
@ -157,7 +158,8 @@ int drm_getsareactx( drm_device_t *dev, void *data, struct drm_file *file_priv )
return 0;
}
int drm_setsareactx(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_setsareactx(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
drm_ctx_priv_map_t *request = data;
drm_local_map_t *map = NULL;
@ -184,7 +186,7 @@ bad:
* The actual DRM context handling routines
*/
int drm_context_switch(drm_device_t *dev, int old, int new)
int drm_context_switch(struct drm_device *dev, int old, int new)
{
if ( test_and_set_bit( 0, &dev->context_flag ) ) {
DRM_ERROR( "Reentering -- FIXME\n" );
@ -201,7 +203,7 @@ int drm_context_switch(drm_device_t *dev, int old, int new)
return 0;
}
int drm_context_switch_complete(drm_device_t *dev, int new)
int drm_context_switch_complete(struct drm_device *dev, int new)
{
dev->last_context = new; /* PRE/POST: This is the _only_ writer. */
@ -217,7 +219,7 @@ int drm_context_switch_complete(drm_device_t *dev, int new)
return 0;
}
int drm_resctx(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_resctx(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
drm_ctx_res_t *res = data;
drm_ctx_t ctx;
@ -237,7 +239,7 @@ int drm_resctx(drm_device_t *dev, void *data, struct drm_file *file_priv)
return 0;
}
int drm_addctx(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_addctx(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
drm_ctx_t *ctx = data;
@ -262,13 +264,13 @@ int drm_addctx(drm_device_t *dev, void *data, struct drm_file *file_priv)
return 0;
}
int drm_modctx(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_modctx(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
/* This does nothing */
return 0;
}
int drm_getctx(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_getctx(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
drm_ctx_t *ctx = data;
@ -278,7 +280,8 @@ int drm_getctx(drm_device_t *dev, void *data, struct drm_file *file_priv)
return 0;
}
int drm_switchctx(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_switchctx(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
drm_ctx_t *ctx = data;
@ -286,7 +289,7 @@ int drm_switchctx(drm_device_t *dev, void *data, struct drm_file *file_priv)
return drm_context_switch(dev, dev->last_context, ctx->handle);
}
int drm_newctx(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_newctx(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
drm_ctx_t *ctx = data;
@ -296,7 +299,7 @@ int drm_newctx(drm_device_t *dev, void *data, struct drm_file *file_priv)
return 0;
}
int drm_rmctx(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_rmctx(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
drm_ctx_t *ctx = data;

View file

@ -38,7 +38,7 @@
#include "drmP.h"
int drm_dma_setup(drm_device_t *dev)
int drm_dma_setup(struct drm_device *dev)
{
dev->dma = malloc(sizeof(*dev->dma), M_DRM, M_NOWAIT | M_ZERO);
@ -50,7 +50,7 @@ int drm_dma_setup(drm_device_t *dev)
return 0;
}
void drm_dma_takedown(drm_device_t *dev)
void drm_dma_takedown(struct drm_device *dev)
{
drm_device_dma_t *dma = dev->dma;
int i, j;
@ -89,7 +89,7 @@ void drm_dma_takedown(drm_device_t *dev)
}
void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf)
void drm_free_buffer(struct drm_device *dev, drm_buf_t *buf)
{
if (!buf) return;
@ -98,7 +98,7 @@ void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf)
buf->used = 0;
}
void drm_reclaim_buffers(drm_device_t *dev, struct drm_file *file_priv)
void drm_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv)
{
drm_device_dma_t *dma = dev->dma;
int i;
@ -122,7 +122,7 @@ void drm_reclaim_buffers(drm_device_t *dev, struct drm_file *file_priv)
}
/* Call into the driver-specific DMA handler */
int drm_dma(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_dma(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
if (dev->driver.dma_ioctl) {

View file

@ -56,7 +56,7 @@ RB_GENERATE_STATIC(drawable_tree, bsd_drm_drawable_info, tree,
drm_drawable_compare);
struct drm_drawable_info *
drm_get_drawable_info(drm_device_t *dev, int handle)
drm_get_drawable_info(struct drm_device *dev, int handle)
{
struct bsd_drm_drawable_info find, *result;
@ -66,7 +66,7 @@ drm_get_drawable_info(drm_device_t *dev, int handle)
return &result->info;
}
int drm_adddraw(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_adddraw(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
drm_draw_t *draw = data;
struct bsd_drm_drawable_info *info;
@ -87,7 +87,7 @@ int drm_adddraw(drm_device_t *dev, void *data, struct drm_file *file_priv)
return 0;
}
int drm_rmdraw(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_rmdraw(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
drm_draw_t *draw = (drm_draw_t *)data;
struct drm_drawable_info *info;
@ -108,7 +108,8 @@ int drm_rmdraw(drm_device_t *dev, void *data, struct drm_file *file_priv)
}
}
int drm_update_draw(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_update_draw(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
struct drm_drawable_info *info;
struct drm_update_draw *update = (struct drm_update_draw *)data;
@ -135,8 +136,10 @@ int drm_update_draw(drm_device_t *dev, void *data, struct drm_file *file_priv)
if (info->rects == NULL) {
info->rects = drm_alloc(sizeof(*info->rects) *
update->num, DRM_MEM_DRAWABLE);
if (info->rects == NULL)
if (info->rects == NULL) {
DRM_SPINUNLOCK(&dev->drw_lock);
return ENOMEM;
}
info->num_rects = update->num;
}
/* For some reason the pointer arg is unsigned long long. */

View file

@ -45,14 +45,14 @@ int drm_debug_flag = 1;
int drm_debug_flag = 0;
#endif
static int drm_load(drm_device_t *dev);
static void drm_unload(drm_device_t *dev);
static int drm_load(struct drm_device *dev);
static void drm_unload(struct drm_device *dev);
static drm_pci_id_list_t *drm_find_description(int vendor, int device,
drm_pci_id_list_t *idlist);
#ifdef __FreeBSD__
#define DRIVER_SOFTC(unit) \
((drm_device_t *)devclass_get_softc(drm_devclass, unit))
((struct drm_device *)devclass_get_softc(drm_devclass, unit))
MODULE_VERSION(drm, 1);
MODULE_DEPEND(drm, agp, 1, 1, 1);
@ -64,7 +64,7 @@ MODULE_DEPEND(drm, mem, 1, 1, 1);
#if defined(__NetBSD__) || defined(__OpenBSD__)
#define DRIVER_SOFTC(unit) \
((drm_device_t *)device_lookup(&drm_cd, unit))
((struct drm_device *)device_lookup(&drm_cd, unit))
#endif /* __NetBSD__ || __OpenBSD__ */
static drm_ioctl_desc_t drm_ioctls[256] = {
@ -180,7 +180,7 @@ int drm_probe(device_t dev, drm_pci_id_list_t *idlist)
int drm_attach(device_t nbdev, drm_pci_id_list_t *idlist)
{
drm_device_t *dev;
struct drm_device *dev;
drm_pci_id_list_t *id_entry;
int unit;
@ -319,14 +319,15 @@ void drm_attach(struct pci_attach_args *pa, dev_t kdev,
drm_pci_id_list_t *idlist)
{
int i;
drm_device_t *dev;
struct drm_device *dev;
drm_pci_id_list_t *id_entry;
config_makeroom(kdev, &drm_cd);
drm_cd.cd_devs[(kdev)] = malloc(sizeof(drm_device_t), M_DRM, M_WAITOK);
drm_cd.cd_devs[(kdev)] = malloc(sizeof(struct drm_device),
M_DRM, M_WAITOK);
dev = DRIVER_SOFTC(kdev);
memset(dev, 0, sizeof(drm_device_t));
memset(dev, 0, sizeof(struct drm_device));
memcpy(&dev->pa, pa, sizeof(dev->pa));
dev->irq = pa->pa_intrline;
@ -346,7 +347,7 @@ void drm_attach(struct pci_attach_args *pa, dev_t kdev,
int drm_detach(struct device *self, int flags)
{
drm_unload((drm_device_t *)self);
drm_unload((struct drm_device *)self);
return 0;
}
@ -379,7 +380,7 @@ drm_pci_id_list_t *drm_find_description(int vendor, int device,
return NULL;
}
static int drm_firstopen(drm_device_t *dev)
static int drm_firstopen(struct drm_device *dev)
{
drm_local_map_t *map;
int i;
@ -425,7 +426,7 @@ static int drm_firstopen(drm_device_t *dev)
return 0;
}
static int drm_lastclose(drm_device_t *dev)
static int drm_lastclose(struct drm_device *dev)
{
drm_magic_entry_t *pt, *next;
drm_local_map_t *map, *mapsave;
@ -498,7 +499,7 @@ static int drm_lastclose(drm_device_t *dev)
return 0;
}
static int drm_load(drm_device_t *dev)
static int drm_load(struct drm_device *dev)
{
int i, retcode;
@ -599,7 +600,7 @@ error:
return retcode;
}
static void drm_unload(drm_device_t *dev)
static void drm_unload(struct drm_device *dev)
{
int i;
@ -654,7 +655,7 @@ static void drm_unload(drm_device_t *dev)
}
int drm_version(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_version(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
drm_version_t *version = data;
int len;
@ -681,7 +682,7 @@ int drm_version(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_open(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
{
drm_device_t *dev = NULL;
struct drm_device *dev = NULL;
int retcode = 0;
dev = DRIVER_SOFTC(minor(kdev));
@ -706,7 +707,7 @@ int drm_open(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
int drm_close(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
{
drm_device_t *dev = drm_get_device_from_kdev(kdev);
struct drm_device *dev = drm_get_device_from_kdev(kdev);
drm_file_t *file_priv;
int retcode = 0;
@ -827,10 +828,10 @@ done:
int drm_ioctl(struct cdev *kdev, u_long cmd, caddr_t data, int flags,
DRM_STRUCTPROC *p)
{
drm_device_t *dev = drm_get_device_from_kdev(kdev);
struct drm_device *dev = drm_get_device_from_kdev(kdev);
int retcode = 0;
drm_ioctl_desc_t *ioctl;
int (*func)(drm_device_t *dev, void *data, struct drm_file *file_priv);
int (*func)(struct drm_device *dev, void *data, struct drm_file *file_priv);
int nr = DRM_IOCTL_NR(cmd);
int is_driver_ioctl = 0;
drm_file_t *file_priv;
@ -929,7 +930,7 @@ int drm_ioctl(struct cdev *kdev, u_long cmd, caddr_t data, int flags,
return retcode;
}
drm_local_map_t *drm_getsarea(drm_device_t *dev)
drm_local_map_t *drm_getsarea(struct drm_device *dev)
{
drm_local_map_t *map;

View file

@ -36,7 +36,7 @@
#include "drmP.h"
drm_file_t *drm_find_file_by_proc(drm_device_t *dev, DRM_STRUCTPROC *p)
drm_file_t *drm_find_file_by_proc(struct drm_device *dev, DRM_STRUCTPROC *p)
{
#if __FreeBSD_version >= 500021
uid_t uid = p->td_ucred->cr_svuid;
@ -57,7 +57,7 @@ drm_file_t *drm_find_file_by_proc(drm_device_t *dev, DRM_STRUCTPROC *p)
/* drm_open_helper is called whenever a process opens /dev/drm. */
int drm_open_helper(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p,
drm_device_t *dev)
struct drm_device *dev)
{
int m = minor(kdev);
drm_file_t *priv;

View file

@ -41,7 +41,8 @@
* before setunique has been called. The format for the bus-specific part of
* the unique is not defined for any other bus.
*/
int drm_getunique(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_getunique(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
drm_unique_t *u = data;
@ -57,7 +58,8 @@ int drm_getunique(drm_device_t *dev, void *data, struct drm_file *file_priv)
/* Deprecated in DRM version 1.1, and will return EBUSY when setversion has
* requested version 1.1 or greater.
*/
int drm_setunique(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_setunique(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
drm_unique_t *u = data;
int domain, bus, slot, func, ret;
@ -112,7 +114,7 @@ int drm_setunique(drm_device_t *dev, void *data, struct drm_file *file_priv)
static int
drm_set_busid(drm_device_t *dev)
drm_set_busid(struct drm_device *dev)
{
DRM_LOCK();
@ -137,7 +139,7 @@ drm_set_busid(drm_device_t *dev)
return 0;
}
int drm_getmap(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_getmap(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
drm_map_t *map = data;
drm_local_map_t *mapinlist;
@ -173,7 +175,8 @@ int drm_getmap(drm_device_t *dev, void *data, struct drm_file *file_priv)
return 0;
}
int drm_getclient(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_getclient(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
drm_client_t *client = data;
drm_file_t *pt;
@ -200,7 +203,7 @@ int drm_getclient(drm_device_t *dev, void *data, struct drm_file *file_priv)
return EINVAL;
}
int drm_getstats(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_getstats(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
drm_stats_t *stats = data;
int i;
@ -229,7 +232,8 @@ int drm_getstats(drm_device_t *dev, void *data, struct drm_file *file_priv)
#define DRM_IF_MAJOR 1
#define DRM_IF_MINOR 2
int drm_setversion(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_setversion(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
drm_set_version_t *sv = data;
drm_set_version_t ver;
@ -273,7 +277,7 @@ int drm_setversion(drm_device_t *dev, void *data, struct drm_file *file_priv)
}
int drm_noop(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_noop(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
DRM_DEBUG("\n");
return 0;

View file

@ -35,7 +35,8 @@
static void drm_locked_task(void *context, int pending __unused);
int drm_irq_by_busid(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_irq_by_busid(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
drm_irq_busid_t *irq = data;
@ -57,7 +58,7 @@ int drm_irq_by_busid(drm_device_t *dev, void *data, struct drm_file *file_priv)
static irqreturn_t
drm_irq_handler_wrap(DRM_IRQ_ARGS)
{
drm_device_t *dev = (drm_device_t *)arg;
struct drm_device *dev = arg;
DRM_SPINLOCK(&dev->irq_lock);
dev->driver.irq_handler(arg);
@ -65,7 +66,7 @@ drm_irq_handler_wrap(DRM_IRQ_ARGS)
}
#endif
int drm_irq_install(drm_device_t *dev)
int drm_irq_install(struct drm_device *dev)
{
int retcode;
#ifdef __NetBSD__
@ -147,7 +148,7 @@ err:
return retcode;
}
int drm_irq_uninstall(drm_device_t *dev)
int drm_irq_uninstall(struct drm_device *dev)
{
#ifdef __FreeBSD__
int irqrid;
@ -179,7 +180,7 @@ int drm_irq_uninstall(drm_device_t *dev)
return 0;
}
int drm_control(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_control(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
drm_control_t *ctl = data;
int err;
@ -207,12 +208,130 @@ int drm_control(drm_device_t *dev, void *data, struct drm_file *file_priv)
}
}
int drm_wait_vblank(drm_device_t *dev, void *data, struct drm_file *file_priv)
static void vblank_disable_fn(void *arg)
{
struct drm_device *dev = (struct drm_device *)arg;
unsigned long irqflags;
int i;
for (i = 0; i < dev->num_crtcs; i++) {
DRM_SPINLOCK_IRQSAVE(&dev->vbl_lock, irqflags);
if (atomic_read(&dev->vblank_refcount[i]) == 0 &&
dev->vblank_enabled[i]) {
dev->driver.disable_vblank(dev, i);
dev->vblank_enabled[i] = 0;
}
DRM_SPINUNLOCK_IRQRESTORE(&dev->vbl_lock, irqflags);
}
}
u32 drm_vblank_count(struct drm_device *dev, int crtc)
{
return atomic_read(&dev->_vblank_count[crtc]) +
dev->vblank_offset[crtc];
}
int drm_vblank_get(struct drm_device *dev, int crtc)
{
unsigned long irqflags;
int ret = 0;
DRM_SPINLOCK_IRQSAVE(&dev->vbl_lock, irqflags);
/* Going from 0->1 means we have to enable interrupts again */
atomic_add_acq_int(&dev->vblank_refcount[crtc], 1);
if (dev->vblank_refcount[crtc] == 1 &&
!dev->vblank_enabled[crtc]) {
ret = dev->driver.enable_vblank(dev, crtc);
if (ret)
atomic_dec(&dev->vblank_refcount[crtc]);
else
dev->vblank_enabled[crtc] = 1;
}
DRM_SPINUNLOCK_IRQRESTORE(&dev->vbl_lock, irqflags);
return ret;
}
void drm_vblank_put(struct drm_device *dev, int crtc)
{
/* Last user schedules interrupt disable */
atomic_subtract_acq_int(&dev->vblank_refcount[crtc], 1);
if (dev->vblank_refcount[crtc] == 0)
callout_reset(&dev->vblank_disable_timer, jiffies + 5*DRM_HZ,
(timeout_t *)vblank_disable_fn, (void *)dev);
}
void drm_handle_vblank(struct drm_device *dev, int crtc)
{
drm_update_vblank_count(dev, crtc);
DRM_WAKEUP(&dev->vbl_queue[crtc]);
drm_vbl_send_signals(dev, crtc);
}
void drm_update_vblank_count(struct drm_device *dev, int crtc)
{
unsigned long irqflags;
u32 cur_vblank, diff;
/*
* Interrupts were disabled prior to this call, so deal with counter
* wrap if needed.
* NOTE! It's possible we lost a full dev->max_vblank_count events
* here if the register is small or we had vblank interrupts off for
* a long time.
*/
cur_vblank = dev->driver.get_vblank_counter(dev, crtc);
DRM_SPINLOCK_IRQSAVE(&dev->vbl_lock, irqflags);
if (cur_vblank < dev->last_vblank[crtc]) {
diff = dev->max_vblank_count -
dev->last_vblank[crtc];
diff += cur_vblank;
} else {
diff = cur_vblank - dev->last_vblank[crtc];
}
dev->last_vblank[crtc] = cur_vblank;
DRM_SPINUNLOCK_IRQRESTORE(&dev->vbl_lock, irqflags);
atomic_add(diff, &dev->_vblank_count[crtc]);
}
int drm_modeset_ctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
struct drm_modeset_ctl *modeset = data;
int crtc, ret = 0;
u32 new;
crtc = modeset->crtc;
if (crtc >= dev->num_crtcs) {
ret = -EINVAL;
goto out;
}
switch (modeset->cmd) {
case _DRM_PRE_MODESET:
dev->vblank_premodeset[crtc] =
dev->driver.get_vblank_counter(dev, crtc);
break;
case _DRM_POST_MODESET:
new = dev->driver.get_vblank_counter(dev, crtc);
dev->vblank_offset[crtc] = dev->vblank_premodeset[crtc] - new;
break;
default:
ret = -EINVAL;
break;
}
out:
return ret;
}
int drm_wait_vblank(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
drm_wait_vblank_t *vblwait = data;
struct timeval now;
int ret = 0;
int flags, seq;
int flags, seq, crtc;
if (!dev->irq_enabled)
return EINVAL;
@ -226,12 +345,13 @@ int drm_wait_vblank(drm_device_t *dev, void *data, struct drm_file *file_priv)
}
flags = vblwait->request.type & _DRM_VBLANK_FLAGS_MASK;
crtc = flags & _DRM_VBLANK_SECONDARY ? 1 : 0;
if ((flags & _DRM_VBLANK_SECONDARY) && !dev->driver.use_vbl_irq2)
if (crtc >= dev->num_crtcs)
return EINVAL;
seq = atomic_read((flags & _DRM_VBLANK_SECONDARY) ?
&dev->vbl_received2 : &dev->vbl_received);
drm_update_vblank_count(dev, crtc);
seq = drm_vblank_count(dev, crtc);
switch (vblwait->request.type & _DRM_VBLANK_TYPES_MASK) {
case _DRM_VBLANK_RELATIVE:
@ -268,16 +388,18 @@ int drm_wait_vblank(drm_device_t *dev, void *data, struct drm_file *file_priv)
#endif
ret = EINVAL;
} else {
unsigned long cur_vblank;
DRM_LOCK();
/* shared code returns -errno */
if (flags & _DRM_VBLANK_SECONDARY) {
if (dev->driver.vblank_wait2)
ret = -dev->driver.vblank_wait2(dev,
&vblwait->request.sequence);
} else if (dev->driver.vblank_wait)
ret = -dev->driver.vblank_wait(dev,
&vblwait->request.sequence);
ret = drm_vblank_get(dev, crtc);
if (ret)
return ret;
DRM_WAIT_ON(ret, dev->vbl_queue[crtc], 3 * DRM_HZ,
(((cur_vblank = drm_vblank_count(dev, crtc))
- vblwait->request.sequence) <= (1 << 23)));
drm_vblank_put(dev, crtc);
DRM_UNLOCK();
microtime(&now);
@ -288,12 +410,104 @@ int drm_wait_vblank(drm_device_t *dev, void *data, struct drm_file *file_priv)
return ret;
}
void drm_vbl_send_signals(drm_device_t *dev)
static void drm_vblank_cleanup(struct drm_device *dev)
{
/* Bail if the driver didn't call drm_vblank_init() */
if (dev->num_crtcs == 0)
return;
callout_stop(&dev->vblank_disable_timer);
vblank_disable_fn((void *)dev);
drm_free(dev->vbl_queue, sizeof(*dev->vbl_queue) * dev->num_crtcs,
DRM_MEM_DRIVER);
drm_free(dev->vbl_sigs, sizeof(*dev->vbl_sigs) * dev->num_crtcs,
DRM_MEM_DRIVER);
drm_free(dev->_vblank_count, sizeof(*dev->_vblank_count) *
dev->num_crtcs, DRM_MEM_DRIVER);
drm_free(dev->vblank_refcount, sizeof(*dev->vblank_refcount) *
dev->num_crtcs, DRM_MEM_DRIVER);
drm_free(dev->vblank_enabled, sizeof(*dev->vblank_enabled) *
dev->num_crtcs, DRM_MEM_DRIVER);
drm_free(dev->last_vblank, sizeof(*dev->last_vblank) * dev->num_crtcs,
DRM_MEM_DRIVER);
drm_free(dev->vblank_premodeset, sizeof(*dev->vblank_premodeset) *
dev->num_crtcs, DRM_MEM_DRIVER);
drm_free(dev->vblank_offset, sizeof(*dev->vblank_offset) * dev->num_crtcs,
DRM_MEM_DRIVER);
dev->num_crtcs = 0;
}
int drm_vblank_init(struct drm_device *dev, int num_crtcs)
{
int i, ret = -ENOMEM;
callout_init(&dev->vblank_disable_timer, 0);
DRM_SPININIT(&dev->vbl_lock, "drm_vblk");
atomic_set(&dev->vbl_signal_pending, 0);
dev->num_crtcs = num_crtcs;
dev->vbl_queue = drm_alloc(sizeof(wait_queue_head_t) * num_crtcs,
DRM_MEM_DRIVER);
if (!dev->vbl_queue)
goto err;
dev->vbl_sigs = drm_alloc(sizeof(struct drm_vbl_sig) * num_crtcs,
DRM_MEM_DRIVER);
if (!dev->vbl_sigs)
goto err;
dev->_vblank_count = drm_alloc(sizeof(atomic_t) * num_crtcs,
DRM_MEM_DRIVER);
if (!dev->_vblank_count)
goto err;
dev->vblank_refcount = drm_alloc(sizeof(atomic_t) * num_crtcs,
DRM_MEM_DRIVER);
if (!dev->vblank_refcount)
goto err;
dev->vblank_enabled = drm_calloc(num_crtcs, sizeof(int),
DRM_MEM_DRIVER);
if (!dev->vblank_enabled)
goto err;
dev->last_vblank = drm_calloc(num_crtcs, sizeof(u32), DRM_MEM_DRIVER);
if (!dev->last_vblank)
goto err;
dev->vblank_premodeset = drm_calloc(num_crtcs, sizeof(u32),
DRM_MEM_DRIVER);
if (!dev->vblank_premodeset)
goto err;
dev->vblank_offset = drm_calloc(num_crtcs, sizeof(u32), DRM_MEM_DRIVER);
if (!dev->vblank_offset)
goto err;
/* Zero per-crtc vblank stuff */
for (i = 0; i < num_crtcs; i++) {
DRM_INIT_WAITQUEUE(&dev->vbl_queue[i]);
TAILQ_INIT(&dev->vbl_sigs[i]);
atomic_set(&dev->_vblank_count[i], 0);
atomic_set(&dev->vblank_refcount[i], 0);
}
return 0;
err:
drm_vblank_cleanup(dev);
return ret;
}
void drm_vbl_send_signals(struct drm_device *dev, int crtc)
{
}
#if 0 /* disabled */
void drm_vbl_send_signals( drm_device_t *dev )
void drm_vbl_send_signals(struct drm_device *dev, int crtc )
{
drm_vbl_sig_t *vbl_sig;
unsigned int vbl_seq = atomic_read( &dev->vbl_received );
@ -318,7 +532,7 @@ void drm_vbl_send_signals( drm_device_t *dev )
static void drm_locked_task(void *context, int pending __unused)
{
drm_device_t *dev = context;
struct drm_device *dev = context;
DRM_LOCK();
for (;;) {
@ -352,7 +566,8 @@ static void drm_locked_task(void *context, int pending __unused)
}
void
drm_locked_tasklet(drm_device_t *dev, void (*tasklet)(drm_device_t *dev))
drm_locked_tasklet(struct drm_device *dev,
void (*tasklet)(struct drm_device *dev))
{
dev->locked_task_call = tasklet;
taskqueue_enqueue(taskqueue_swi, &dev->locked_task);

View file

@ -77,7 +77,7 @@ int drm_lock_take(__volatile__ unsigned int *lock, unsigned int context)
/* This takes a lock forcibly and hands it to context. Should ONLY be used
inside *_unlock to give lock to kernel before calling *_dma_schedule. */
int drm_lock_transfer(drm_device_t *dev,
int drm_lock_transfer(struct drm_device *dev,
__volatile__ unsigned int *lock, unsigned int context)
{
unsigned int old, new;
@ -91,7 +91,7 @@ int drm_lock_transfer(drm_device_t *dev,
return 1;
}
int drm_lock_free(drm_device_t *dev,
int drm_lock_free(struct drm_device *dev,
__volatile__ unsigned int *lock, unsigned int context)
{
unsigned int old, new;
@ -111,7 +111,7 @@ int drm_lock_free(drm_device_t *dev,
return 0;
}
int drm_lock(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
drm_lock_t *lock = data;
int ret = 0;
@ -164,7 +164,7 @@ int drm_lock(drm_device_t *dev, void *data, struct drm_file *file_priv)
return 0;
}
int drm_unlock(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
drm_lock_t *lock = data;

View file

@ -80,7 +80,7 @@ void drm_free(void *pt, size_t size, int area)
free(pt, M_DRM);
}
void *drm_ioremap(drm_device_t *dev, drm_local_map_t *map)
void *drm_ioremap(struct drm_device *dev, drm_local_map_t *map)
{
#ifdef __FreeBSD__
return pmap_mapdev(map->offset, map->size);

View file

@ -53,7 +53,8 @@ drm_pci_busdma_callback(void *arg, bus_dma_segment_t *segs, int nsegs, int error
* memory block.
*/
drm_dma_handle_t *
drm_pci_alloc(drm_device_t *dev, size_t size, size_t align, dma_addr_t maxaddr)
drm_pci_alloc(struct drm_device *dev, size_t size,
size_t align, dma_addr_t maxaddr)
{
drm_dma_handle_t *dmah;
int ret;
@ -123,7 +124,7 @@ drm_pci_alloc(drm_device_t *dev, size_t size, size_t align, dma_addr_t maxaddr)
* \brief Free a DMA-accessible consistent memory block.
*/
void
drm_pci_free(drm_device_t *dev, drm_dma_handle_t *dmah)
drm_pci_free(struct drm_device *dev, drm_dma_handle_t *dmah)
{
if (dmah == NULL)
return;

View file

@ -45,7 +45,7 @@ void drm_sg_cleanup(drm_sg_mem_t *entry)
free(entry, M_DRM);
}
int drm_sg_alloc(drm_device_t * dev, drm_scatter_gather_t * request)
int drm_sg_alloc(struct drm_device * dev, drm_scatter_gather_t * request)
{
drm_sg_mem_t *entry;
unsigned long pages;
@ -98,7 +98,8 @@ int drm_sg_alloc(drm_device_t * dev, drm_scatter_gather_t * request)
return 0;
}
int drm_sg_alloc_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_sg_alloc_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
drm_scatter_gather_t *request = data;
int ret;
@ -109,7 +110,7 @@ int drm_sg_alloc_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv
return ret;
}
int drm_sg_free(drm_device_t *dev, void *data, struct drm_file *file_priv)
int drm_sg_free(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
drm_scatter_gather_t *request = data;
drm_sg_mem_t *entry;

View file

@ -52,7 +52,7 @@ struct drm_sysctl_info {
char name[2];
};
int drm_sysctl_init(drm_device_t *dev)
int drm_sysctl_init(struct drm_device *dev)
{
struct drm_sysctl_info *info;
struct sysctl_oid *oid;
@ -106,7 +106,7 @@ int drm_sysctl_init(drm_device_t *dev)
return 0;
}
int drm_sysctl_cleanup(drm_device_t *dev)
int drm_sysctl_cleanup(struct drm_device *dev)
{
int error;
error = sysctl_ctx_free( &dev->sysctl->ctx );
@ -127,7 +127,7 @@ do { \
static int drm_name_info DRM_SYSCTL_HANDLER_ARGS
{
drm_device_t *dev = arg1;
struct drm_device *dev = arg1;
char buf[128];
int retcode;
int hasunique = 0;
@ -152,7 +152,7 @@ done:
static int drm_vm_info DRM_SYSCTL_HANDLER_ARGS
{
drm_device_t *dev = arg1;
struct drm_device *dev = arg1;
drm_local_map_t *map, *tempmaps;
const char *types[] = { "FB", "REG", "SHM", "AGP", "SG" };
const char *type, *yesno;
@ -211,7 +211,7 @@ done:
static int drm_bufs_info DRM_SYSCTL_HANDLER_ARGS
{
drm_device_t *dev = arg1;
struct drm_device *dev = arg1;
drm_device_dma_t *dma = dev->dma;
drm_device_dma_t tempdma;
int *templists;
@ -267,7 +267,7 @@ done:
static int drm_clients_info DRM_SYSCTL_HANDLER_ARGS
{
drm_device_t *dev = arg1;
struct drm_device *dev = arg1;
drm_file_t *priv, *tempprivs;
char buf[128];
int retcode;

View file

@ -37,7 +37,7 @@ int drm_mmap(dev_t kdev, vm_offset_t offset, int prot)
paddr_t drm_mmap(dev_t kdev, off_t offset, int prot)
#endif
{
drm_device_t *dev = drm_get_device_from_kdev(kdev);
struct drm_device *dev = drm_get_device_from_kdev(kdev);
drm_local_map_t *map;
drm_file_t *priv;
drm_map_type_t type;
@ -67,9 +67,9 @@ paddr_t drm_mmap(dev_t kdev, off_t offset, int prot)
unsigned long page = offset >> PAGE_SHIFT;
unsigned long phys = dma->pagelist[page];
DRM_SPINUNLOCK(&dev->dma_lock);
#if defined(__FreeBSD__) && __FreeBSD_version >= 500102
*paddr = phys;
DRM_SPINUNLOCK(&dev->dma_lock);
return 0;
#else
return atop(phys);
@ -78,7 +78,6 @@ paddr_t drm_mmap(dev_t kdev, off_t offset, int prot)
DRM_SPINUNLOCK(&dev->dma_lock);
return -1;
}
DRM_SPINUNLOCK(&dev->dma_lock);
}
/* A sequential search of a linked list is

View file

@ -40,15 +40,16 @@ static drm_pci_id_list_t i915_pciidlist[] = {
i915_PCI_IDS
};
static void i915_configure(drm_device_t *dev)
static void i915_configure(struct drm_device *dev)
{
dev->driver.buf_priv_size = 1; /* No dev_priv */
dev->driver.load = i915_driver_load;
dev->driver.preclose = i915_driver_preclose;
dev->driver.lastclose = i915_driver_lastclose;
dev->driver.device_is_agp = i915_driver_device_is_agp;
dev->driver.vblank_wait = i915_driver_vblank_wait;
dev->driver.vblank_wait2 = i915_driver_vblank_wait2;
dev->driver.get_vblank_counter = i915_get_vblank_counter;
dev->driver.enable_vblank = i915_enable_vblank;
dev->driver.disable_vblank = i915_disable_vblank;
dev->driver.irq_preinstall = i915_driver_irq_preinstall;
dev->driver.irq_postinstall = i915_driver_irq_postinstall;
dev->driver.irq_uninstall = i915_driver_irq_uninstall;
@ -82,9 +83,9 @@ i915_probe(device_t dev)
static int
i915_attach(device_t nbdev)
{
drm_device_t *dev = device_get_softc(nbdev);
struct drm_device *dev = device_get_softc(nbdev);
bzero(dev, sizeof(drm_device_t));
bzero(dev, sizeof(struct drm_device));
i915_configure(dev);
return drm_attach(nbdev, i915_pciidlist);
}
@ -105,7 +106,7 @@ static driver_t i915_driver = {
"drmsub",
#endif
i915_methods,
sizeof(drm_device_t)
sizeof(struct drm_device)
};
extern devclass_t drm_devclass;

View file

@ -44,11 +44,13 @@ static drm_pci_id_list_t mach64_pciidlist[] = {
mach64_PCI_IDS
};
static void mach64_configure(drm_device_t *dev)
static void mach64_configure(struct drm_device *dev)
{
dev->driver.buf_priv_size = 1; /* No dev_priv */
dev->driver.lastclose = mach64_driver_lastclose;
dev->driver.vblank_wait = mach64_driver_vblank_wait;
dev->driver.get_vblank_counter = mach64_get_vblank_counter;
dev->driver.enable_vblank = mach64_enable_vblank;
dev->driver.disable_vblank = mach64_disable_vblank;
dev->driver.irq_preinstall = mach64_driver_irq_preinstall;
dev->driver.irq_postinstall = mach64_driver_irq_postinstall;
dev->driver.irq_uninstall = mach64_driver_irq_uninstall;
@ -83,9 +85,9 @@ mach64_probe(device_t dev)
static int
mach64_attach(device_t nbdev)
{
drm_device_t *dev = device_get_softc(nbdev);
struct drm_device *dev = device_get_softc(nbdev);
bzero(dev, sizeof(drm_device_t));
bzero(dev, sizeof(struct drm_device));
mach64_configure(dev);
return drm_attach(nbdev, mach64_pciidlist);
}
@ -102,7 +104,7 @@ static device_method_t mach64_methods[] = {
static driver_t mach64_driver = {
"drm",
mach64_methods,
sizeof(drm_device_t)
sizeof(struct drm_device)
};
extern devclass_t drm_devclass;

View file

@ -59,7 +59,7 @@ static drm_pci_id_list_t mga_pciidlist[] = {
* This function needs to be filled in! The implementation in
* linux-core/mga_drv.c shows what needs to be done.
*/
static int mga_driver_device_is_agp(drm_device_t * dev)
static int mga_driver_device_is_agp(struct drm_device * dev)
{
device_t bus;
@ -84,13 +84,15 @@ static int mga_driver_device_is_agp(drm_device_t * dev)
return DRM_MIGHT_BE_AGP;
}
static void mga_configure(drm_device_t *dev)
static void mga_configure(struct drm_device *dev)
{
dev->driver.buf_priv_size = sizeof(drm_mga_buf_priv_t);
dev->driver.load = mga_driver_load;
dev->driver.unload = mga_driver_unload;
dev->driver.lastclose = mga_driver_lastclose;
dev->driver.vblank_wait = mga_driver_vblank_wait;
dev->driver.get_vblank_counter = mga_get_vblank_counter;
dev->driver.enable_vblank = mga_enable_vblank;
dev->driver.disable_vblank = mga_disable_vblank;
dev->driver.irq_preinstall = mga_driver_irq_preinstall;
dev->driver.irq_postinstall = mga_driver_irq_postinstall;
dev->driver.irq_uninstall = mga_driver_irq_uninstall;
@ -129,9 +131,9 @@ mga_probe(device_t dev)
static int
mga_attach(device_t nbdev)
{
drm_device_t *dev = device_get_softc(nbdev);
struct drm_device *dev = device_get_softc(nbdev);
bzero(dev, sizeof(drm_device_t));
bzero(dev, sizeof(struct drm_device));
mga_configure(dev);
return drm_attach(nbdev, mga_pciidlist);
}
@ -148,7 +150,7 @@ static device_method_t mga_methods[] = {
static driver_t mga_driver = {
"drm",
mga_methods,
sizeof(drm_device_t)
sizeof(struct drm_device)
};
extern devclass_t drm_devclass;
@ -163,7 +165,7 @@ MODULE_DEPEND(mga, drm, 1, 1, 1);
#ifdef _LKM
CFDRIVER_DECL(mga, DV_TTY, NULL);
#else
CFATTACH_DECL(mga, sizeof(drm_device_t), drm_probe, drm_attach, drm_detach,
CFATTACH_DECL(mga, sizeof(struct drm_device), drm_probe, drm_attach, drm_detach,
drm_activate);
#endif
#endif

View file

@ -42,12 +42,14 @@ static drm_pci_id_list_t r128_pciidlist[] = {
r128_PCI_IDS
};
static void r128_configure(drm_device_t *dev)
static void r128_configure(struct drm_device *dev)
{
dev->driver.buf_priv_size = sizeof(drm_r128_buf_priv_t);
dev->driver.preclose = r128_driver_preclose;
dev->driver.lastclose = r128_driver_lastclose;
dev->driver.vblank_wait = r128_driver_vblank_wait;
dev->driver.get_vblank_counter = r128_get_vblank_counter;
dev->driver.enable_vblank = r128_enable_vblank;
dev->driver.disable_vblank = r128_disable_vblank;
dev->driver.irq_preinstall = r128_driver_irq_preinstall;
dev->driver.irq_postinstall = r128_driver_irq_postinstall;
dev->driver.irq_uninstall = r128_driver_irq_uninstall;
@ -83,9 +85,9 @@ r128_probe(device_t dev)
static int
r128_attach(device_t nbdev)
{
drm_device_t *dev = device_get_softc(nbdev);
struct drm_device *dev = device_get_softc(nbdev);
bzero(dev, sizeof(drm_device_t));
bzero(dev, sizeof(struct drm_device));
r128_configure(dev);
return drm_attach(nbdev, r128_pciidlist);
}
@ -102,7 +104,7 @@ static device_method_t r128_methods[] = {
static driver_t r128_driver = {
"drm",
r128_methods,
sizeof(drm_device_t)
sizeof(struct drm_device)
};
extern devclass_t drm_devclass;
@ -117,7 +119,7 @@ MODULE_DEPEND(r128, drm, 1, 1, 1);
#ifdef _LKM
CFDRIVER_DECL(r128, DV_TTY, NULL);
#else
CFATTACH_DECL(r128, sizeof(drm_device_t), drm_probe, drm_attach, drm_detach,
drm_activate);
CFATTACH_DECL(r128, sizeof(struct drm_device), drm_probe, drm_attach,
drm_detach, drm_activate);
#endif
#endif

View file

@ -42,7 +42,7 @@ static drm_pci_id_list_t radeon_pciidlist[] = {
radeon_PCI_IDS
};
static void radeon_configure(drm_device_t *dev)
static void radeon_configure(struct drm_device *dev)
{
dev->driver.buf_priv_size = sizeof(drm_radeon_buf_priv_t);
dev->driver.load = radeon_driver_load;
@ -52,8 +52,9 @@ static void radeon_configure(drm_device_t *dev)
dev->driver.preclose = radeon_driver_preclose;
dev->driver.postclose = radeon_driver_postclose;
dev->driver.lastclose = radeon_driver_lastclose;
dev->driver.vblank_wait = radeon_driver_vblank_wait;
dev->driver.vblank_wait2 = radeon_driver_vblank_wait2;
dev->driver.get_vblank_counter = radeon_get_vblank_counter;
dev->driver.enable_vblank = radeon_enable_vblank;
dev->driver.disable_vblank = radeon_disable_vblank;
dev->driver.irq_preinstall = radeon_driver_irq_preinstall;
dev->driver.irq_postinstall = radeon_driver_irq_postinstall;
dev->driver.irq_uninstall = radeon_driver_irq_uninstall;
@ -90,9 +91,9 @@ radeon_probe(device_t dev)
static int
radeon_attach(device_t nbdev)
{
drm_device_t *dev = device_get_softc(nbdev);
struct drm_device *dev = device_get_softc(nbdev);
bzero(dev, sizeof(drm_device_t));
bzero(dev, sizeof(struct drm_device));
radeon_configure(dev);
return drm_attach(nbdev, radeon_pciidlist);
}
@ -109,7 +110,7 @@ static device_method_t radeon_methods[] = {
static driver_t radeon_driver = {
"drm",
radeon_methods,
sizeof(drm_device_t)
sizeof(struct drm_device)
};
extern devclass_t drm_devclass;
@ -124,7 +125,7 @@ MODULE_DEPEND(radeon, drm, 1, 1, 1);
#ifdef _LKM
CFDRIVER_DECL(radeon, DV_TTY, NULL);
#else
CFATTACH_DECL(radeon, sizeof(drm_device_t), drm_probe, drm_attach, drm_detach,
drm_activate);
CFATTACH_DECL(radeon, sizeof(struct drm_device), drm_probe, drm_attach,
drm_detach, drm_activate);
#endif
#endif /* __FreeBSD__ */

View file

@ -37,7 +37,7 @@ static drm_pci_id_list_t savage_pciidlist[] = {
savage_PCI_IDS
};
static void savage_configure(drm_device_t *dev)
static void savage_configure(struct drm_device *dev)
{
dev->driver.buf_priv_size = sizeof(drm_savage_buf_priv_t);
dev->driver.load = savage_driver_load;
@ -73,9 +73,9 @@ savage_probe(device_t dev)
static int
savage_attach(device_t nbdev)
{
drm_device_t *dev = device_get_softc(nbdev);
struct drm_device *dev = device_get_softc(nbdev);
bzero(dev, sizeof(drm_device_t));
bzero(dev, sizeof(struct drm_device));
savage_configure(dev);
return drm_attach(nbdev, savage_pciidlist);
}
@ -92,7 +92,7 @@ static device_method_t savage_methods[] = {
static driver_t savage_driver = {
"drm",
savage_methods,
sizeof(drm_device_t)
sizeof(struct drm_device)
};
extern devclass_t drm_devclass;

View file

@ -36,7 +36,7 @@ static drm_pci_id_list_t sis_pciidlist[] = {
sis_PCI_IDS
};
static void sis_configure(drm_device_t *dev)
static void sis_configure(struct drm_device *dev)
{
dev->driver.buf_priv_size = 1; /* No dev_priv */
dev->driver.context_ctor = sis_init_context;
@ -66,9 +66,9 @@ sis_probe(device_t dev)
static int
sis_attach(device_t nbdev)
{
drm_device_t *dev = device_get_softc(nbdev);
struct drm_device *dev = device_get_softc(nbdev);
bzero(dev, sizeof(drm_device_t));
bzero(dev, sizeof(struct drm_device));
sis_configure(dev);
return drm_attach(nbdev, sis_pciidlist);
}
@ -85,7 +85,7 @@ static device_method_t sis_methods[] = {
static driver_t sis_driver = {
"drm",
sis_methods,
sizeof(drm_device_t)
sizeof(struct drm_device)
};
extern devclass_t drm_devclass;
@ -100,7 +100,7 @@ MODULE_DEPEND(sisdrm, drm, 1, 1, 1);
#ifdef _LKM
CFDRIVER_DECL(sis, DV_TTY, NULL);
#else
CFATTACH_DECL(sis, sizeof(drm_device_t), drm_probe, drm_attach, drm_detach,
CFATTACH_DECL(sis, sizeof(struct drm_device), drm_probe, drm_attach, drm_detach,
drm_activate);
#endif
#endif

View file

@ -41,7 +41,7 @@ static drm_pci_id_list_t tdfx_pciidlist[] = {
tdfx_PCI_IDS
};
static void tdfx_configure(drm_device_t *dev)
static void tdfx_configure(struct drm_device *dev)
{
dev->driver.buf_priv_size = 1; /* No dev_priv */
@ -67,9 +67,9 @@ tdfx_probe(device_t dev)
static int
tdfx_attach(device_t nbdev)
{
drm_device_t *dev = device_get_softc(nbdev);
struct drm_device *dev = device_get_softc(nbdev);
bzero(dev, sizeof(drm_device_t));
bzero(dev, sizeof(struct drm_device));
tdfx_configure(dev);
return drm_attach(nbdev, tdfx_pciidlist);
}
@ -86,7 +86,7 @@ static device_method_t tdfx_methods[] = {
static driver_t tdfx_driver = {
"drm",
tdfx_methods,
sizeof(drm_device_t)
sizeof(struct drm_device)
};
extern devclass_t drm_devclass;
@ -101,7 +101,7 @@ MODULE_DEPEND(tdfx, drm, 1, 1, 1);
#ifdef _LKM
CFDRIVER_DECL(tdfx, DV_TTY, NULL);
#else
CFATTACH_DECL(tdfx, sizeof(drm_device_t), drm_probe, drm_attach, drm_detach,
drm_activate);
CFATTACH_DECL(tdfx, sizeof(struct drm_device), drm_probe, drm_attach,
drm_detach, drm_activate);
#endif
#endif

View file

@ -39,7 +39,7 @@ static drm_pci_id_list_t via_pciidlist[] = {
viadrv_PCI_IDS
};
static void via_configure(drm_device_t *dev)
static void via_configure(struct drm_device *dev)
{
dev->driver.buf_priv_size = 1;
dev->driver.load = via_driver_load;
@ -79,9 +79,9 @@ via_probe(device_t dev)
static int
via_attach(device_t nbdev)
{
drm_device_t *dev = device_get_softc(nbdev);
struct drm_device *dev = device_get_softc(nbdev);
bzero(dev, sizeof(drm_device_t));
bzero(dev, sizeof(struct drm_device));
via_configure(dev);
return drm_attach(nbdev, via_pciidlist);
}
@ -98,7 +98,7 @@ static device_method_t via_methods[] = {
static driver_t via_driver = {
"drm",
via_methods,
sizeof(drm_device_t)
sizeof(struct drm_device)
};
extern devclass_t drm_devclass;
@ -109,7 +109,7 @@ MODULE_DEPEND(via, drm, 1, 1, 1);
#ifdef _LKM
CFDRIVER_DECL(via, DV_TTY, NULL);
#else
CFATTACH_DECL(via, sizeof(drm_device_t), drm_probe, drm_attach, drm_detach,
CFATTACH_DECL(via, sizeof(struct drm_device), drm_probe, drm_attach, drm_detach,
drm_activate);
#endif
#endif

View file

@ -14,7 +14,7 @@ drm-objs := drm_auth.o drm_bufs.o drm_context.o drm_dma.o drm_drawable.o \
drm_memory_debug.o ati_pcigart.o drm_sman.o \
drm_hashtab.o drm_memrange.o drm_object.o drm_compat.o \
drm_fence.o drm_ttm.o drm_bo.o drm_bo_move.o drm_bo_lock.o \
drm_regman.o drm_gem.o
drm_regman.o drm_vm_nopage_compat.o drm_gem.o
tdfx-objs := tdfx_drv.o
r128-objs := r128_drv.o r128_cce.o r128_state.o r128_irq.o
mga-objs := mga_drv.o mga_dma.o mga_state.o mga_warp.o mga_irq.o

View file

@ -34,6 +34,11 @@
#include "drmP.h"
# define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */
# define ATI_PCIGART_PAGE_MASK (~(ATI_PCIGART_PAGE_SIZE-1))
#define ATI_PCIE_WRITE 0x4
#define ATI_PCIE_READ 0x8
static int drm_ati_alloc_pcigart_table(struct drm_device *dev,
struct drm_ati_pcigart_info *gart_info)
{
@ -103,6 +108,7 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga
dma_addr_t bus_address = 0;
int i, j, ret = 0;
int max_pages;
dma_addr_t entry_addr;
if (!entry) {
DRM_ERROR("no scatter/gather memory!\n");
@ -148,23 +154,27 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga
bus_address = 0;
goto done;
}
page_base = (u32) entry->busaddr[i];
entry_addr = entry->busaddr[i];
for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) {
page_base = (u32) entry_addr & ATI_PCIGART_PAGE_MASK;
switch(gart_info->gart_reg_if) {
case DRM_ATI_GART_IGP:
*pci_gart = cpu_to_le32((page_base) | 0xc);
page_base |= (upper_32_bits(entry_addr) & 0xff) << 4;
page_base |= 0xc;
break;
case DRM_ATI_GART_PCIE:
*pci_gart = cpu_to_le32((page_base >> 8) | 0xc);
page_base >>= 8;
page_base |= (upper_32_bits(entry_addr) & 0xff) << 24;
page_base |= ATI_PCIE_READ | ATI_PCIE_WRITE;
break;
default:
case DRM_ATI_GART_PCI:
*pci_gart = cpu_to_le32(page_base);
break;
}
*pci_gart = cpu_to_le32(page_base);
pci_gart++;
page_base += ATI_PCIGART_PAGE_SIZE;
entry_addr += ATI_PCIGART_PAGE_SIZE;
}
}

View file

@ -758,3 +758,4 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, enum km_type type,
EXPORT_SYMBOL(kmap_atomic_prot_pfn);
#endif

View file

@ -343,4 +343,23 @@ extern void *kmap_atomic_prot_pfn(unsigned long pfn, enum km_type type,
#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : (1ULL<<(n)) - 1)
#endif
#ifndef VM_CAN_NONLINEAR
#define DRM_VM_NOPAGE 1
#endif
#ifdef DRM_VM_NOPAGE
extern struct page *drm_vm_nopage(struct vm_area_struct *vma,
unsigned long address, int *type);
extern struct page *drm_vm_shm_nopage(struct vm_area_struct *vma,
unsigned long address, int *type);
extern struct page *drm_vm_dma_nopage(struct vm_area_struct *vma,
unsigned long address, int *type);
extern struct page *drm_vm_sg_nopage(struct vm_area_struct *vma,
unsigned long address, int *type);
#endif
#endif

View file

@ -376,7 +376,6 @@ int drm_release(struct inode *inode, struct file *filp)
struct drm_file *file_priv = filp->private_data;
struct drm_device *dev = file_priv->minor->dev;
int retcode = 0;
unsigned long irqflags;
lock_kernel();
@ -407,11 +406,9 @@ int drm_release(struct inode *inode, struct file *filp)
*/
do{
spin_lock_irqsave(&dev->lock.spinlock,
irqflags);
spin_lock_bh(&dev->lock.spinlock);
locked = dev->lock.idle_has_lock;
spin_unlock_irqrestore(&dev->lock.spinlock,
irqflags);
spin_unlock_bh(&dev->lock.spinlock);
if (locked)
break;
schedule();

View file

@ -437,7 +437,7 @@ int drm_modeset_ctl(struct drm_device *dev, void *data,
int crtc, ret = 0;
u32 new;
crtc = modeset->arg;
crtc = modeset->crtc;
if (crtc >= dev->num_crtcs) {
ret = -EINVAL;
goto out;

View file

@ -53,7 +53,6 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
DECLARE_WAITQUEUE(entry, current);
struct drm_lock *lock = data;
int ret = 0;
unsigned long irqflags;
++file_priv->lock_count;
@ -72,9 +71,9 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
return -EINVAL;
add_wait_queue(&dev->lock.lock_queue, &entry);
spin_lock_irqsave(&dev->lock.spinlock, irqflags);
spin_lock_bh(&dev->lock.spinlock);
dev->lock.user_waiters++;
spin_unlock_irqrestore(&dev->lock.spinlock, irqflags);
spin_unlock_bh(&dev->lock.spinlock);
for (;;) {
__set_current_state(TASK_INTERRUPTIBLE);
if (!dev->lock.hw_lock) {
@ -96,9 +95,9 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
break;
}
}
spin_lock_irqsave(&dev->lock.spinlock, irqflags);
spin_lock_bh(&dev->lock.spinlock);
dev->lock.user_waiters--;
spin_unlock_irqrestore(&dev->lock.spinlock, irqflags);
spin_unlock_bh(&dev->lock.spinlock);
__set_current_state(TASK_RUNNING);
remove_wait_queue(&dev->lock.lock_queue, &entry);
@ -199,9 +198,8 @@ int drm_lock_take(struct drm_lock_data *lock_data,
{
unsigned int old, new, prev;
volatile unsigned int *lock = &lock_data->hw_lock->lock;
unsigned long irqflags;
spin_lock_irqsave(&lock_data->spinlock, irqflags);
spin_lock_bh(&lock_data->spinlock);
do {
old = *lock;
if (old & _DRM_LOCK_HELD)
@ -213,7 +211,7 @@ int drm_lock_take(struct drm_lock_data *lock_data,
}
prev = cmpxchg(lock, old, new);
} while (prev != old);
spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
spin_unlock_bh(&lock_data->spinlock);
/* Warn on recursive locking of user contexts. */
if (_DRM_LOCKING_CONTEXT(old) == context && _DRM_LOCK_IS_HELD(old)) {
@ -269,16 +267,15 @@ int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context)
{
unsigned int old, new, prev;
volatile unsigned int *lock = &lock_data->hw_lock->lock;
unsigned long irqflags;
spin_lock_irqsave(&lock_data->spinlock, irqflags);
spin_lock_bh(&lock_data->spinlock);
if (lock_data->kernel_waiters != 0) {
drm_lock_transfer(lock_data, 0);
lock_data->idle_has_lock = 1;
spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
spin_unlock_bh(&lock_data->spinlock);
return 1;
}
spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
spin_unlock_bh(&lock_data->spinlock);
do {
old = *lock;
@ -342,20 +339,19 @@ static int drm_notifier(void *priv)
void drm_idlelock_take(struct drm_lock_data *lock_data)
{
int ret = 0;
unsigned long irqflags;
spin_lock_irqsave(&lock_data->spinlock, irqflags);
spin_lock_bh(&lock_data->spinlock);
lock_data->kernel_waiters++;
if (!lock_data->idle_has_lock) {
spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
spin_unlock_bh(&lock_data->spinlock);
ret = drm_lock_take(lock_data, DRM_KERNEL_CONTEXT);
spin_lock_irqsave(&lock_data->spinlock, irqflags);
spin_lock_bh(&lock_data->spinlock);
if (ret == 1)
lock_data->idle_has_lock = 1;
}
spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
spin_unlock_bh(&lock_data->spinlock);
}
EXPORT_SYMBOL(drm_idlelock_take);
@ -363,9 +359,8 @@ void drm_idlelock_release(struct drm_lock_data *lock_data)
{
unsigned int old, prev;
volatile unsigned int *lock = &lock_data->hw_lock->lock;
unsigned long irqflags;
spin_lock_irqsave(&lock_data->spinlock, irqflags);
spin_lock_bh(&lock_data->spinlock);
if (--lock_data->kernel_waiters == 0) {
if (lock_data->idle_has_lock) {
do {
@ -376,7 +371,7 @@ void drm_idlelock_release(struct drm_lock_data *lock_data)
lock_data->idle_has_lock = 0;
}
}
spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
spin_unlock_bh(&lock_data->spinlock);
}
EXPORT_SYMBOL(drm_idlelock_release);

View file

@ -81,8 +81,9 @@ static pgprot_t drm_dma_prot(uint32_t map_type, struct vm_area_struct *vma)
return tmp;
}
#ifndef DRM_VM_NOPAGE
/**
* \c nopage method for AGP virtual memory.
* \c fault method for AGP virtual memory.
*
* \param vma virtual memory area.
* \param address access address.
@ -92,8 +93,7 @@ static pgprot_t drm_dma_prot(uint32_t map_type, struct vm_area_struct *vma)
* map, get the page, increment the use count and return it.
*/
#if __OS_HAS_AGP
static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma,
unsigned long address)
static int drm_do_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
{
struct drm_file *priv = vma->vm_file->private_data;
struct drm_device *dev = priv->minor->dev;
@ -105,19 +105,24 @@ static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma,
* Find the right map
*/
if (!drm_core_has_AGP(dev))
goto vm_nopage_error;
goto vm_fault_error;
if (!dev->agp || !dev->agp->cant_use_aperture)
goto vm_nopage_error;
goto vm_fault_error;
if (drm_ht_find_item(&dev->map_hash, vma->vm_pgoff, &hash))
goto vm_nopage_error;
goto vm_fault_error;
r_list = drm_hash_entry(hash, struct drm_map_list, hash);
map = r_list->map;
if (map && map->type == _DRM_AGP) {
unsigned long offset = address - vma->vm_start;
/*
* Using vm_pgoff as a selector forces us to use this unusual
* addressing scheme.
*/
unsigned long offset = (unsigned long)vmf->virtual_address -
vma->vm_start;
unsigned long baddr = map->offset + offset;
struct drm_agp_mem *agpmem;
struct page *page;
@ -139,7 +144,7 @@ static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma,
}
if (!agpmem)
goto vm_nopage_error;
goto vm_fault_error;
/*
* Get the page, inc the use count, and return it
@ -147,25 +152,21 @@ static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma,
offset = (baddr - agpmem->bound) >> PAGE_SHIFT;
page = virt_to_page(__va(agpmem->memory->memory[offset]));
get_page(page);
vmf->page = page;
#if 0
/* page_count() not defined everywhere */
DRM_DEBUG
("baddr = 0x%lx page = 0x%p, offset = 0x%lx, count=%d\n",
baddr, __va(agpmem->memory->memory[offset]), offset,
page_count(page));
#endif
return page;
return 0;
}
vm_nopage_error:
return NOPAGE_SIGBUS; /* Disallow mremap */
vm_fault_error:
return VM_FAULT_SIGBUS; /* Disallow mremap */
}
#else /* __OS_HAS_AGP */
static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma,
unsigned long address)
static int drm_do_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
{
return NOPAGE_SIGBUS;
return VM_FAULT_SIGBUS;
}
#endif /* __OS_HAS_AGP */
@ -179,29 +180,28 @@ static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma,
* Get the mapping, find the real physical page to map, get the page, and
* return it.
*/
static __inline__ struct page *drm_do_vm_shm_nopage(struct vm_area_struct *vma,
unsigned long address)
static int drm_do_vm_shm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
{
struct drm_map *map = (struct drm_map *) vma->vm_private_data;
unsigned long offset;
unsigned long i;
struct page *page;
if (address > vma->vm_end)
return NOPAGE_SIGBUS; /* Disallow mremap */
if (!map)
return NOPAGE_SIGBUS; /* Nothing allocated */
return VM_FAULT_SIGBUS; /* Nothing allocated */
offset = address - vma->vm_start;
offset = (unsigned long)vmf->virtual_address - vma->vm_start;
i = (unsigned long)map->handle + offset;
page = vmalloc_to_page((void *)i);
if (!page)
return NOPAGE_SIGBUS;
return VM_FAULT_SIGBUS;
get_page(page);
vmf->page = page;
DRM_DEBUG("0x%lx\n", address);
return page;
DRM_DEBUG("shm_fault 0x%lx\n", offset);
return 0;
}
#endif
/**
* \c close method for shared virtual memory.
@ -283,8 +283,9 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
mutex_unlock(&dev->struct_mutex);
}
#ifndef DRM_VM_NOPAGE
/**
* \c nopage method for DMA virtual memory.
* \c fault method for DMA virtual memory.
*
* \param vma virtual memory area.
* \param address access address.
@ -292,8 +293,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
*
* Determine the page number from the page offset and get it from drm_device_dma::pagelist.
*/
static __inline__ struct page *drm_do_vm_dma_nopage(struct vm_area_struct *vma,
unsigned long address)
static int drm_do_vm_dma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
{
struct drm_file *priv = vma->vm_file->private_data;
struct drm_device *dev = priv->minor->dev;
@ -303,24 +303,23 @@ static __inline__ struct page *drm_do_vm_dma_nopage(struct vm_area_struct *vma,
struct page *page;
if (!dma)
return NOPAGE_SIGBUS; /* Error */
if (address > vma->vm_end)
return NOPAGE_SIGBUS; /* Disallow mremap */
return VM_FAULT_SIGBUS; /* Error */
if (!dma->pagelist)
return NOPAGE_SIGBUS; /* Nothing allocated */
return VM_FAULT_SIGBUS; /* Nothing allocated */
offset = address - vma->vm_start; /* vm_[pg]off[set] should be 0 */
page_nr = offset >> PAGE_SHIFT;
offset = (unsigned long)vmf->virtual_address - vma->vm_start; /* vm_[pg]off[set] should be 0 */
page_nr = offset >> PAGE_SHIFT; /* page_nr could just be vmf->pgoff */
page = virt_to_page((dma->pagelist[page_nr] + (offset & (~PAGE_MASK))));
get_page(page);
vmf->page = page;
DRM_DEBUG("0x%lx (page %lu)\n", address, page_nr);
return page;
DRM_DEBUG("dma_fault 0x%lx (page %lu)\n", offset, page_nr);
return 0;
}
/**
* \c nopage method for scatter-gather virtual memory.
* \c fault method for scatter-gather virtual memory.
*
* \param vma virtual memory area.
* \param address access address.
@ -328,8 +327,7 @@ static __inline__ struct page *drm_do_vm_dma_nopage(struct vm_area_struct *vma,
*
* Determine the map offset from the page offset and get it from drm_sg_mem::pagelist.
*/
static __inline__ struct page *drm_do_vm_sg_nopage(struct vm_area_struct *vma,
unsigned long address)
static int drm_do_vm_sg_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
{
struct drm_map *map = (struct drm_map *) vma->vm_private_data;
struct drm_file *priv = vma->vm_file->private_data;
@ -340,80 +338,62 @@ static __inline__ struct page *drm_do_vm_sg_nopage(struct vm_area_struct *vma,
unsigned long page_offset;
struct page *page;
DRM_DEBUG("\n");
if (!entry)
return NOPAGE_SIGBUS; /* Error */
if (address > vma->vm_end)
return NOPAGE_SIGBUS; /* Disallow mremap */
return VM_FAULT_SIGBUS; /* Error */
if (!entry->pagelist)
return NOPAGE_SIGBUS; /* Nothing allocated */
return VM_FAULT_SIGBUS; /* Nothing allocated */
offset = address - vma->vm_start;
offset = (unsigned long)vmf->virtual_address - vma->vm_start;
map_offset = map->offset - (unsigned long)dev->sg->virtual;
page_offset = (offset >> PAGE_SHIFT) + (map_offset >> PAGE_SHIFT);
page = entry->pagelist[page_offset];
get_page(page);
vmf->page = page;
return page;
return 0;
}
static struct page *drm_vm_nopage(struct vm_area_struct *vma,
unsigned long address, int *type)
{
if (type)
*type = VM_FAULT_MINOR;
return drm_do_vm_nopage(vma, address);
}
static struct page *drm_vm_shm_nopage(struct vm_area_struct *vma,
unsigned long address, int *type)
{
if (type)
*type = VM_FAULT_MINOR;
return drm_do_vm_shm_nopage(vma, address);
}
static struct page *drm_vm_dma_nopage(struct vm_area_struct *vma,
unsigned long address, int *type)
{
if (type)
*type = VM_FAULT_MINOR;
return drm_do_vm_dma_nopage(vma, address);
}
static struct page *drm_vm_sg_nopage(struct vm_area_struct *vma,
unsigned long address, int *type)
{
if (type)
*type = VM_FAULT_MINOR;
return drm_do_vm_sg_nopage(vma, address);
}
#endif
/** AGP virtual memory operations */
static struct vm_operations_struct drm_vm_ops = {
#ifdef DRM_VM_NOPAGE
.nopage = drm_vm_nopage,
#else
.fault = drm_do_vm_fault,
#endif
.open = drm_vm_open,
.close = drm_vm_close,
};
/** Shared virtual memory operations */
static struct vm_operations_struct drm_vm_shm_ops = {
#ifdef DRM_VM_NOPAGE
.nopage = drm_vm_shm_nopage,
#else
.fault = drm_do_vm_shm_fault,
#endif
.open = drm_vm_open,
.close = drm_vm_shm_close,
};
/** DMA virtual memory operations */
static struct vm_operations_struct drm_vm_dma_ops = {
#ifdef DRM_VM_NOPAGE
.nopage = drm_vm_dma_nopage,
#else
.fault = drm_do_vm_dma_fault,
#endif
.open = drm_vm_open,
.close = drm_vm_close,
};
/** Scatter-gather virtual memory operations */
static struct vm_operations_struct drm_vm_sg_ops = {
#ifdef DRM_VM_NOPAGE
.nopage = drm_vm_sg_nopage,
#else
.fault = drm_do_vm_sg_fault,
#endif
.open = drm_vm_open,
.close = drm_vm_close,
};
@ -751,6 +731,7 @@ static unsigned long drm_bo_vm_nopfn(struct vm_area_struct *vma,
err = drm_bo_wait(bo, 0, 1, 0, 1);
if (err) {
ret = (err != -EAGAIN) ? NOPFN_SIGBUS : NOPFN_REFAULT;
bo->priv_flags &= ~_DRM_BO_FLAG_UNLOCKED;
goto out_unlock;
}

View file

@ -0,0 +1,267 @@
/**
* \file drm_vm.c
* Memory mapping for DRM
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
* \author Gareth Hughes <gareth@valinux.com>
*/
/*
* Created: Mon Jan 4 08:58:31 1999 by faith@valinux.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* 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,
* and/or sell copies of the Software, and to permit persons to whom the
* 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
* VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* 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.
*/
#include "drmP.h"
#ifdef DRM_VM_NOPAGE
/**
* \c nopage method for AGP virtual memory.
*
* \param vma virtual memory area.
* \param address access address.
* \return pointer to the page structure.
*
* Find the right map and if it's AGP memory find the real physical page to
* map, get the page, increment the use count and return it.
*/
#if __OS_HAS_AGP
static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma,
unsigned long address)
{
struct drm_file *priv = vma->vm_file->private_data;
struct drm_device *dev = priv->minor->dev;
struct drm_map *map = NULL;
struct drm_map_list *r_list;
struct drm_hash_item *hash;
/*
* Find the right map
*/
if (!drm_core_has_AGP(dev))
goto vm_nopage_error;
if (!dev->agp || !dev->agp->cant_use_aperture)
goto vm_nopage_error;
if (drm_ht_find_item(&dev->map_hash, vma->vm_pgoff, &hash))
goto vm_nopage_error;
r_list = drm_hash_entry(hash, struct drm_map_list, hash);
map = r_list->map;
if (map && map->type == _DRM_AGP) {
unsigned long offset = address - vma->vm_start;
unsigned long baddr = map->offset + offset;
struct drm_agp_mem *agpmem;
struct page *page;
#ifdef __alpha__
/*
* Adjust to a bus-relative address
*/
baddr -= dev->hose->mem_space->start;
#endif
/*
* It's AGP memory - find the real physical page to map
*/
list_for_each_entry(agpmem, &dev->agp->memory, head) {
if (agpmem->bound <= baddr &&
agpmem->bound + agpmem->pages * PAGE_SIZE > baddr)
break;
}
if (!agpmem)
goto vm_nopage_error;
/*
* Get the page, inc the use count, and return it
*/
offset = (baddr - agpmem->bound) >> PAGE_SHIFT;
page = virt_to_page(__va(agpmem->memory->memory[offset]));
get_page(page);
#if 0
/* page_count() not defined everywhere */
DRM_DEBUG
("baddr = 0x%lx page = 0x%p, offset = 0x%lx, count=%d\n",
baddr, __va(agpmem->memory->memory[offset]), offset,
page_count(page));
#endif
return page;
}
vm_nopage_error:
return NOPAGE_SIGBUS; /* Disallow mremap */
}
#else /* __OS_HAS_AGP */
static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma,
unsigned long address)
{
return NOPAGE_SIGBUS;
}
#endif /* __OS_HAS_AGP */
/**
* \c nopage method for shared virtual memory.
*
* \param vma virtual memory area.
* \param address access address.
* \return pointer to the page structure.
*
* Get the mapping, find the real physical page to map, get the page, and
* return it.
*/
static __inline__ struct page *drm_do_vm_shm_nopage(struct vm_area_struct *vma,
unsigned long address)
{
struct drm_map *map = (struct drm_map *) vma->vm_private_data;
unsigned long offset;
unsigned long i;
struct page *page;
if (address > vma->vm_end)
return NOPAGE_SIGBUS; /* Disallow mremap */
if (!map)
return NOPAGE_SIGBUS; /* Nothing allocated */
offset = address - vma->vm_start;
i = (unsigned long)map->handle + offset;
page = vmalloc_to_page((void *)i);
if (!page)
return NOPAGE_SIGBUS;
get_page(page);
DRM_DEBUG("0x%lx\n", address);
return page;
}
/**
* \c nopage method for DMA virtual memory.
*
* \param vma virtual memory area.
* \param address access address.
* \return pointer to the page structure.
*
* Determine the page number from the page offset and get it from drm_device_dma::pagelist.
*/
static __inline__ struct page *drm_do_vm_dma_nopage(struct vm_area_struct *vma,
unsigned long address)
{
struct drm_file *priv = vma->vm_file->private_data;
struct drm_device *dev = priv->minor->dev;
struct drm_device_dma *dma = dev->dma;
unsigned long offset;
unsigned long page_nr;
struct page *page;
if (!dma)
return NOPAGE_SIGBUS; /* Error */
if (address > vma->vm_end)
return NOPAGE_SIGBUS; /* Disallow mremap */
if (!dma->pagelist)
return NOPAGE_SIGBUS; /* Nothing allocated */
offset = address - vma->vm_start; /* vm_[pg]off[set] should be 0 */
page_nr = offset >> PAGE_SHIFT;
page = virt_to_page((dma->pagelist[page_nr] + (offset & (~PAGE_MASK))));
get_page(page);
DRM_DEBUG("0x%lx (page %lu)\n", address, page_nr);
return page;
}
/**
* \c nopage method for scatter-gather virtual memory.
*
* \param vma virtual memory area.
* \param address access address.
* \return pointer to the page structure.
*
* Determine the map offset from the page offset and get it from drm_sg_mem::pagelist.
*/
static __inline__ struct page *drm_do_vm_sg_nopage(struct vm_area_struct *vma,
unsigned long address)
{
struct drm_map *map = (struct drm_map *) vma->vm_private_data;
struct drm_file *priv = vma->vm_file->private_data;
struct drm_device *dev = priv->minor->dev;
struct drm_sg_mem *entry = dev->sg;
unsigned long offset;
unsigned long map_offset;
unsigned long page_offset;
struct page *page;
DRM_DEBUG("\n");
if (!entry)
return NOPAGE_SIGBUS; /* Error */
if (address > vma->vm_end)
return NOPAGE_SIGBUS; /* Disallow mremap */
if (!entry->pagelist)
return NOPAGE_SIGBUS; /* Nothing allocated */
offset = address - vma->vm_start;
map_offset = map->offset - (unsigned long)dev->sg->virtual;
page_offset = (offset >> PAGE_SHIFT) + (map_offset >> PAGE_SHIFT);
page = entry->pagelist[page_offset];
get_page(page);
return page;
}
struct page *drm_vm_nopage(struct vm_area_struct *vma,
unsigned long address, int *type)
{
if (type)
*type = VM_FAULT_MINOR;
return drm_do_vm_nopage(vma, address);
}
struct page *drm_vm_shm_nopage(struct vm_area_struct *vma,
unsigned long address, int *type)
{
if (type)
*type = VM_FAULT_MINOR;
return drm_do_vm_shm_nopage(vma, address);
}
struct page *drm_vm_dma_nopage(struct vm_area_struct *vma,
unsigned long address, int *type)
{
if (type)
*type = VM_FAULT_MINOR;
return drm_do_vm_dma_nopage(vma, address);
}
struct page *drm_vm_sg_nopage(struct vm_area_struct *vma,
unsigned long address, int *type)
{
if (type)
*type = VM_FAULT_MINOR;
return drm_do_vm_sg_nopage(vma, address);
}
#endif

View file

@ -172,7 +172,7 @@ static void i915_save_vga(struct drm_device *dev)
i915_write_indexed(cr_index, cr_data, 0x11,
i915_read_indexed(cr_index, cr_data, 0x11) &
(~0x80));
for (i = 0; i < 0x24; i++)
for (i = 0; i <= 0x24; i++)
dev_priv->saveCR[i] =
i915_read_indexed(cr_index, cr_data, i);
/* Make sure we don't turn off CR group 0 writes */
@ -181,7 +181,7 @@ static void i915_save_vga(struct drm_device *dev)
/* Attribute controller registers */
inb(st01);
dev_priv->saveAR_INDEX = inb(VGA_AR_INDEX);
for (i = 0; i < 20; i++)
for (i = 0; i <= 0x14; i++)
dev_priv->saveAR[i] = i915_read_ar(st01, i, 0);
inb(st01);
outb(dev_priv->saveAR_INDEX, VGA_AR_INDEX);
@ -231,7 +231,7 @@ static void i915_restore_vga(struct drm_device *dev)
/* CRT controller regs */
/* Enable CR group 0 writes */
i915_write_indexed(cr_index, cr_data, 0x11, dev_priv->saveCR[0x11]);
for (i = 0; i < 0x24; i++)
for (i = 0; i <= 0x24; i++)
i915_write_indexed(cr_index, cr_data, i, dev_priv->saveCR[i]);
/* Graphics controller regs */
@ -248,7 +248,7 @@ static void i915_restore_vga(struct drm_device *dev)
/* Attribute controller registers */
inb(st01); /* switch back to index mode */
for (i = 0; i < 20; i++)
for (i = 0; i <= 0x14; i++)
i915_write_ar(st01, i, dev_priv->saveAR[i], 0);
inb(st01); /* switch back to index mode */
outb(dev_priv->saveAR_INDEX | 0x20, VGA_AR_INDEX);

View file

@ -0,0 +1 @@
../shared-core/radeon_microcode.h

View file

@ -555,10 +555,9 @@ union drm_wait_vblank {
struct drm_wait_vblank_reply reply;
};
enum drm_modeset_ctl_cmd {
_DRM_PRE_MODESET = 1,
_DRM_POST_MODESET = 2,
};
#define _DRM_PRE_MODESET 1
#define _DRM_POST_MODESET 2
/**
* DRM_IOCTL_MODESET_CTL ioctl argument type
@ -566,8 +565,8 @@ enum drm_modeset_ctl_cmd {
* \sa drmModesetCtl().
*/
struct drm_modeset_ctl {
unsigned long arg;
enum drm_modeset_ctl_cmd cmd;
uint32_t crtc;
uint32_t cmd;
};
/**

View file

@ -99,20 +99,18 @@
0x1002 0x5653 CHIP_RV410|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP "ATI Radeon Mobility X700 M26"
0x1002 0x5834 CHIP_RS300|RADEON_IS_IGP "ATI Radeon RS300 9100 IGP"
0x1002 0x5835 CHIP_RS300|RADEON_IS_IGP|RADEON_IS_MOBILITY "ATI Radeon RS300 Mobility IGP"
0x1002 0x5954 CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART "ATI RS480 XPRESS 200G"
0x1002 0x5955 CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART "ATI Radeon XPRESS 200M 5955"
0x1002 0x5974 CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART "ATI Radeon RS482 XPRESS 200"
0x1002 0x5975 CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART "ATI Radeon RS485 XPRESS 1100 IGP"
0x1002 0x5954 CHIP_RS480|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART "ATI RS480 XPRESS 200G"
0x1002 0x5955 CHIP_RS480|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART "ATI Radeon XPRESS 200M 5955"
0x1002 0x5974 CHIP_RS480|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART "ATI Radeon RS482 XPRESS 200"
0x1002 0x5975 CHIP_RS480|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART "ATI Radeon RS485 XPRESS 1100 IGP"
0x1002 0x5960 CHIP_RV280 "ATI Radeon RV280 9250"
0x1002 0x5961 CHIP_RV280 "ATI Radeon RV280 9200"
0x1002 0x5962 CHIP_RV280 "ATI Radeon RV280 9200"
0x1002 0x5964 CHIP_RV280 "ATI Radeon RV280 9200 SE"
0x1002 0x5965 CHIP_RV280 "ATI FireMV 2200 PCI"
0x1002 0x5969 CHIP_RV100 "ATI ES1000 RN50"
0x1002 0x5a41 CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART "ATI Radeon RS400 XPRESS 200"
0x1002 0x5a42 CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART "ATI Radeon RS400 XPRESS 200M"
0x1002 0x5a61 CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART "ATI Radeon RC410 XPRESS 200"
0x1002 0x5a62 CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART "ATI Radeon RC410 XPRESS 200M"
0x1002 0x5a61 CHIP_RS480|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART "ATI Radeon RC410 XPRESS 200"
0x1002 0x5a62 CHIP_RS480|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART "ATI Radeon RC410 XPRESS 200M"
0x1002 0x5b60 CHIP_RV380|RADEON_NEW_MEMMAP "ATI Radeon RV370 X300 SE"
0x1002 0x5b62 CHIP_RV380|RADEON_NEW_MEMMAP "ATI Radeon RV370 X600 Pro"
0x1002 0x5b63 CHIP_RV380|RADEON_NEW_MEMMAP "ATI Radeon RV370 X550"

View file

@ -138,7 +138,7 @@ static int i915_dma_cleanup(struct drm_device * dev)
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) \
@ -197,15 +197,16 @@ setup_dri2_sarea(struct drm_device * dev,
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");
@ -297,7 +298,7 @@ static int i915_initialize(struct drm_device * dev,
#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) {
@ -306,7 +307,7 @@ static int i915_initialize(struct drm_device * dev,
return ret;
}
}
#endif
return 0;
}
@ -832,7 +833,7 @@ static int i915_cmdbuffer(struct drm_device *dev, void *data,
return 0;
}
#if DRM_DEBUG_CODE
#if defined(DRM_DEBUG_CODE)
#define DRM_DEBUG_RELOCATION (drm_debug != 0)
#else
#define DRM_DEBUG_RELOCATION 0
@ -1130,7 +1131,7 @@ void i915_driver_lastclose(struct drm_device * dev)
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;
@ -1144,7 +1145,7 @@ void i915_driver_lastclose(struct drm_device * dev)
mutex_unlock(&dev->struct_mutex);
dev_priv->sarea_bo = NULL;
}
#endif
i915_dma_cleanup(dev);
}

View file

@ -389,6 +389,7 @@ struct drm_i915_op_arg {
uint64_t next;
uint64_t reloc_ptr;
int handled;
unsigned int pad64;
union {
struct drm_bo_op_req req;
struct drm_bo_arg_rep rep;

View file

@ -150,11 +150,11 @@ typedef struct drm_i915_private {
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
/* Register state */
u8 saveLBB;
u32 saveDSPACNTR;
@ -239,10 +239,10 @@ typedef struct drm_i915_private {
u8 saveSR[8];
u8 saveGR[25];
u8 saveAR_INDEX;
u8 saveAR[20];
u8 saveAR[21];
u8 saveDACMASK;
u8 saveDACDATA[256*3]; /* 256 3-byte colors */
u8 saveCR[36];
u8 saveCR[37];
struct {
struct drm_memrange gtt_space;
@ -748,7 +748,7 @@ extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
#define HEAD_WRAP_ONE 0x00200000
#define HEAD_ADDR 0x001FFFFC
#define RING_START 0x08
#define START_ADDR 0x0xFFFFF000
#define START_ADDR 0xFFFFF000
#define RING_LEN 0x0C
#define RING_NR_PAGES 0x001FF000
#define RING_REPORT_MASK 0x00000006

View file

@ -396,8 +396,7 @@ u32 i915_get_vblank_counter(struct drm_device *dev, int plane)
low_frame = pipe ? PIPEBFRAMEPIXEL : PIPEAFRAMEPIXEL;
if (!i915_pipe_enabled(dev, pipe)) {
printk(KERN_ERR "trying to get vblank count for disabled "
"pipe %d\n", pipe);
DRM_ERROR("trying to get vblank count for disabled pipe %d\n", pipe);
return 0;
}

View file

@ -71,8 +71,9 @@ nouveau_fifo_irq_handler(struct drm_device *dev)
{
struct drm_nouveau_private *dev_priv = dev->dev_private;
struct nouveau_engine *engine = &dev_priv->Engine;
uint32_t status;
uint32_t status, reassign;
reassign = NV_READ(NV03_PFIFO_CACHES) & 1;
while ((status = NV_READ(NV03_PFIFO_INTR_0))) {
uint32_t chid, get;
@ -119,9 +120,10 @@ nouveau_fifo_irq_handler(struct drm_device *dev)
if (status) {
DRM_INFO("Unhandled PFIFO_INTR - 0x%08x\n", status);
NV_WRITE(NV03_PFIFO_INTR_0, status);
NV_WRITE(NV03_PMC_INTR_EN_0, 0);
}
NV_WRITE(NV03_PFIFO_CACHES, 1);
NV_WRITE(NV03_PFIFO_CACHES, reassign);
}
NV_WRITE(NV03_PMC_INTR_0, NV_PMC_INTR_0_PFIFO_PENDING);
@ -188,6 +190,39 @@ nouveau_print_bitfield_names(uint32_t value,
printk(" (unknown bits 0x%08x)", value);
}
static int
nouveau_graph_chid_from_grctx(struct drm_device *dev)
{
struct drm_nouveau_private *dev_priv = dev->dev_private;
uint32_t inst;
int i;
if (dev_priv->card_type < NV_40)
return dev_priv->Engine.fifo.channels;
else
if (dev_priv->card_type < NV_50)
inst = (NV_READ(0x40032c) & 0xfffff) << 4;
else
inst = NV_READ(0x40032c) & 0xfffff;
for (i = 0; i < dev_priv->Engine.fifo.channels; i++) {
struct nouveau_channel *chan = dev_priv->fifos[i];
if (!chan || !chan->ramin_grctx)
continue;
if (dev_priv->card_type < NV_50) {
if (inst == chan->ramin_grctx->instance)
break;
} else {
if (inst == INSTANCE_RD(chan->ramin_grctx->gpuobj, 0))
break;
}
}
return i;
}
static int
nouveau_graph_trapped_channel(struct drm_device *dev, int *channel_ret)
{
@ -195,49 +230,15 @@ nouveau_graph_trapped_channel(struct drm_device *dev, int *channel_ret)
struct nouveau_engine *engine = &dev_priv->Engine;
int channel;
if (dev_priv->card_type < NV_10) {
if (dev_priv->card_type < NV_10)
channel = (NV_READ(NV04_PGRAPH_TRAPPED_ADDR) >> 24) & 0xf;
} else if (dev_priv->card_type < NV_40) {
else
if (dev_priv->card_type < NV_40)
channel = (NV_READ(NV04_PGRAPH_TRAPPED_ADDR) >> 20) & 0x1f;
} else
if (dev_priv->card_type < NV_50) {
uint32_t cur_grctx = (NV_READ(0x40032C) & 0xfffff) << 4;
else
channel = nouveau_graph_chid_from_grctx(dev);
/* 0x400704 *sometimes* contains a sensible channel ID, but
* mostly not.. for now lookup which channel owns the active
* PGRAPH context. Probably a better way, but this'll do
* for now.
*/
for (channel = 0; channel < 32; channel++) {
if (dev_priv->fifos[channel] == NULL)
continue;
if (cur_grctx ==
dev_priv->fifos[channel]->ramin_grctx->instance)
break;
}
if (channel == 32) {
DRM_ERROR("AIII, unable to determine active channel "
"from PGRAPH context 0x%08x\n", cur_grctx);
return -EINVAL;
}
} else {
uint32_t cur_grctx = (NV_READ(0x40032C) & 0xfffff) << 12;
for (channel = 0; channel < 128; channel++) {
if (dev_priv->fifos[channel] == NULL)
continue;
if (cur_grctx ==
dev_priv->fifos[channel]->ramin_grctx->instance)
break;
}
if (channel == 128) {
DRM_ERROR("AIII, unable to determine active channel "
"from PGRAPH context 0x%08x\n", cur_grctx);
return -EINVAL;
}
}
if (channel > engine->fifo.channels || !dev_priv->fifos[channel]) {
if (channel >= engine->fifo.channels || !dev_priv->fifos[channel]) {
DRM_ERROR("AIII, invalid/inactive channel id %d\n", channel);
return -EINVAL;
}
@ -251,6 +252,7 @@ struct nouveau_pgraph_trap {
int class;
int subc, mthd, size;
uint32_t data, data2;
uint32_t nsource, nstatus;
};
static void
@ -260,6 +262,12 @@ nouveau_graph_trap_info(struct drm_device *dev,
struct drm_nouveau_private *dev_priv = dev->dev_private;
uint32_t address;
trap->nsource = trap->nstatus = 0;
if (dev_priv->card_type < NV_50) {
trap->nsource = NV_READ(NV03_PGRAPH_NSOURCE);
trap->nstatus = NV_READ(NV03_PGRAPH_NSTATUS);
}
if (nouveau_graph_trapped_channel(dev, &trap->channel))
trap->channel = -1;
address = NV_READ(NV04_PGRAPH_TRAPPED_ADDR);
@ -289,10 +297,7 @@ nouveau_graph_dump_trap_info(struct drm_device *dev, const char *id,
struct nouveau_pgraph_trap *trap)
{
struct drm_nouveau_private *dev_priv = dev->dev_private;
uint32_t nsource, nstatus;
nsource = NV_READ(NV03_PGRAPH_NSOURCE);
nstatus = NV_READ(NV03_PGRAPH_NSTATUS);
uint32_t nsource = trap->nsource, nstatus = trap->nstatus;
DRM_INFO("%s - nSource:", id);
nouveau_print_bitfield_names(nsource, nouveau_nsource_names,
@ -347,6 +352,7 @@ nouveau_pgraph_intr_error(struct drm_device *dev, uint32_t nsource)
int unhandled = 0;
nouveau_graph_trap_info(dev, &trap);
trap.nsource = nsource;
if (nsource & NV03_PGRAPH_NSOURCE_ILLEGAL_MTHD) {
if (trap.channel >= 0 && trap.mthd == 0x0150) {
@ -432,6 +438,53 @@ nouveau_pgraph_irq_handler(struct drm_device *dev)
NV_WRITE(NV03_PMC_INTR_0, NV_PMC_INTR_0_PGRAPH_PENDING);
}
static void
nv50_pgraph_irq_handler(struct drm_device *dev)
{
struct drm_nouveau_private *dev_priv = dev->dev_private;
uint32_t status;
status = NV_READ(NV03_PGRAPH_INTR);
if (status & 0x00000020) {
nouveau_pgraph_intr_error(dev,
NV03_PGRAPH_NSOURCE_ILLEGAL_MTHD);
status &= ~0x00000020;
NV_WRITE(NV03_PGRAPH_INTR, 0x00000020);
}
if (status & 0x00100000) {
nouveau_pgraph_intr_error(dev,
NV03_PGRAPH_NSOURCE_DATA_ERROR);
status &= ~0x00100000;
NV_WRITE(NV03_PGRAPH_INTR, 0x00100000);
}
if (status & 0x00200000) {
nouveau_pgraph_intr_error(dev,
NV03_PGRAPH_NSOURCE_PROTECTION_ERROR);
status &= ~0x00200000;
NV_WRITE(NV03_PGRAPH_INTR, 0x00200000);
}
if (status) {
DRM_INFO("Unhandled PGRAPH_INTR - 0x%08x\n", status);
NV_WRITE(NV03_PGRAPH_INTR, status);
}
{
const int isb = (1 << 16) | (1 << 0);
if ((NV_READ(0x400500) & isb) != isb)
NV_WRITE(0x400500, NV_READ(0x400500) | isb);
}
NV_WRITE(NV03_PMC_INTR_0, NV_PMC_INTR_0_PGRAPH_PENDING);
}
static void
nouveau_crtc_irq_handler(struct drm_device *dev, int crtc)
{
@ -485,7 +538,11 @@ nouveau_irq_handler(DRM_IRQ_ARGS)
}
if (status & NV_PMC_INTR_0_PGRAPH_PENDING) {
nouveau_pgraph_irq_handler(dev);
if (dev_priv->card_type >= NV_50)
nv50_pgraph_irq_handler(dev);
else
nouveau_pgraph_irq_handler(dev);
status &= ~NV_PMC_INTR_0_PGRAPH_PENDING;
}

View file

@ -243,6 +243,7 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
break;
case 0x50:
case 0x80: /* gotta love NVIDIA's consistency.. */
case 0x90:
engine->instmem.init = nv50_instmem_init;
engine->instmem.takedown= nv50_instmem_takedown;
engine->instmem.populate = nv50_instmem_populate;
@ -614,7 +615,7 @@ int nouveau_ioctl_getparam(struct drm_device *dev, void *data, struct drm_file *
break;
case NOUVEAU_GETPARAM_PCI_PHYSICAL:
if ( dev -> sg )
getparam->value=(uint64_t) (uintptr_t) dev->sg->virtual;
getparam->value=(unsigned long)dev->sg->virtual;
else
{
DRM_ERROR("Requested PCIGART address, while no PCIGART was created\n");

File diff suppressed because it is too large Load diff

View file

@ -235,8 +235,14 @@ void r300_init_reg_flags(struct drm_device *dev)
ADD_RANGE(R300_VAP_INPUT_ROUTE_1_0, 8);
if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RV515) {
ADD_RANGE(R500_VAP_INDEX_OFFSET, 1);
ADD_RANGE(R500_US_CONFIG, 2);
ADD_RANGE(R500_US_CODE_ADDR, 3);
ADD_RANGE(R500_US_FC_CTRL, 1);
ADD_RANGE(R500_RS_IP_0, 16);
ADD_RANGE(R500_RS_INST_0, 16);
ADD_RANGE(R500_RB3D_COLOR_CLEAR_VALUE_AR, 2);
ADD_RANGE(R500_RB3D_CONSTANT_COLOR_AR, 2);
} else {
ADD_RANGE(R300_PFS_CNTL_0, 3);
ADD_RANGE(R300_PFS_NODE_0, 4);

View file

@ -1349,7 +1349,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* Guess by Vladimir.
* Set to 0A before 3D operations, set to 02 afterwards.
*/
#define R300_RB3D_DSTCACHE_CTLSTAT 0x4E4C
/*#define R300_RB3D_DSTCACHE_CTLSTAT 0x4E4C*/
# define R300_RB3D_DSTCACHE_UNKNOWN_02 0x00000002
# define R300_RB3D_DSTCACHE_UNKNOWN_0A 0x0000000A
@ -1626,12 +1626,22 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define R300_CP_CMD_BITBLT_MULTI 0xC0009B00
#define R500_VAP_INDEX_OFFSET 0x208c
#define R500_GA_US_VECTOR_INDEX 0x4250
#define R500_GA_US_VECTOR_DATA 0x4254
#define R500_RS_IP_0 0x4074
#define R500_RS_INST_0 0x4320
#define R500_US_CONFIG 0x4600
#define R500_US_FC_CTRL 0x4624
#define R500_US_CODE_ADDR 0x4630
#define R500_RB3D_COLOR_CLEAR_VALUE_AR 0x46c0
#define R500_RB3D_CONSTANT_COLOR_AR 0x4ef8
#endif /* _R300_REG_H */
/* *INDENT-ON* */

14275
shared-core/r600_microcode.h Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -676,6 +676,7 @@ typedef struct drm_radeon_indirect {
#define RADEON_PARAM_CARD_TYPE 12
#define RADEON_PARAM_VBLANK_CRTC 13 /* VBLANK CRTC */
#define RADEON_PARAM_FB_LOCATION 14 /* FB location */
#define RADEON_PARAM_NUM_GB_PIPES 15 /* num GB pipes */
typedef struct drm_radeon_getparam {
int param;

View file

@ -38,7 +38,7 @@
#define DRIVER_NAME "radeon"
#define DRIVER_DESC "ATI Radeon"
#define DRIVER_DATE "20060524"
#define DRIVER_DATE "20080528"
/* Interface history:
*
@ -98,10 +98,11 @@
* 1.26- Add support for variable size PCI(E) gart aperture
* 1.27- Add support for IGP GART
* 1.28- Add support for VBL on CRTC2
* 1.29- R500 3D cmd buffer support
*/
#define DRIVER_MAJOR 1
#define DRIVER_MINOR 28
#define DRIVER_MINOR 29
#define DRIVER_PATCHLEVEL 0
/*
@ -123,7 +124,7 @@ enum radeon_family {
CHIP_RV380,
CHIP_R420,
CHIP_RV410,
CHIP_RS400,
CHIP_RS480,
CHIP_RS690,
CHIP_RV515,
CHIP_R520,
@ -296,6 +297,7 @@ typedef struct drm_radeon_private {
int vblank_crtc;
uint32_t irq_enable_reg;
int irq_enabled;
uint32_t r500_disp_irq_reg;
struct radeon_surface surfaces[RADEON_MAX_SURFACES];
struct radeon_virt_surface virt_surfaces[2 * RADEON_MAX_SURFACES];
@ -313,6 +315,7 @@ typedef struct drm_radeon_private {
uint32_t flags; /* see radeon_chip_flags */
unsigned long fb_aper_offset;
int num_gb_pipes;
} drm_radeon_private_t;
typedef struct drm_radeon_buf_priv {
@ -379,7 +382,6 @@ extern void radeon_do_release(struct drm_device * dev);
extern u32 radeon_get_vblank_counter(struct drm_device *dev, int crtc);
extern int radeon_enable_vblank(struct drm_device *dev, int crtc);
extern void radeon_disable_vblank(struct drm_device *dev, int crtc);
extern void radeon_do_release(struct drm_device * dev);
extern irqreturn_t radeon_driver_irq_handler(DRM_IRQ_ARGS);
extern void radeon_driver_irq_preinstall(struct drm_device * dev);
extern int radeon_driver_irq_postinstall(struct drm_device * dev);
@ -448,13 +450,13 @@ extern int r300_do_cp_cmdbuf(struct drm_device *dev,
#define RADEON_PCIE_DATA 0x0034
#define RADEON_PCIE_TX_GART_CNTL 0x10
# define RADEON_PCIE_TX_GART_EN (1 << 0)
# define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_PASS_THRU (0<<1)
# define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_CLAMP_LO (1<<1)
# define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_DISCARD (3<<1)
# define RADEON_PCIE_TX_GART_MODE_32_128_CACHE (0<<3)
# define RADEON_PCIE_TX_GART_MODE_8_4_128_CACHE (1<<3)
# define RADEON_PCIE_TX_GART_CHK_RW_VALID_EN (1<<5)
# define RADEON_PCIE_TX_GART_INVALIDATE_TLB (1<<8)
# define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_PASS_THRU (0 << 1)
# define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_CLAMP_LO (1 << 1)
# define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_DISCARD (3 << 1)
# define RADEON_PCIE_TX_GART_MODE_32_128_CACHE (0 << 3)
# define RADEON_PCIE_TX_GART_MODE_8_4_128_CACHE (1 << 3)
# define RADEON_PCIE_TX_GART_CHK_RW_VALID_EN (1 << 5)
# define RADEON_PCIE_TX_GART_INVALIDATE_TLB (1 << 8)
#define RADEON_PCIE_TX_DISCARD_RD_ADDR_LO 0x11
#define RADEON_PCIE_TX_DISCARD_RD_ADDR_HI 0x12
#define RADEON_PCIE_TX_GART_BASE 0x13
@ -463,14 +465,9 @@ extern int r300_do_cp_cmdbuf(struct drm_device *dev,
#define RADEON_PCIE_TX_GART_END_LO 0x16
#define RADEON_PCIE_TX_GART_END_HI 0x17
#define RADEON_IGPGART_INDEX 0x168
#define RADEON_IGPGART_DATA 0x16c
#define RADEON_IGPGART_UNK_18 0x18
#define RADEON_IGPGART_CTRL 0x2b
#define RADEON_IGPGART_BASE_ADDR 0x2c
#define RADEON_IGPGART_FLUSH 0x2e
#define RADEON_IGPGART_ENABLE 0x38
#define RADEON_IGPGART_UNK_39 0x39
#define RS480_NB_MC_INDEX 0x168
# define RS480_NB_MC_IND_WR_EN (1 << 8)
#define RS480_NB_MC_DATA 0x16c
#define RS690_MC_INDEX 0x78
# define RS690_MC_INDEX_MASK 0x1ff
@ -478,46 +475,91 @@ extern int r300_do_cp_cmdbuf(struct drm_device *dev,
# define RS690_MC_INDEX_WR_ACK 0x7f
#define RS690_MC_DATA 0x7c
#define RS690_MC_MISC_CNTL 0x18
#define RS690_MC_GART_FEATURE_ID 0x2b
#define RS690_MC_GART_BASE 0x2c
#define RS690_MC_GART_CACHE_CNTL 0x2e
# define RS690_MC_GART_CC_NO_CHANGE 0x0
# define RS690_MC_GART_CC_CLEAR 0x1
# define RS690_MC_GART_CLEAR_STATUS (1 << 1)
# define RS690_MC_GART_CLEAR_DONE (0 << 1)
# define RS690_MC_GART_CLEAR_PENDING (1 << 1)
#define RS690_MC_AGP_SIZE 0x38
# define RS690_MC_GART_DIS 0x0
# define RS690_MC_GART_EN 0x1
# define RS690_MC_AGP_SIZE_32MB (0 << 1)
# define RS690_MC_AGP_SIZE_64MB (1 << 1)
# define RS690_MC_AGP_SIZE_128MB (2 << 1)
# define RS690_MC_AGP_SIZE_256MB (3 << 1)
# define RS690_MC_AGP_SIZE_512MB (4 << 1)
# define RS690_MC_AGP_SIZE_1GB (5 << 1)
# define RS690_MC_AGP_SIZE_2GB (6 << 1)
#define RS690_MC_AGP_MODE_CONTROL 0x39
/* MC indirect registers */
#define RS480_MC_MISC_CNTL 0x18
# define RS480_DISABLE_GTW (1 << 1)
/* switch between MCIND GART and MM GART registers. 0 = mmgart, 1 = mcind gart */
# define RS480_GART_INDEX_REG_EN (1 << 12)
# define RS690_BLOCK_GFX_D3_EN (1 << 14)
#define RS480_K8_FB_LOCATION 0x1e
#define RS480_GART_FEATURE_ID 0x2b
# define RS480_HANG_EN (1 << 11)
# define RS480_TLB_ENABLE (1 << 18)
# define RS480_P2P_ENABLE (1 << 19)
# define RS480_GTW_LAC_EN (1 << 25)
# define RS480_2LEVEL_GART (0 << 30)
# define RS480_1LEVEL_GART (1 << 30)
# define RS480_PDC_EN (1 << 31)
#define RS480_GART_BASE 0x2c
#define RS480_GART_CACHE_CNTRL 0x2e
# define RS480_GART_CACHE_INVALIDATE (1 << 0) /* wait for it to clear */
#define RS480_AGP_ADDRESS_SPACE_SIZE 0x38
# define RS480_GART_EN (1 << 0)
# define RS480_VA_SIZE_32MB (0 << 1)
# define RS480_VA_SIZE_64MB (1 << 1)
# define RS480_VA_SIZE_128MB (2 << 1)
# define RS480_VA_SIZE_256MB (3 << 1)
# define RS480_VA_SIZE_512MB (4 << 1)
# define RS480_VA_SIZE_1GB (5 << 1)
# define RS480_VA_SIZE_2GB (6 << 1)
#define RS480_AGP_MODE_CNTL 0x39
# define RS480_POST_GART_Q_SIZE (1 << 18)
# define RS480_NONGART_SNOOP (1 << 19)
# define RS480_AGP_RD_BUF_SIZE (1 << 20)
# define RS480_REQ_TYPE_SNOOP_SHIFT 22
# define RS480_REQ_TYPE_SNOOP_MASK 0x3
# define RS480_REQ_TYPE_SNOOP_DIS (1 << 24)
#define RS480_MC_MISC_UMA_CNTL 0x5f
#define RS480_MC_MCLK_CNTL 0x7a
#define RS480_MC_UMA_DUALCH_CNTL 0x86
#define RS690_MC_FB_LOCATION 0x100
#define RS690_MC_AGP_LOCATION 0x101
#define RS690_MC_AGP_BASE 0x102
#define RS690_MC_AGP_BASE_2 0x103
#define R520_MC_IND_INDEX 0x70
#define R520_MC_IND_WR_EN (1<<24)
#define R520_MC_IND_WR_EN (1 << 24)
#define R520_MC_IND_DATA 0x74
#define RV515_MC_FB_LOCATION 0x01
#define RV515_MC_AGP_LOCATION 0x02
#define RV515_MC_AGP_BASE 0x03
#define RV515_MC_AGP_BASE_2 0x04
#define R520_MC_FB_LOCATION 0x04
#define R520_MC_AGP_LOCATION 0x05
#define R520_MC_AGP_BASE 0x06
#define R520_MC_AGP_BASE_2 0x07
#define RADEON_MPP_TB_CONFIG 0x01c0
#define RADEON_MEM_CNTL 0x0140
#define RADEON_MEM_SDRAM_MODE_REG 0x0158
#define RADEON_AGP_BASE_2 0x015c /* r200+ only */
#define RS480_AGP_BASE_2 0x0164
#define RADEON_AGP_BASE 0x0170
/* pipe config regs */
#define R400_GB_PIPE_SELECT 0x402c
#define R500_DYN_SCLK_PWMEM_PIPE 0x000d /* PLL */
#define R500_SU_REG_DEST 0x42c8
#define R300_GB_TILE_CONFIG 0x4018
# define R300_ENABLE_TILING (1 << 0)
# define R300_PIPE_COUNT_RV350 (0 << 1)
# define R300_PIPE_COUNT_R300 (3 << 1)
# define R300_PIPE_COUNT_R420_3P (6 << 1)
# define R300_PIPE_COUNT_R420 (7 << 1)
# define R300_TILE_SIZE_8 (0 << 4)
# define R300_TILE_SIZE_16 (1 << 4)
# define R300_TILE_SIZE_32 (2 << 4)
# define R300_SUBPIXEL_1_12 (0 << 16)
# define R300_SUBPIXEL_1_16 (1 << 16)
#define R300_DST_PIPE_CONFIG 0x170c
# define R300_PIPE_AUTO_CONFIG (1 << 31)
#define R300_RB2D_DSTCACHE_MODE 0x3428
# define R300_DC_AUTOFLUSH_ENABLE (1 << 8)
# define R300_DC_DC_DISABLE_IGNORE_PE (1 << 17)
#define RADEON_RB3D_COLOROFFSET 0x1c40
#define RADEON_RB3D_COLORPITCH 0x1c48
@ -584,6 +626,8 @@ extern int r300_do_cp_cmdbuf(struct drm_device *dev,
# define RADEON_SW_INT_TEST (1 << 25)
# define RADEON_SW_INT_TEST_ACK (1 << 25)
# define RADEON_SW_INT_FIRE (1 << 26)
# define R500_DISPLAY_INT_STATUS (1 << 0)
#define RADEON_HOST_PATH_CNTL 0x0130
# define RADEON_HDP_SOFT_RESET (1 << 26)
@ -654,11 +698,18 @@ extern int r300_do_cp_cmdbuf(struct drm_device *dev,
# define RADEON_RB3D_ZC_FREE (1 << 2)
# define RADEON_RB3D_ZC_FLUSH_ALL 0x5
# define RADEON_RB3D_ZC_BUSY (1 << 31)
#define R300_ZB_ZCACHE_CTLSTAT 0x4f18
# define R300_ZC_FLUSH (1 << 0)
# define R300_ZC_FREE (1 << 1)
# define R300_ZC_FLUSH_ALL 0x3
# define R300_ZC_BUSY (1 << 31)
#define RADEON_RB3D_DSTCACHE_CTLSTAT 0x325c
# define RADEON_RB3D_DC_FLUSH (3 << 0)
# define RADEON_RB3D_DC_FREE (3 << 2)
# define RADEON_RB3D_DC_FLUSH_ALL 0xf
# define RADEON_RB3D_DC_BUSY (1 << 31)
#define R300_RB3D_DSTCACHE_CTLSTAT 0x4e4c
# define R300_RB3D_DC_FINISH (1 << 4)
#define RADEON_RB3D_ZSTENCILCNTL 0x1c2c
# define RADEON_Z_TEST_MASK (7 << 4)
# define RADEON_Z_TEST_ALWAYS (7 << 4)
@ -1096,7 +1147,30 @@ extern int r300_do_cp_cmdbuf(struct drm_device *dev,
#define RADEON_VHA_BACKFRAME0_OFF_V_2 0x1894
#define RADEON_VHA_BACKFRAME1_OFF_PITCH_V_2 0x1898
#define R500_D1CRTC_STATUS 0x609c
#define R500_D2CRTC_STATUS 0x689c
#define R500_CRTC_V_BLANK (1<<0)
#define R500_D1CRTC_FRAME_COUNT 0x60a4
#define R500_D2CRTC_FRAME_COUNT 0x68a4
#define R500_D1MODE_V_COUNTER 0x6530
#define R500_D2MODE_V_COUNTER 0x6d30
#define R500_D1MODE_VBLANK_STATUS 0x6534
#define R500_D2MODE_VBLANK_STATUS 0x6d34
#define R500_VBLANK_OCCURED (1<<0)
#define R500_VBLANK_ACK (1<<4)
#define R500_VBLANK_STAT (1<<12)
#define R500_VBLANK_INT (1<<16)
#define R500_DxMODE_INT_MASK 0x6540
#define R500_D1MODE_INT_MASK (1<<0)
#define R500_D2MODE_INT_MASK (1<<8)
#define R500_DISP_INTERRUPT_STATUS 0x7edc
#define R500_D1_VBLANK_INTERRUPT (1 << 4)
#define R500_D2_VBLANK_INTERRUPT (1 << 5)
/* Constants */
#define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */
@ -1126,14 +1200,6 @@ do { \
RADEON_WRITE( RADEON_CLOCK_CNTL_DATA, (val) ); \
} while (0)
#define RADEON_WRITE_IGPGART( addr, val ) \
do { \
RADEON_WRITE( RADEON_IGPGART_INDEX, \
((addr) & 0x7f) | (1 << 8)); \
RADEON_WRITE( RADEON_IGPGART_DATA, (val) ); \
RADEON_WRITE( RADEON_IGPGART_INDEX, 0x7f ); \
} while (0)
#define RADEON_WRITE_PCIE( addr, val ) \
do { \
RADEON_WRITE8( RADEON_PCIE_INDEX, \
@ -1141,12 +1207,20 @@ do { \
RADEON_WRITE( RADEON_PCIE_DATA, (val) ); \
} while (0)
#define RADEON_WRITE_MCIND( addr, val ) \
do { \
RADEON_WRITE(R520_MC_IND_INDEX, 0xff0000 | ((addr) & 0xff)); \
RADEON_WRITE(R520_MC_IND_DATA, (val)); \
RADEON_WRITE(R520_MC_IND_INDEX, 0); \
} while (0)
#define R500_WRITE_MCIND( addr, val ) \
do { \
RADEON_WRITE(R520_MC_IND_INDEX, 0xff0000 | ((addr) & 0xff)); \
RADEON_WRITE(R520_MC_IND_DATA, (val)); \
RADEON_WRITE(R520_MC_IND_INDEX, 0); \
} while (0)
#define RS480_WRITE_MCIND( addr, val ) \
do { \
RADEON_WRITE( RS480_NB_MC_INDEX, \
((addr) & 0xff) | RS480_NB_MC_IND_WR_EN); \
RADEON_WRITE( RS480_NB_MC_DATA, (val) ); \
RADEON_WRITE( RS480_NB_MC_INDEX, 0xff ); \
} while (0)
#define RS690_WRITE_MCIND( addr, val ) \
do { \
@ -1155,6 +1229,14 @@ do { \
RADEON_WRITE(RS690_MC_INDEX, RS690_MC_INDEX_WR_ACK); \
} while (0)
#define IGP_WRITE_MCIND( addr, val ) \
do { \
if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) \
RS690_WRITE_MCIND( addr, val ); \
else \
RS480_WRITE_MCIND( addr, val ); \
} while (0)
#define CP_PACKET0( reg, n ) \
(RADEON_CP_PACKET0 | ((n) << 16) | ((reg) >> 2))
#define CP_PACKET0_TABLE( reg, n ) \
@ -1195,23 +1277,43 @@ do { \
} while (0)
#define RADEON_FLUSH_CACHE() do { \
OUT_RING( CP_PACKET0( RADEON_RB3D_DSTCACHE_CTLSTAT, 0 ) ); \
OUT_RING( RADEON_RB3D_DC_FLUSH ); \
if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) { \
OUT_RING( CP_PACKET0( RADEON_RB3D_DSTCACHE_CTLSTAT, 0 ) ); \
OUT_RING( RADEON_RB3D_DC_FLUSH ); \
} else { \
OUT_RING( CP_PACKET0( R300_RB3D_DSTCACHE_CTLSTAT, 0 ) ); \
OUT_RING( RADEON_RB3D_DC_FLUSH ); \
} \
} while (0)
#define RADEON_PURGE_CACHE() do { \
OUT_RING( CP_PACKET0( RADEON_RB3D_DSTCACHE_CTLSTAT, 0 ) ); \
OUT_RING( RADEON_RB3D_DC_FLUSH_ALL ); \
if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) { \
OUT_RING( CP_PACKET0( RADEON_RB3D_DSTCACHE_CTLSTAT, 0 ) ); \
OUT_RING( RADEON_RB3D_DC_FLUSH_ALL ); \
} else { \
OUT_RING( CP_PACKET0( R300_RB3D_DSTCACHE_CTLSTAT, 0 ) ); \
OUT_RING( RADEON_RB3D_DC_FLUSH_ALL ); \
} \
} while (0)
#define RADEON_FLUSH_ZCACHE() do { \
OUT_RING( CP_PACKET0( RADEON_RB3D_ZCACHE_CTLSTAT, 0 ) ); \
OUT_RING( RADEON_RB3D_ZC_FLUSH ); \
if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) { \
OUT_RING( CP_PACKET0( RADEON_RB3D_ZCACHE_CTLSTAT, 0 ) ); \
OUT_RING( RADEON_RB3D_ZC_FLUSH ); \
} else { \
OUT_RING( CP_PACKET0( R300_ZB_ZCACHE_CTLSTAT, 0 ) ); \
OUT_RING( R300_ZC_FLUSH ); \
} \
} while (0)
#define RADEON_PURGE_ZCACHE() do { \
OUT_RING( CP_PACKET0( RADEON_RB3D_ZCACHE_CTLSTAT, 0 ) ); \
OUT_RING( RADEON_RB3D_ZC_FLUSH_ALL ); \
if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) { \
OUT_RING( CP_PACKET0( RADEON_RB3D_ZCACHE_CTLSTAT, 0 ) ); \
OUT_RING( RADEON_RB3D_ZC_FLUSH_ALL ); \
} else { \
OUT_RING( CP_PACKET0( R300_RB3D_DSTCACHE_CTLSTAT, 0 ) ); \
OUT_RING( R300_ZC_FLUSH_ALL ); \
} \
} while (0)
/* ================================================================

View file

@ -47,19 +47,48 @@ static void radeon_irq_set_state(struct drm_device *dev, u32 mask, int state)
RADEON_WRITE(RADEON_GEN_INT_CNTL, dev_priv->irq_enable_reg);
}
static void r500_vbl_irq_set_state(struct drm_device *dev, u32 mask, int state)
{
drm_radeon_private_t *dev_priv = dev->dev_private;
if (state)
dev_priv->r500_disp_irq_reg |= mask;
else
dev_priv->r500_disp_irq_reg &= ~mask;
RADEON_WRITE(R500_DxMODE_INT_MASK, dev_priv->r500_disp_irq_reg);
}
int radeon_enable_vblank(struct drm_device *dev, int crtc)
{
switch (crtc) {
case 0:
radeon_irq_set_state(dev, RADEON_CRTC_VBLANK_MASK, 1);
break;
case 1:
radeon_irq_set_state(dev, RADEON_CRTC2_VBLANK_MASK, 1);
break;
default:
DRM_ERROR("tried to enable vblank on non-existent crtc %d\n",
crtc);
return EINVAL;
drm_radeon_private_t *dev_priv = dev->dev_private;
if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS690) {
switch (crtc) {
case 0:
r500_vbl_irq_set_state(dev, R500_D1MODE_INT_MASK, 1);
break;
case 1:
r500_vbl_irq_set_state(dev, R500_D2MODE_INT_MASK, 1);
break;
default:
DRM_ERROR("tried to enable vblank on non-existent crtc %d\n",
crtc);
return EINVAL;
}
} else {
switch (crtc) {
case 0:
radeon_irq_set_state(dev, RADEON_CRTC_VBLANK_MASK, 1);
break;
case 1:
radeon_irq_set_state(dev, RADEON_CRTC2_VBLANK_MASK, 1);
break;
default:
DRM_ERROR("tried to enable vblank on non-existent crtc %d\n",
crtc);
return EINVAL;
}
}
return 0;
@ -67,29 +96,69 @@ int radeon_enable_vblank(struct drm_device *dev, int crtc)
void radeon_disable_vblank(struct drm_device *dev, int crtc)
{
switch (crtc) {
case 0:
radeon_irq_set_state(dev, RADEON_CRTC_VBLANK_MASK, 0);
break;
case 1:
radeon_irq_set_state(dev, RADEON_CRTC2_VBLANK_MASK, 0);
break;
default:
DRM_ERROR("tried to enable vblank on non-existent crtc %d\n",
crtc);
break;
drm_radeon_private_t *dev_priv = dev->dev_private;
if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS690) {
switch (crtc) {
case 0:
r500_vbl_irq_set_state(dev, R500_D1MODE_INT_MASK, 0);
break;
case 1:
r500_vbl_irq_set_state(dev, R500_D2MODE_INT_MASK, 0);
break;
default:
DRM_ERROR("tried to enable vblank on non-existent crtc %d\n",
crtc);
break;
}
} else {
switch (crtc) {
case 0:
radeon_irq_set_state(dev, RADEON_CRTC_VBLANK_MASK, 0);
break;
case 1:
radeon_irq_set_state(dev, RADEON_CRTC2_VBLANK_MASK, 0);
break;
default:
DRM_ERROR("tried to enable vblank on non-existent crtc %d\n",
crtc);
break;
}
}
}
static __inline__ u32 radeon_acknowledge_irqs(drm_radeon_private_t * dev_priv)
static __inline__ u32 radeon_acknowledge_irqs(drm_radeon_private_t * dev_priv, u32 *r500_disp_int)
{
u32 irqs = RADEON_READ(RADEON_GEN_INT_STATUS) &
(RADEON_SW_INT_TEST | RADEON_CRTC_VBLANK_STAT |
RADEON_CRTC2_VBLANK_STAT);
u32 irqs = RADEON_READ(RADEON_GEN_INT_STATUS);
u32 irq_mask = RADEON_SW_INT_TEST;
*r500_disp_int = 0;
if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS690) {
/* vbl interrupts in a different place */
if (irqs & R500_DISPLAY_INT_STATUS) {
/* if a display interrupt */
u32 disp_irq;
disp_irq = RADEON_READ(R500_DISP_INTERRUPT_STATUS);
*r500_disp_int = disp_irq;
if (disp_irq & R500_D1_VBLANK_INTERRUPT) {
RADEON_WRITE(R500_D1MODE_VBLANK_STATUS, R500_VBLANK_ACK);
}
if (disp_irq & R500_D2_VBLANK_INTERRUPT) {
RADEON_WRITE(R500_D2MODE_VBLANK_STATUS, R500_VBLANK_ACK);
}
}
irq_mask |= R500_DISPLAY_INT_STATUS;
} else
irq_mask |= RADEON_CRTC_VBLANK_STAT | RADEON_CRTC2_VBLANK_STAT;
irqs &= irq_mask;
if (irqs)
RADEON_WRITE(RADEON_GEN_INT_STATUS, irqs);
return irqs;
}
@ -117,11 +186,12 @@ irqreturn_t radeon_driver_irq_handler(DRM_IRQ_ARGS)
drm_radeon_private_t *dev_priv =
(drm_radeon_private_t *) dev->dev_private;
u32 stat;
u32 r500_disp_int;
/* Only consider the bits we're interested in - others could be used
* outside the DRM
*/
stat = radeon_acknowledge_irqs(dev_priv);
stat = radeon_acknowledge_irqs(dev_priv, &r500_disp_int);
if (!stat)
return IRQ_NONE;
@ -132,11 +202,17 @@ irqreturn_t radeon_driver_irq_handler(DRM_IRQ_ARGS)
DRM_WAKEUP(&dev_priv->swi_queue);
/* VBLANK interrupt */
if (stat & RADEON_CRTC_VBLANK_STAT)
drm_handle_vblank(dev, 0);
if (stat & RADEON_CRTC2_VBLANK_STAT)
drm_handle_vblank(dev, 1);
if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS690) {
if (r500_disp_int & R500_D1_VBLANK_INTERRUPT)
drm_handle_vblank(dev, 0);
if (r500_disp_int & R500_D2_VBLANK_INTERRUPT)
drm_handle_vblank(dev, 1);
} else {
if (stat & RADEON_CRTC_VBLANK_STAT)
drm_handle_vblank(dev, 0);
if (stat & RADEON_CRTC2_VBLANK_STAT)
drm_handle_vblank(dev, 1);
}
return IRQ_HANDLED;
}
@ -185,17 +261,29 @@ u32 radeon_get_vblank_counter(struct drm_device *dev, int crtc)
return -EINVAL;
}
if (crtc == 0) {
crtc_cnt_reg = RADEON_CRTC_CRNT_FRAME;
crtc_status_reg = RADEON_CRTC_STATUS;
} else if (crtc == 1) {
crtc_cnt_reg = RADEON_CRTC2_CRNT_FRAME;
crtc_status_reg = RADEON_CRTC2_STATUS;
if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS690) {
if (crtc == 0) {
crtc_cnt_reg = R500_D1CRTC_FRAME_COUNT;
crtc_status_reg = R500_D1CRTC_STATUS;
} else if (crtc == 1) {
crtc_cnt_reg = R500_D2CRTC_FRAME_COUNT;
crtc_status_reg = R500_D2CRTC_STATUS;
} else
return -EINVAL;
return RADEON_READ(crtc_cnt_reg) + (RADEON_READ(crtc_status_reg) & 1);
} else {
return -EINVAL;
if (crtc == 0) {
crtc_cnt_reg = RADEON_CRTC_CRNT_FRAME;
crtc_status_reg = RADEON_CRTC_STATUS;
} else if (crtc == 1) {
crtc_cnt_reg = RADEON_CRTC2_CRNT_FRAME;
crtc_status_reg = RADEON_CRTC2_STATUS;
} else {
return -EINVAL;
}
return RADEON_READ(crtc_cnt_reg) + (RADEON_READ(crtc_status_reg) & 1);
}
return RADEON_READ(crtc_cnt_reg) + (RADEON_READ(crtc_status_reg) & 1);
}
/* Needs the lock as it touches the ring.
@ -244,12 +332,15 @@ void radeon_driver_irq_preinstall(struct drm_device * dev)
{
drm_radeon_private_t *dev_priv =
(drm_radeon_private_t *) dev->dev_private;
u32 dummy;
/* Disable *all* interrupts */
if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS690)
RADEON_WRITE(R500_DxMODE_INT_MASK, 0);
RADEON_WRITE(RADEON_GEN_INT_CNTL, 0);
/* Clear bits if they're already high */
radeon_acknowledge_irqs(dev_priv);
radeon_acknowledge_irqs(dev_priv, &dummy);
}
int radeon_driver_irq_postinstall(struct drm_device * dev)
@ -281,6 +372,8 @@ void radeon_driver_irq_uninstall(struct drm_device * dev)
dev_priv->irq_enabled = 0;
if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS690)
RADEON_WRITE(R500_DxMODE_INT_MASK, 0);
/* Disable *all* interrupts */
RADEON_WRITE(RADEON_GEN_INT_CNTL, 0);
}
@ -292,14 +385,23 @@ int radeon_vblank_crtc_get(struct drm_device *dev)
u32 flag;
u32 value;
flag = RADEON_READ(RADEON_GEN_INT_CNTL);
value = 0;
if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS690) {
flag = RADEON_READ(R500_DxMODE_INT_MASK);
value = 0;
if (flag & R500_D1MODE_INT_MASK)
value |= DRM_RADEON_VBLANK_CRTC1;
if (flag & RADEON_CRTC_VBLANK_MASK)
value |= DRM_RADEON_VBLANK_CRTC1;
if (flag & R500_D2MODE_INT_MASK)
value |= DRM_RADEON_VBLANK_CRTC2;
} else {
flag = RADEON_READ(RADEON_GEN_INT_CNTL);
value = 0;
if (flag & RADEON_CRTC_VBLANK_MASK)
value |= DRM_RADEON_VBLANK_CRTC1;
if (flag & RADEON_CRTC2_VBLANK_MASK)
value |= DRM_RADEON_VBLANK_CRTC2;
if (flag & RADEON_CRTC2_VBLANK_MASK)
value |= DRM_RADEON_VBLANK_CRTC2;
}
return value;
}

File diff suppressed because it is too large Load diff

View file

@ -3091,6 +3091,9 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
case RADEON_PARAM_FB_LOCATION:
value = radeon_read_fb_location(dev_priv);
break;
case RADEON_PARAM_NUM_GB_PIPES:
value = dev_priv->num_gb_pipes;
break;
default:
DRM_DEBUG( "Invalid parameter %d\n", param->param );
return -EINVAL;