Commit 37ef4399 authored by Linus Torvalds's avatar Linus Torvalds
parents bf785ee0 9c7d462e
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
drm-objs := drm_auth.o drm_bufs.o drm_context.o drm_dma.o drm_drawable.o \ drm-objs := drm_auth.o drm_bufs.o drm_context.o drm_dma.o drm_drawable.o \
drm_drv.o drm_fops.o drm_init.o drm_ioctl.o drm_irq.o \ drm_drv.o drm_fops.o drm_ioctl.o drm_irq.o \
drm_lock.o drm_memory.o drm_proc.o drm_stub.o drm_vm.o \ drm_lock.o drm_memory.o drm_proc.o drm_stub.o drm_vm.o \
drm_agpsupport.o drm_scatter.o ati_pcigart.o drm_pci.o \ drm_agpsupport.o drm_scatter.o ati_pcigart.o drm_pci.o \
drm_sysfs.o drm_sysfs.o
...@@ -18,7 +18,7 @@ radeon-objs := radeon_drv.o radeon_cp.o radeon_state.o radeon_mem.o radeon_irq.o ...@@ -18,7 +18,7 @@ radeon-objs := radeon_drv.o radeon_cp.o radeon_state.o radeon_mem.o radeon_irq.o
ffb-objs := ffb_drv.o ffb_context.o ffb-objs := ffb_drv.o ffb_context.o
sis-objs := sis_drv.o sis_ds.o sis_mm.o sis-objs := sis_drv.o sis_ds.o sis_mm.o
savage-objs := savage_drv.o savage_bci.o savage_state.o savage-objs := savage_drv.o savage_bci.o savage_state.o
via-objs := via_irq.o via_drv.o via_ds.o via_map.o via_mm.o via_dma.o via_verifier.o via_video.o via-objs := via_irq.o via_drv.o via_ds.o via_map.o via_mm.o via_dma.o via_verifier.o via_video.o via_dmablit.o
ifeq ($(CONFIG_COMPAT),y) ifeq ($(CONFIG_COMPAT),y)
drm-objs += drm_ioc32.o drm-objs += drm_ioc32.o
......
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
# define ATI_MAX_PCIGART_PAGES 8192 /**< 32 MB aperture, 4K pages */ # define ATI_MAX_PCIGART_PAGES 8192 /**< 32 MB aperture, 4K pages */
# define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */ # define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */
static unsigned long drm_ati_alloc_pcigart_table(void) static void *drm_ati_alloc_pcigart_table(void)
{ {
unsigned long address; unsigned long address;
struct page *page; struct page *page;
...@@ -72,27 +72,26 @@ static unsigned long drm_ati_alloc_pcigart_table(void) ...@@ -72,27 +72,26 @@ static unsigned long drm_ati_alloc_pcigart_table(void)
} }
DRM_DEBUG("%s: returning 0x%08lx\n", __FUNCTION__, address); DRM_DEBUG("%s: returning 0x%08lx\n", __FUNCTION__, address);
return address; return (void *)address;
} }
static void drm_ati_free_pcigart_table(unsigned long address) static void drm_ati_free_pcigart_table(void *address)
{ {
struct page *page; struct page *page;
int i; int i;
DRM_DEBUG("%s\n", __FUNCTION__); DRM_DEBUG("%s\n", __FUNCTION__);
page = virt_to_page(address); page = virt_to_page((unsigned long)address);
for (i = 0; i < ATI_PCIGART_TABLE_PAGES; i++, page++) { for (i = 0; i < ATI_PCIGART_TABLE_PAGES; i++, page++) {
__put_page(page); __put_page(page);
ClearPageReserved(page); ClearPageReserved(page);
} }
free_pages(address, ATI_PCIGART_TABLE_ORDER); free_pages((unsigned long)address, ATI_PCIGART_TABLE_ORDER);
} }
int drm_ati_pcigart_cleanup(drm_device_t * dev, int drm_ati_pcigart_cleanup(drm_device_t *dev, drm_ati_pcigart_info *gart_info)
drm_ati_pcigart_info * gart_info)
{ {
drm_sg_mem_t *entry = dev->sg; drm_sg_mem_t *entry = dev->sg;
unsigned long pages; unsigned long pages;
...@@ -136,10 +135,10 @@ int drm_ati_pcigart_cleanup(drm_device_t * dev, ...@@ -136,10 +135,10 @@ int drm_ati_pcigart_cleanup(drm_device_t * dev,
EXPORT_SYMBOL(drm_ati_pcigart_cleanup); EXPORT_SYMBOL(drm_ati_pcigart_cleanup);
int drm_ati_pcigart_init(drm_device_t * dev, drm_ati_pcigart_info * gart_info) int drm_ati_pcigart_init(drm_device_t *dev, drm_ati_pcigart_info *gart_info)
{ {
drm_sg_mem_t *entry = dev->sg; drm_sg_mem_t *entry = dev->sg;
unsigned long address = 0; void *address = NULL;
unsigned long pages; unsigned long pages;
u32 *pci_gart, page_base, bus_address = 0; u32 *pci_gart, page_base, bus_address = 0;
int i, j, ret = 0; int i, j, ret = 0;
...@@ -163,7 +162,7 @@ int drm_ati_pcigart_init(drm_device_t * dev, drm_ati_pcigart_info * gart_info) ...@@ -163,7 +162,7 @@ int drm_ati_pcigart_init(drm_device_t * dev, drm_ati_pcigart_info * gart_info)
goto done; goto done;
} }
bus_address = pci_map_single(dev->pdev, (void *)address, bus_address = pci_map_single(dev->pdev, address,
ATI_PCIGART_TABLE_PAGES * ATI_PCIGART_TABLE_PAGES *
PAGE_SIZE, PCI_DMA_TODEVICE); PAGE_SIZE, PCI_DMA_TODEVICE);
if (bus_address == 0) { if (bus_address == 0) {
...@@ -176,7 +175,7 @@ int drm_ati_pcigart_init(drm_device_t * dev, drm_ati_pcigart_info * gart_info) ...@@ -176,7 +175,7 @@ int drm_ati_pcigart_init(drm_device_t * dev, drm_ati_pcigart_info * gart_info)
address = gart_info->addr; address = gart_info->addr;
bus_address = gart_info->bus_addr; bus_address = gart_info->bus_addr;
DRM_DEBUG("PCI: Gart Table: VRAM %08X mapped at %08lX\n", DRM_DEBUG("PCI: Gart Table: VRAM %08X mapped at %08lX\n",
bus_address, address); bus_address, (unsigned long)address);
} }
pci_gart = (u32 *) address; pci_gart = (u32 *) address;
...@@ -195,7 +194,7 @@ int drm_ati_pcigart_init(drm_device_t * dev, drm_ati_pcigart_info * gart_info) ...@@ -195,7 +194,7 @@ int drm_ati_pcigart_init(drm_device_t * dev, drm_ati_pcigart_info * gart_info)
if (entry->busaddr[i] == 0) { if (entry->busaddr[i] == 0) {
DRM_ERROR("unable to map PCIGART pages!\n"); DRM_ERROR("unable to map PCIGART pages!\n");
drm_ati_pcigart_cleanup(dev, gart_info); drm_ati_pcigart_cleanup(dev, gart_info);
address = 0; address = NULL;
bus_address = 0; bus_address = 0;
goto done; goto done;
} }
......
...@@ -90,8 +90,8 @@ ...@@ -90,8 +90,8 @@
#define DRM_MAX_ORDER 22 /**< Up to 2^22 bytes = 4MB */ #define DRM_MAX_ORDER 22 /**< Up to 2^22 bytes = 4MB */
#define DRM_RAM_PERCENT 10 /**< How much system ram can we lock? */ #define DRM_RAM_PERCENT 10 /**< How much system ram can we lock? */
#define _DRM_LOCK_HELD 0x80000000 /**< Hardware lock is held */ #define _DRM_LOCK_HELD 0x80000000U /**< Hardware lock is held */
#define _DRM_LOCK_CONT 0x40000000 /**< Hardware lock is contended */ #define _DRM_LOCK_CONT 0x40000000U /**< Hardware lock is contended */
#define _DRM_LOCK_IS_HELD(lock) ((lock) & _DRM_LOCK_HELD) #define _DRM_LOCK_IS_HELD(lock) ((lock) & _DRM_LOCK_HELD)
#define _DRM_LOCK_IS_CONT(lock) ((lock) & _DRM_LOCK_CONT) #define _DRM_LOCK_IS_CONT(lock) ((lock) & _DRM_LOCK_CONT)
#define _DRM_LOCKING_CONTEXT(lock) ((lock) & ~(_DRM_LOCK_HELD|_DRM_LOCK_CONT)) #define _DRM_LOCKING_CONTEXT(lock) ((lock) & ~(_DRM_LOCK_HELD|_DRM_LOCK_CONT))
......
...@@ -144,20 +144,6 @@ ...@@ -144,20 +144,6 @@
/** \name Backward compatibility section */ /** \name Backward compatibility section */
/*@{*/ /*@{*/
#ifndef MODULE_LICENSE
#define MODULE_LICENSE(x)
#endif
#ifndef preempt_disable
#define preempt_disable()
#define preempt_enable()
#endif
#ifndef pte_offset_map
#define pte_offset_map pte_offset
#define pte_unmap(pte)
#endif
#define DRM_RPR_ARG(vma) vma, #define DRM_RPR_ARG(vma) vma,
#define VM_OFFSET(vma) ((vma)->vm_pgoff << PAGE_SHIFT) #define VM_OFFSET(vma) ((vma)->vm_pgoff << PAGE_SHIFT)
...@@ -286,10 +272,13 @@ typedef int drm_ioctl_t(struct inode *inode, struct file *filp, ...@@ -286,10 +272,13 @@ typedef int drm_ioctl_t(struct inode *inode, struct file *filp,
typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd, typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
unsigned long arg); unsigned long arg);
#define DRM_AUTH 0x1
#define DRM_MASTER 0x2
#define DRM_ROOT_ONLY 0x4
typedef struct drm_ioctl_desc { typedef struct drm_ioctl_desc {
drm_ioctl_t *func; drm_ioctl_t *func;
int auth_needed; int flags;
int root_only;
} drm_ioctl_desc_t; } drm_ioctl_desc_t;
typedef struct drm_devstate { typedef struct drm_devstate {
...@@ -384,6 +373,7 @@ typedef struct drm_buf_entry { ...@@ -384,6 +373,7 @@ typedef struct drm_buf_entry {
/** File private data */ /** File private data */
typedef struct drm_file { typedef struct drm_file {
int authenticated; int authenticated;
int master;
int minor; int minor;
pid_t pid; pid_t pid;
uid_t uid; uid_t uid;
...@@ -532,8 +522,9 @@ typedef struct drm_vbl_sig { ...@@ -532,8 +522,9 @@ typedef struct drm_vbl_sig {
typedef struct ati_pcigart_info { typedef struct ati_pcigart_info {
int gart_table_location; int gart_table_location;
int is_pcie; int is_pcie;
unsigned long addr; void *addr;
dma_addr_t bus_addr; dma_addr_t bus_addr;
drm_local_map_t mapping;
} drm_ati_pcigart_info; } drm_ati_pcigart_info;
/** /**
...@@ -544,16 +535,14 @@ typedef struct ati_pcigart_info { ...@@ -544,16 +535,14 @@ typedef struct ati_pcigart_info {
struct drm_device; struct drm_device;
struct drm_driver { struct drm_driver {
int (*preinit) (struct drm_device *, unsigned long flags); int (*load) (struct drm_device *, unsigned long flags);
void (*prerelease) (struct drm_device *, struct file * filp); int (*firstopen) (struct drm_device *);
void (*pretakedown) (struct drm_device *); int (*open) (struct drm_device *, drm_file_t *);
int (*postcleanup) (struct drm_device *); void (*preclose) (struct drm_device *, struct file * filp);
int (*presetup) (struct drm_device *); void (*postclose) (struct drm_device *, drm_file_t *);
int (*postsetup) (struct drm_device *); void (*lastclose) (struct drm_device *);
int (*unload) (struct drm_device *);
int (*dma_ioctl) (DRM_IOCTL_ARGS); int (*dma_ioctl) (DRM_IOCTL_ARGS);
int (*open_helper) (struct drm_device *, drm_file_t *);
void (*free_filp_priv) (struct drm_device *, drm_file_t *);
void (*release) (struct drm_device *, struct file * filp);
void (*dma_ready) (struct drm_device *); void (*dma_ready) (struct drm_device *);
int (*dma_quiescent) (struct drm_device *); int (*dma_quiescent) (struct drm_device *);
int (*context_ctor) (struct drm_device * dev, int context); int (*context_ctor) (struct drm_device * dev, int context);
...@@ -561,8 +550,9 @@ struct drm_driver { ...@@ -561,8 +550,9 @@ struct drm_driver {
int (*kernel_context_switch) (struct drm_device * dev, int old, int (*kernel_context_switch) (struct drm_device * dev, int old,
int new); int new);
void (*kernel_context_switch_unlock) (struct drm_device * dev, void (*kernel_context_switch_unlock) (struct drm_device * dev,
drm_lock_t * lock); drm_lock_t *lock);
int (*vblank_wait) (struct drm_device * dev, unsigned int *sequence); int (*vblank_wait) (struct drm_device * dev, unsigned int *sequence);
int (*dri_library_name) (struct drm_device *dev, char *buf);
/** /**
* Called by \c drm_device_is_agp. Typically used to determine if a * Called by \c drm_device_is_agp. Typically used to determine if a
...@@ -579,16 +569,24 @@ struct drm_driver { ...@@ -579,16 +569,24 @@ struct drm_driver {
/* these have to be filled in */ /* these have to be filled in */
int (*postinit) (struct drm_device *, unsigned long flags);
irqreturn_t(*irq_handler) (DRM_IRQ_ARGS); irqreturn_t(*irq_handler) (DRM_IRQ_ARGS);
void (*irq_preinstall) (struct drm_device * dev); void (*irq_preinstall) (struct drm_device * dev);
void (*irq_postinstall) (struct drm_device * dev); void (*irq_postinstall) (struct drm_device * dev);
void (*irq_uninstall) (struct drm_device * dev); void (*irq_uninstall) (struct drm_device * dev);
void (*reclaim_buffers) (struct drm_device * dev, struct file * filp); void (*reclaim_buffers) (struct drm_device * dev, struct file * filp);
void (*reclaim_buffers_locked) (struct drm_device *dev,
struct file *filp);
unsigned long (*get_map_ofs) (drm_map_t * map); unsigned long (*get_map_ofs) (drm_map_t * map);
unsigned long (*get_reg_ofs) (struct drm_device * dev); unsigned long (*get_reg_ofs) (struct drm_device * dev);
void (*set_version) (struct drm_device * dev, drm_set_version_t * sv); void (*set_version) (struct drm_device * dev, drm_set_version_t * sv);
int (*version) (drm_version_t * version);
int major;
int minor;
int patchlevel;
char *name;
char *desc;
char *date;
u32 driver_features; u32 driver_features;
int dev_priv_size; int dev_priv_size;
drm_ioctl_desc_t *ioctls; drm_ioctl_desc_t *ioctls;
...@@ -752,19 +750,43 @@ static inline int drm_core_has_MTRR(struct drm_device *dev) ...@@ -752,19 +750,43 @@ static inline int drm_core_has_MTRR(struct drm_device *dev)
{ {
return drm_core_check_feature(dev, DRIVER_USE_MTRR); return drm_core_check_feature(dev, DRIVER_USE_MTRR);
} }
#define DRM_MTRR_WC MTRR_TYPE_WRCOMB
static inline int drm_mtrr_add(unsigned long offset, unsigned long size,
unsigned int flags)
{
return mtrr_add(offset, size, flags, 1);
}
static inline int drm_mtrr_del(int handle, unsigned long offset,
unsigned long size, unsigned int flags)
{
return mtrr_del(handle, offset, size);
}
#else #else
#define drm_core_has_MTRR(dev) (0) #define drm_core_has_MTRR(dev) (0)
#define DRM_MTRR_WC 0
static inline int drm_mtrr_add(unsigned long offset, unsigned long size,
unsigned int flags)
{
return 0;
}
static inline int drm_mtrr_del(int handle, unsigned long offset,
unsigned long size, unsigned int flags)
{
return 0;
}
#endif #endif
/******************************************************************/ /******************************************************************/
/** \name Internal function definitions */ /** \name Internal function definitions */
/*@{*/ /*@{*/
/* Misc. support (drm_init.h) */
extern int drm_flags;
extern void drm_parse_options(char *s);
extern int drm_cpu_valid(void);
/* Driver support (drm_drv.h) */ /* Driver support (drm_drv.h) */
extern int drm_init(struct drm_driver *driver); extern int drm_init(struct drm_driver *driver);
extern void drm_exit(struct drm_driver *driver); extern void drm_exit(struct drm_driver *driver);
...@@ -772,12 +794,11 @@ extern int drm_ioctl(struct inode *inode, struct file *filp, ...@@ -772,12 +794,11 @@ extern int drm_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern long drm_compat_ioctl(struct file *filp, extern long drm_compat_ioctl(struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern int drm_takedown(drm_device_t * dev); extern int drm_lastclose(drm_device_t *dev);
/* Device support (drm_fops.h) */ /* Device support (drm_fops.h) */
extern int drm_open(struct inode *inode, struct file *filp); extern int drm_open(struct inode *inode, struct file *filp);
extern int drm_stub_open(struct inode *inode, struct file *filp); extern int drm_stub_open(struct inode *inode, struct file *filp);
extern int drm_flush(struct file *filp);
extern int drm_fasync(int fd, struct file *filp, int on); extern int drm_fasync(int fd, struct file *filp, int on);
extern int drm_release(struct inode *inode, struct file *filp); extern int drm_release(struct inode *inode, struct file *filp);
...@@ -819,6 +840,8 @@ extern int drm_getstats(struct inode *inode, struct file *filp, ...@@ -819,6 +840,8 @@ extern int drm_getstats(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern int drm_setversion(struct inode *inode, struct file *filp, extern int drm_setversion(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern int drm_noop(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
/* Context IOCTL support (drm_context.h) */ /* Context IOCTL support (drm_context.h) */
extern int drm_resctx(struct inode *inode, struct file *filp, extern int drm_resctx(struct inode *inode, struct file *filp,
...@@ -855,10 +878,6 @@ extern int drm_rmdraw(struct inode *inode, struct file *filp, ...@@ -855,10 +878,6 @@ extern int drm_rmdraw(struct inode *inode, struct file *filp,
extern int drm_getmagic(struct inode *inode, struct file *filp, extern int drm_getmagic(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern int drm_authmagic(struct inode *inode, struct file *filp, extern int drm_authmagic(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
/* Placeholder for ioctls past */
extern int drm_noop(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
/* Locking IOCTL support (drm_lock.h) */ /* Locking IOCTL support (drm_lock.h) */
...@@ -873,6 +892,7 @@ extern int drm_lock_free(drm_device_t * dev, ...@@ -873,6 +892,7 @@ extern int drm_lock_free(drm_device_t * dev,
/* Buffer management support (drm_bufs.h) */ /* Buffer management support (drm_bufs.h) */
extern int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request); extern int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request);
extern int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request); extern int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request);
extern int drm_addbufs_fb(drm_device_t *dev, drm_buf_desc_t *request);
extern int drm_addmap(drm_device_t * dev, unsigned int offset, extern int drm_addmap(drm_device_t * dev, unsigned int offset,
unsigned int size, drm_map_type_t type, unsigned int size, drm_map_type_t type,
drm_map_flags_t flags, drm_local_map_t ** map_ptr); drm_map_flags_t flags, drm_local_map_t ** map_ptr);
...@@ -908,8 +928,8 @@ extern void drm_core_reclaim_buffers(drm_device_t * dev, struct file *filp); ...@@ -908,8 +928,8 @@ extern void drm_core_reclaim_buffers(drm_device_t * dev, struct file *filp);
/* IRQ support (drm_irq.h) */ /* IRQ support (drm_irq.h) */
extern int drm_control(struct inode *inode, struct file *filp, extern int drm_control(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern int drm_irq_uninstall(drm_device_t * dev);
extern irqreturn_t drm_irq_handler(DRM_IRQ_ARGS); extern irqreturn_t drm_irq_handler(DRM_IRQ_ARGS);
extern int drm_irq_uninstall(drm_device_t * dev);
extern void drm_driver_irq_preinstall(drm_device_t * dev); extern void drm_driver_irq_preinstall(drm_device_t * dev);
extern void drm_driver_irq_postinstall(drm_device_t * dev); extern void drm_driver_irq_postinstall(drm_device_t * dev);
extern void drm_driver_irq_uninstall(drm_device_t * dev); extern void drm_driver_irq_uninstall(drm_device_t * dev);
...@@ -933,13 +953,17 @@ extern int drm_agp_enable_ioctl(struct inode *inode, struct file *filp, ...@@ -933,13 +953,17 @@ extern int drm_agp_enable_ioctl(struct inode *inode, struct file *filp,
extern int drm_agp_info(drm_device_t * dev, drm_agp_info_t * info); extern int drm_agp_info(drm_device_t * dev, drm_agp_info_t * info);
extern int drm_agp_info_ioctl(struct inode *inode, struct file *filp, extern int drm_agp_info_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern int drm_agp_alloc(struct inode *inode, struct file *filp, extern int drm_agp_alloc(drm_device_t *dev, drm_agp_buffer_t *request);
extern int drm_agp_alloc_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern int drm_agp_free(struct inode *inode, struct file *filp, extern int drm_agp_free(drm_device_t *dev, drm_agp_buffer_t *request);
extern int drm_agp_free_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern int drm_agp_unbind(struct inode *inode, struct file *filp, extern int drm_agp_unbind(drm_device_t *dev, drm_agp_binding_t *request);
extern int drm_agp_unbind_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern int drm_agp_bind(struct inode *inode, struct file *filp, extern int drm_agp_bind(drm_device_t *dev, drm_agp_binding_t *request);
extern int drm_agp_bind_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern DRM_AGP_MEM *drm_agp_allocate_memory(struct agp_bridge_data *bridge, extern DRM_AGP_MEM *drm_agp_allocate_memory(struct agp_bridge_data *bridge,
size_t pages, u32 type); size_t pages, u32 type);
...@@ -991,10 +1015,8 @@ extern struct drm_sysfs_class *drm_sysfs_create(struct module *owner, ...@@ -991,10 +1015,8 @@ extern struct drm_sysfs_class *drm_sysfs_create(struct module *owner,
char *name); char *name);
extern void drm_sysfs_destroy(struct drm_sysfs_class *cs); extern void drm_sysfs_destroy(struct drm_sysfs_class *cs);
extern struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs, extern struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs,
dev_t dev, drm_head_t *head);
struct device *device, extern void drm_sysfs_device_remove(struct class_device *class_dev);
const char *fmt, ...);
extern void drm_sysfs_device_remove(dev_t dev);
/* Inline replacements for DRM_IOREMAP macros */ /* Inline replacements for DRM_IOREMAP macros */
static __inline__ void drm_core_ioremap(struct drm_map *map, static __inline__ void drm_core_ioremap(struct drm_map *map,
......
/** /**
* \file drm_agpsupport.h * \file drm_agpsupport.c
* DRM support for AGP/GART backend * DRM support for AGP/GART backend
* *
* \author Rickard E. (Rik) Faith <faith@valinux.com> * \author Rickard E. (Rik) Faith <faith@valinux.com>
...@@ -91,7 +91,7 @@ int drm_agp_info_ioctl(struct inode *inode, struct file *filp, ...@@ -91,7 +91,7 @@ int drm_agp_info_ioctl(struct inode *inode, struct file *filp,
/** /**
* Acquire the AGP device. * Acquire the AGP device.
* *
* \param dev DRM device that is to acquire AGP * \param dev DRM device that is to acquire AGP.
* \return zero on success or a negative number on failure. * \return zero on success or a negative number on failure.
* *
* Verifies the AGP device hasn't been acquired before and calls * Verifies the AGP device hasn't been acquired before and calls
...@@ -134,7 +134,7 @@ int drm_agp_acquire_ioctl(struct inode *inode, struct file *filp, ...@@ -134,7 +134,7 @@ int drm_agp_acquire_ioctl(struct inode *inode, struct file *filp,
/** /**
* Release the AGP device. * Release the AGP device.
* *
* \param dev DRM device that is to release AGP * \param dev DRM device that is to release AGP.
* \return zero on success or a negative number on failure. * \return zero on success or a negative number on failure.
* *
* Verifies the AGP device has been acquired and calls \c agp_backend_release. * Verifies the AGP device has been acquired and calls \c agp_backend_release.
...@@ -147,7 +147,6 @@ int drm_agp_release(drm_device_t * dev) ...@@ -147,7 +147,6 @@ int drm_agp_release(drm_device_t * dev)
dev->agp->acquired = 0; dev->agp->acquired = 0;
return 0; return 0;
} }
EXPORT_SYMBOL(drm_agp_release); EXPORT_SYMBOL(drm_agp_release);
int drm_agp_release_ioctl(struct inode *inode, struct file *filp, int drm_agp_release_ioctl(struct inode *inode, struct file *filp,
...@@ -208,30 +207,22 @@ int drm_agp_enable_ioctl(struct inode *inode, struct file *filp, ...@@ -208,30 +207,22 @@ int drm_agp_enable_ioctl(struct inode *inode, struct file *filp,
* Verifies the AGP device is present and has been acquired, allocates the * Verifies the AGP device is present and has been acquired, allocates the
* memory via alloc_agp() and creates a drm_agp_mem entry for it. * memory via alloc_agp() and creates a drm_agp_mem entry for it.
*/ */
int drm_agp_alloc(struct inode *inode, struct file *filp, int drm_agp_alloc(drm_device_t *dev, drm_agp_buffer_t *request)
unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->head->dev;
drm_agp_buffer_t request;
drm_agp_mem_t *entry; drm_agp_mem_t *entry;
DRM_AGP_MEM *memory; DRM_AGP_MEM *memory;
unsigned long pages; unsigned long pages;
u32 type; u32 type;
drm_agp_buffer_t __user *argp = (void __user *)arg;
if (!dev->agp || !dev->agp->acquired) if (!dev->agp || !dev->agp->acquired)
return -EINVAL; return -EINVAL;
if (copy_from_user(&request, argp, sizeof(request)))
return -EFAULT;
if (!(entry = drm_alloc(sizeof(*entry), DRM_MEM_AGPLISTS))) if (!(entry = drm_alloc(sizeof(*entry), DRM_MEM_AGPLISTS)))
return -ENOMEM; return -ENOMEM;
memset(entry, 0, sizeof(*entry)); memset(entry, 0, sizeof(*entry));
pages = (request.size + PAGE_SIZE - 1) / PAGE_SIZE; pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE;
type = (u32) request.type; type = (u32) request->type;
if (!(memory = drm_alloc_agp(dev, pages, type))) { if (!(memory = drm_alloc_agp(dev, pages, type))) {
drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
return -ENOMEM; return -ENOMEM;
...@@ -247,16 +238,39 @@ int drm_agp_alloc(struct inode *inode, struct file *filp, ...@@ -247,16 +238,39 @@ int drm_agp_alloc(struct inode *inode, struct file *filp,
dev->agp->memory->prev = entry; dev->agp->memory->prev = entry;
dev->agp->memory = entry; dev->agp->memory = entry;
request.handle = entry->handle; request->handle = entry->handle;
request.physical = memory->physical; request->physical = memory->physical;
return 0;
}
EXPORT_SYMBOL(drm_agp_alloc);
int drm_agp_alloc_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->head->dev;
drm_agp_buffer_t request;
drm_agp_buffer_t __user *argp = (void __user *)arg;
int err;
if (copy_from_user(&request, argp, sizeof(request)))
return -EFAULT;
err = drm_agp_alloc(dev, &request);
if (err)
return err;
if (copy_to_user(argp, &request, sizeof(request))) { if (copy_to_user(argp, &request, sizeof(request))) {
drm_agp_mem_t *entry = dev->agp->memory;
dev->agp->memory = entry->next; dev->agp->memory = entry->next;
dev->agp->memory->prev = NULL; dev->agp->memory->prev = NULL;
drm_free_agp(memory, pages); drm_free_agp(entry->memory, entry->pages);
drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
return -EFAULT; return -EFAULT;
} }
return 0; return 0;
} }
...@@ -293,21 +307,14 @@ static drm_agp_mem_t *drm_agp_lookup_entry(drm_device_t * dev, ...@@ -293,21 +307,14 @@ static drm_agp_mem_t *drm_agp_lookup_entry(drm_device_t * dev,
* Verifies the AGP device is present and acquired, looks-up the AGP memory * Verifies the AGP device is present and acquired, looks-up the AGP memory
* entry and passes it to the unbind_agp() function. * entry and passes it to the unbind_agp() function.
*/ */
int drm_agp_unbind(struct inode *inode, struct file *filp, int drm_agp_unbind(drm_device_t *dev, drm_agp_binding_t *request)
unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->head->dev;
drm_agp_binding_t request;
drm_agp_mem_t *entry; drm_agp_mem_t *entry;
int ret; int ret;
if (!dev->agp || !dev->agp->acquired) if (!dev->agp || !dev->agp->acquired)
return -EINVAL; return -EINVAL;
if (copy_from_user if (!(entry = drm_agp_lookup_entry(dev, request->handle)))
(&request, (drm_agp_binding_t __user *) arg, sizeof(request)))
return -EFAULT;
if (!(entry = drm_agp_lookup_entry(dev, request.handle)))
return -EINVAL; return -EINVAL;
if (!entry->bound) if (!entry->bound)
return -EINVAL; return -EINVAL;
...@@ -316,6 +323,21 @@ int drm_agp_unbind(struct inode *inode, struct file *filp, ...@@ -316,6 +323,21 @@ int drm_agp_unbind(struct inode *inode, struct file *filp,
entry->bound = 0; entry->bound = 0;
return ret; return ret;
} }
EXPORT_SYMBOL(drm_agp_unbind);
int drm_agp_unbind_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->head->dev;
drm_agp_binding_t request;
if (copy_from_user
(&request, (drm_agp_binding_t __user *) arg, sizeof(request)))
return -EFAULT;
return drm_agp_unbind(dev, &request);
}
/** /**
* Bind AGP memory into the GATT (ioctl) * Bind AGP memory into the GATT (ioctl)
...@@ -330,26 +352,19 @@ int drm_agp_unbind(struct inode *inode, struct file *filp, ...@@ -330,26 +352,19 @@ int drm_agp_unbind(struct inode *inode, struct file *filp,
* is currently bound into the GATT. Looks-up the AGP memory entry and passes * is currently bound into the GATT. Looks-up the AGP memory entry and passes
* it to bind_agp() function. * it to bind_agp() function.
*/ */
int drm_agp_bind(struct inode *inode, struct file *filp, int drm_agp_bind(drm_device_t *dev, drm_agp_binding_t *request)
unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->head->dev;
drm_agp_binding_t request;
drm_agp_mem_t *entry; drm_agp_mem_t *entry;
int retcode; int retcode;
int page; int page;
if (!dev->agp || !dev->agp->acquired) if (!dev->agp || !dev->agp->acquired)
return -EINVAL; return -EINVAL;
if (copy_from_user if (!(entry = drm_agp_lookup_entry(dev, request->handle)))
(&request, (drm_agp_binding_t __user *) arg, sizeof(request)))
return -EFAULT;
if (!(entry = drm_agp_lookup_entry(dev, request.handle)))
return -EINVAL; return -EINVAL;
if (entry->bound) if (entry->bound)
return -EINVAL; return -EINVAL;
page = (request.offset + PAGE_SIZE - 1) / PAGE_SIZE; page = (request->offset + PAGE_SIZE - 1) / PAGE_SIZE;
if ((retcode = drm_bind_agp(entry->memory, page))) if ((retcode = drm_bind_agp(entry->memory, page)))
return retcode; return retcode;
entry->bound = dev->agp->base + (page << PAGE_SHIFT); entry->bound = dev->agp->base + (page << PAGE_SHIFT);
...@@ -357,6 +372,21 @@ int drm_agp_bind(struct inode *inode, struct file *filp, ...@@ -357,6 +372,21 @@ int drm_agp_bind(struct inode *inode, struct file *filp,
dev->agp->base, entry->bound); dev->agp->base, entry->bound);
return 0; return 0;
} }
EXPORT_SYMBOL(drm_agp_bind);
int drm_agp_bind_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->head->dev;
drm_agp_binding_t request;
if (copy_from_user
(&request, (drm_agp_binding_t __user *) arg, sizeof(request)))
return -EFAULT;
return drm_agp_bind(dev, &request);
}
/** /**
* Free AGP memory (ioctl). * Free AGP memory (ioctl).
...@@ -372,20 +402,13 @@ int drm_agp_bind(struct inode *inode, struct file *filp, ...@@ -372,20 +402,13 @@ int drm_agp_bind(struct inode *inode, struct file *filp,
* unbind_agp(). Frees it via free_agp() as well as the entry itself * unbind_agp(). Frees it via free_agp() as well as the entry itself
* and unlinks from the doubly linked list it's inserted in. * and unlinks from the doubly linked list it's inserted in.
*/ */
int drm_agp_free(struct inode *inode, struct file *filp, int drm_agp_free(drm_device_t *dev, drm_agp_buffer_t *request)
unsigned int cmd, unsigned long arg)
{ {
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->head->dev;
drm_agp_buffer_t request;
drm_agp_mem_t *entry; drm_agp_mem_t *entry;
if (!dev->agp || !dev->agp->acquired) if (!dev->agp || !dev->agp->acquired)
return -EINVAL; return -EINVAL;
if (copy_from_user if (!(entry = drm_agp_lookup_entry(dev, request->handle)))
(&request, (drm_agp_buffer_t __user *) arg, sizeof(request)))
return -EFAULT;
if (!(entry = drm_agp_lookup_entry(dev, request.handle)))
return -EINVAL; return -EINVAL;
if (entry->bound) if (entry->bound)
drm_unbind_agp(entry->memory); drm_unbind_agp(entry->memory);
...@@ -402,12 +425,30 @@ int drm_agp_free(struct inode *inode, struct file *filp, ...@@ -402,12 +425,30 @@ int drm_agp_free(struct inode *inode, struct file *filp,
drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
return 0; return 0;
} }
EXPORT_SYMBOL(drm_agp_free);
int drm_agp_free_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->head->dev;
drm_agp_buffer_t request;
if (copy_from_user
(&request, (drm_agp_buffer_t __user *) arg, sizeof(request)))
return -EFAULT;
return drm_agp_free(dev, &request);
}
/** /**
* Initialize the AGP resources. * Initialize the AGP resources.
* *
* \return pointer to a drm_agp_head structure. * \return pointer to a drm_agp_head structure.
* *
* Gets the drm_agp_t structure which is made available by the agpgart module
* via the inter_module_* functions. Creates and initializes a drm_agp_head
* structure.
*/ */
drm_agp_head_t *drm_agp_init(drm_device_t * dev) drm_agp_head_t *drm_agp_init(drm_device_t * dev)
{ {
......
...@@ -36,22 +36,21 @@ ...@@ -36,22 +36,21 @@
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include "drmP.h" #include "drmP.h"
unsigned long drm_get_resource_start(drm_device_t * dev, unsigned int resource) unsigned long drm_get_resource_start(drm_device_t *dev, unsigned int resource)
{ {
return pci_resource_start(dev->pdev, resource); return pci_resource_start(dev->pdev, resource);
} }
EXPORT_SYMBOL(drm_get_resource_start); EXPORT_SYMBOL(drm_get_resource_start);
unsigned long drm_get_resource_len(drm_device_t * dev, unsigned int resource) unsigned long drm_get_resource_len(drm_device_t *dev, unsigned int resource)
{ {
return pci_resource_len(dev->pdev, resource); return pci_resource_len(dev->pdev, resource);
} }
EXPORT_SYMBOL(drm_get_resource_len); EXPORT_SYMBOL(drm_get_resource_len);
static drm_map_list_t *drm_find_matching_map(drm_device_t * dev, static drm_map_list_t *drm_find_matching_map(drm_device_t *dev,
drm_local_map_t * map) drm_local_map_t *map)
{ {
struct list_head *list; struct list_head *list;
...@@ -74,7 +73,7 @@ static drm_map_list_t *drm_find_matching_map(drm_device_t * dev, ...@@ -74,7 +73,7 @@ static drm_map_list_t *drm_find_matching_map(drm_device_t * dev,
#ifdef _LP64 #ifdef _LP64
static __inline__ unsigned int HandleID(unsigned long lhandle, static __inline__ unsigned int HandleID(unsigned long lhandle,
drm_device_t * dev) drm_device_t *dev)
{ {
static unsigned int map32_handle = START_RANGE; static unsigned int map32_handle = START_RANGE;
unsigned int hash; unsigned int hash;
...@@ -155,7 +154,7 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset, ...@@ -155,7 +154,7 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset,
case _DRM_REGISTERS: case _DRM_REGISTERS:
case _DRM_FRAME_BUFFER: case _DRM_FRAME_BUFFER:
#if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__) && !defined(__powerpc64__) && !defined(__x86_64__) #if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__) && !defined(__powerpc64__) && !defined(__x86_64__)
if (map->offset + map->size < map->offset || if (map->offset + (map->size-1) < map->offset ||
map->offset < virt_to_phys(high_memory)) { map->offset < virt_to_phys(high_memory)) {
drm_free(map, sizeof(*map), DRM_MEM_MAPS); drm_free(map, sizeof(*map), DRM_MEM_MAPS);
return -EINVAL; return -EINVAL;
...@@ -301,6 +300,9 @@ int drm_addmap_ioctl(struct inode *inode, struct file *filp, ...@@ -301,6 +300,9 @@ int drm_addmap_ioctl(struct inode *inode, struct file *filp,
return -EFAULT; return -EFAULT;
} }
if (!(capable(CAP_SYS_ADMIN) || map.type == _DRM_AGP))
return -EPERM;
err = drm_addmap_core(dev, map.offset, map.size, map.type, map.flags, err = drm_addmap_core(dev, map.offset, map.size, map.type, map.flags,
&maplist); &maplist);
...@@ -332,7 +334,7 @@ int drm_addmap_ioctl(struct inode *inode, struct file *filp, ...@@ -332,7 +334,7 @@ int drm_addmap_ioctl(struct inode *inode, struct file *filp,
* *
* \sa drm_addmap * \sa drm_addmap
*/ */
int drm_rmmap_locked(drm_device_t * dev, drm_local_map_t * map) int drm_rmmap_locked(drm_device_t *dev, drm_local_map_t *map)
{ {
struct list_head *list; struct list_head *list;
drm_map_list_t *r_list = NULL; drm_map_list_t *r_list = NULL;
...@@ -384,10 +386,9 @@ int drm_rmmap_locked(drm_device_t * dev, drm_local_map_t * map) ...@@ -384,10 +386,9 @@ int drm_rmmap_locked(drm_device_t * dev, drm_local_map_t * map)
return 0; return 0;
} }
EXPORT_SYMBOL(drm_rmmap_locked); EXPORT_SYMBOL(drm_rmmap_locked);
int drm_rmmap(drm_device_t * dev, drm_local_map_t * map) int drm_rmmap(drm_device_t *dev, drm_local_map_t *map)
{ {
int ret; int ret;
...@@ -397,7 +398,6 @@ int drm_rmmap(drm_device_t * dev, drm_local_map_t * map) ...@@ -397,7 +398,6 @@ int drm_rmmap(drm_device_t * dev, drm_local_map_t * map)
return ret; return ret;
} }
EXPORT_SYMBOL(drm_rmmap); EXPORT_SYMBOL(drm_rmmap);
/* The rmmap ioctl appears to be unnecessary. All mappings are torn down on /* The rmmap ioctl appears to be unnecessary. All mappings are torn down on
...@@ -548,7 +548,7 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request) ...@@ -548,7 +548,7 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
DRM_DEBUG("count: %d\n", count); DRM_DEBUG("count: %d\n", count);
DRM_DEBUG("order: %d\n", order); DRM_DEBUG("order: %d\n", order);
DRM_DEBUG("size: %d\n", size); DRM_DEBUG("size: %d\n", size);
DRM_DEBUG("agp_offset: %lu\n", agp_offset); DRM_DEBUG("agp_offset: %lx\n", agp_offset);
DRM_DEBUG("alignment: %d\n", alignment); DRM_DEBUG("alignment: %d\n", alignment);
DRM_DEBUG("page_order: %d\n", page_order); DRM_DEBUG("page_order: %d\n", page_order);
DRM_DEBUG("total: %d\n", total); DRM_DEBUG("total: %d\n", total);
...@@ -649,6 +649,8 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request) ...@@ -649,6 +649,8 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
} }
dma->buf_count += entry->buf_count; dma->buf_count += entry->buf_count;
dma->seg_count += entry->seg_count;
dma->page_count += byte_count >> PAGE_SHIFT;
dma->byte_count += byte_count; dma->byte_count += byte_count;
DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count); DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
...@@ -664,7 +666,6 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request) ...@@ -664,7 +666,6 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request)
atomic_dec(&dev->buf_alloc); atomic_dec(&dev->buf_alloc);
return 0; return 0;
} }
EXPORT_SYMBOL(drm_addbufs_agp); EXPORT_SYMBOL(drm_addbufs_agp);
#endif /* __OS_HAS_AGP */ #endif /* __OS_HAS_AGP */
...@@ -689,9 +690,13 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request) ...@@ -689,9 +690,13 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
if (!drm_core_check_feature(dev, DRIVER_PCI_DMA)) if (!drm_core_check_feature(dev, DRIVER_PCI_DMA))
return -EINVAL; return -EINVAL;
if (!dma) if (!dma)
return -EINVAL; return -EINVAL;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
count = request->count; count = request->count;
order = drm_order(request->size); order = drm_order(request->size);
size = 1 << order; size = 1 << order;
...@@ -882,7 +887,6 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request) ...@@ -882,7 +887,6 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request)
return 0; return 0;
} }
EXPORT_SYMBOL(drm_addbufs_pci); EXPORT_SYMBOL(drm_addbufs_pci);
static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request) static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
...@@ -908,6 +912,9 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request) ...@@ -908,6 +912,9 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
if (!dma) if (!dma)
return -EINVAL; return -EINVAL;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
count = request->count; count = request->count;
order = drm_order(request->size); order = drm_order(request->size);
size = 1 << order; size = 1 << order;
...@@ -1026,6 +1033,8 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request) ...@@ -1026,6 +1033,8 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
} }
dma->buf_count += entry->buf_count; dma->buf_count += entry->buf_count;
dma->seg_count += entry->seg_count;
dma->page_count += byte_count >> PAGE_SHIFT;
dma->byte_count += byte_count; dma->byte_count += byte_count;
DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count); DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
...@@ -1042,7 +1051,7 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request) ...@@ -1042,7 +1051,7 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request)
return 0; return 0;
} }
static int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request) int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
{ {
drm_device_dma_t *dma = dev->dma; drm_device_dma_t *dma = dev->dma;
drm_buf_entry_t *entry; drm_buf_entry_t *entry;
...@@ -1065,6 +1074,9 @@ static int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request) ...@@ -1065,6 +1074,9 @@ static int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
if (!dma) if (!dma)
return -EINVAL; return -EINVAL;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
count = request->count; count = request->count;
order = drm_order(request->size); order = drm_order(request->size);
size = 1 << order; size = 1 << order;
...@@ -1181,6 +1193,8 @@ static int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request) ...@@ -1181,6 +1193,8 @@ static int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
} }
dma->buf_count += entry->buf_count; dma->buf_count += entry->buf_count;
dma->seg_count += entry->seg_count;
dma->page_count += byte_count >> PAGE_SHIFT;
dma->byte_count += byte_count; dma->byte_count += byte_count;
DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count); DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
...@@ -1196,6 +1210,8 @@ static int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request) ...@@ -1196,6 +1210,8 @@ static int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request)
atomic_dec(&dev->buf_alloc); atomic_dec(&dev->buf_alloc);
return 0; return 0;
} }
EXPORT_SYMBOL(drm_addbufs_fb);
/** /**
* Add buffers for DMA transfers (ioctl). * Add buffers for DMA transfers (ioctl).
...@@ -1577,5 +1593,6 @@ int drm_order(unsigned long size) ...@@ -1577,5 +1593,6 @@ int drm_order(unsigned long size)
return order; return order;
} }
EXPORT_SYMBOL(drm_order); EXPORT_SYMBOL(drm_order);
...@@ -433,7 +433,7 @@ int drm_addctx(struct inode *inode, struct file *filp, ...@@ -433,7 +433,7 @@ int drm_addctx(struct inode *inode, struct file *filp,
if (ctx.handle != DRM_KERNEL_CONTEXT) { if (ctx.handle != DRM_KERNEL_CONTEXT) {
if (dev->driver->context_ctor) if (dev->driver->context_ctor)
if (!dev->driver->context_ctor(dev, ctx.handle)) { if (!dev->driver->context_ctor(dev, ctx.handle)) {
DRM_DEBUG( "Running out of ctxs or memory.\n"); DRM_DEBUG("Running out of ctxs or memory.\n");
return -ENOMEM; return -ENOMEM;
} }
} }
......
...@@ -24,11 +24,11 @@ ...@@ -24,11 +24,11 @@
#define CORE_NAME "drm" #define CORE_NAME "drm"
#define CORE_DESC "DRM shared core routines" #define CORE_DESC "DRM shared core routines"
#define CORE_DATE "20040925" #define CORE_DATE "20051102"
#define DRM_IF_MAJOR 1 #define DRM_IF_MAJOR 1
#define DRM_IF_MINOR 2 #define DRM_IF_MINOR 2
#define CORE_MAJOR 1 #define CORE_MAJOR 1
#define CORE_MINOR 0 #define CORE_MINOR 0
#define CORE_PATCHLEVEL 0 #define CORE_PATCHLEVEL 1
...@@ -56,66 +56,66 @@ static int drm_version(struct inode *inode, struct file *filp, ...@@ -56,66 +56,66 @@ static int drm_version(struct inode *inode, struct file *filp,
/** Ioctl table */ /** Ioctl table */
static drm_ioctl_desc_t drm_ioctls[] = { static drm_ioctl_desc_t drm_ioctls[] = {
[DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = {drm_version, 0, 0}, [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = {drm_version, 0},
[DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = {drm_getunique, 0, 0}, [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = {drm_getunique, 0},
[DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = {drm_getmagic, 0, 0}, [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = {drm_getmagic, 0},
[DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = {drm_irq_by_busid, 0, 1}, [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = {drm_irq_by_busid, DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_GET_MAP)] = {drm_getmap, 0, 0}, [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP)] = {drm_getmap, 0},
[DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = {drm_getclient, 0, 0}, [DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = {drm_getclient, 0},
[DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = {drm_getstats, 0, 0}, [DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = {drm_getstats, 0},
[DRM_IOCTL_NR(DRM_IOCTL_SET_VERSION)] = {drm_setversion, 0, 1}, [DRM_IOCTL_NR(DRM_IOCTL_SET_VERSION)] = {drm_setversion, DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = {drm_setunique, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = {drm_setunique, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = {drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = {drm_noop, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = {drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = {drm_noop, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = {drm_authmagic, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = {drm_authmagic, 1, 1},
[DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = {drm_addmap_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = {drm_addmap_ioctl, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_RM_MAP)] = {drm_rmmap_ioctl, DRM_AUTH},
[DRM_IOCTL_NR(DRM_IOCTL_RM_MAP)] = {drm_rmmap_ioctl, 1, 0},
[DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)] = {drm_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)] = {drm_setsareactx, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)] = {drm_getsareactx, DRM_AUTH},
[DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)] = {drm_getsareactx, 1, 0},
[DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = {drm_addctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = {drm_addctx, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = {drm_rmctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = {drm_rmctx, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = {drm_modctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = {drm_modctx, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = {drm_getctx, DRM_AUTH},
[DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = {drm_getctx, 1, 0}, [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = {drm_switchctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = {drm_switchctx, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = {drm_newctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = {drm_newctx, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = {drm_resctx, DRM_AUTH},
[DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = {drm_resctx, 1, 0},
[DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = {drm_adddraw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = {drm_adddraw, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = {drm_rmdraw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = {drm_rmdraw, 1, 1},
[DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = {drm_lock, DRM_AUTH},
[DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = {drm_lock, 1, 0}, [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = {drm_unlock, DRM_AUTH},
[DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = {drm_unlock, 1, 0},
[DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = {drm_noop, DRM_AUTH},
[DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = {drm_noop, 1, 0},
[DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = {drm_addbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = {drm_addbufs, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = {drm_markbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = {drm_markbufs, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = {drm_infobufs, DRM_AUTH},
[DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = {drm_infobufs, 1, 0}, [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = {drm_mapbufs, DRM_AUTH},
[DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = {drm_mapbufs, 1, 0}, [DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = {drm_freebufs, DRM_AUTH},
[DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = {drm_freebufs, 1, 0},
/* The DRM_IOCTL_DMA ioctl should be defined by the driver. */ /* The DRM_IOCTL_DMA ioctl should be defined by the driver. */
[DRM_IOCTL_NR(DRM_IOCTL_DMA)] = {NULL, DRM_AUTH},
[DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = {drm_control, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = {drm_control, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
#if __OS_HAS_AGP #if __OS_HAS_AGP
[DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = {drm_agp_acquire_ioctl, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = {drm_agp_acquire_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = {drm_agp_release_ioctl, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = {drm_agp_release_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = {drm_agp_enable_ioctl, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = {drm_agp_enable_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = {drm_agp_info_ioctl, 1, 0}, [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = {drm_agp_info_ioctl, DRM_AUTH},
[DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = {drm_agp_alloc, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = {drm_agp_alloc_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = {drm_agp_free, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = {drm_agp_free_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = {drm_agp_bind, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = {drm_agp_bind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = {drm_agp_unbind, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = {drm_agp_unbind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
#endif #endif
[DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = {drm_sg_alloc, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = {drm_sg_alloc, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = {drm_sg_free, 1, 1}, [DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = {drm_sg_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = {drm_wait_vblank, 0, 0}, [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = {drm_wait_vblank, 0},
}; };
#define DRIVER_IOCTL_COUNT DRM_ARRAY_SIZE( drm_ioctls ) #define DRIVER_IOCTL_COUNT DRM_ARRAY_SIZE( drm_ioctls )
...@@ -129,7 +129,7 @@ static drm_ioctl_desc_t drm_ioctls[] = { ...@@ -129,7 +129,7 @@ static drm_ioctl_desc_t drm_ioctls[] = {
* *
* \sa drm_device * \sa drm_device
*/ */
int drm_takedown(drm_device_t * dev) int drm_lastclose(drm_device_t * dev)
{ {
drm_magic_entry_t *pt, *next; drm_magic_entry_t *pt, *next;
drm_map_list_t *r_list; drm_map_list_t *r_list;
...@@ -138,9 +138,9 @@ int drm_takedown(drm_device_t * dev) ...@@ -138,9 +138,9 @@ int drm_takedown(drm_device_t * dev)
DRM_DEBUG("\n"); DRM_DEBUG("\n");
if (dev->driver->pretakedown) if (dev->driver->lastclose)
dev->driver->pretakedown(dev); dev->driver->lastclose(dev);
DRM_DEBUG("driver pretakedown completed\n"); DRM_DEBUG("driver lastclose completed\n");
if (dev->unique) { if (dev->unique) {
drm_free(dev->unique, strlen(dev->unique) + 1, DRM_MEM_DRIVER); drm_free(dev->unique, strlen(dev->unique) + 1, DRM_MEM_DRIVER);
...@@ -233,7 +233,7 @@ int drm_takedown(drm_device_t * dev) ...@@ -233,7 +233,7 @@ int drm_takedown(drm_device_t * dev)
} }
up(&dev->struct_sem); up(&dev->struct_sem);
DRM_DEBUG("takedown completed\n"); DRM_DEBUG("lastclose completed\n");
return 0; return 0;
} }
...@@ -281,7 +281,7 @@ EXPORT_SYMBOL(drm_init); ...@@ -281,7 +281,7 @@ EXPORT_SYMBOL(drm_init);
/** /**
* Called via cleanup_module() at module unload time. * Called via cleanup_module() at module unload time.
* *
* Cleans up all DRM device, calling takedown(). * Cleans up all DRM device, calling drm_lastclose().
* *
* \sa drm_init * \sa drm_init
*/ */
...@@ -294,7 +294,7 @@ static void drm_cleanup(drm_device_t * dev) ...@@ -294,7 +294,7 @@ static void drm_cleanup(drm_device_t * dev)
return; return;
} }
drm_takedown(dev); drm_lastclose(dev);
if (dev->maplist) { if (dev->maplist) {
drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS); drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
...@@ -317,8 +317,8 @@ static void drm_cleanup(drm_device_t * dev) ...@@ -317,8 +317,8 @@ static void drm_cleanup(drm_device_t * dev)
dev->agp = NULL; dev->agp = NULL;
} }
if (dev->driver->postcleanup) if (dev->driver->unload)
dev->driver->postcleanup(dev); dev->driver->unload(dev);
drm_put_head(&dev->primary); drm_put_head(&dev->primary);
if (drm_put_dev(dev)) if (drm_put_dev(dev))
...@@ -342,13 +342,13 @@ void drm_exit(struct drm_driver *driver) ...@@ -342,13 +342,13 @@ void drm_exit(struct drm_driver *driver)
if (head->dev->driver != driver) if (head->dev->driver != driver)
continue; continue;
dev = head->dev; dev = head->dev;
}
if (dev) { if (dev) {
/* release the pci driver */ /* release the pci driver */
if (dev->pdev) if (dev->pdev)
pci_dev_put(dev->pdev); pci_dev_put(dev->pdev);
drm_cleanup(dev); drm_cleanup(dev);
} }
}
DRM_INFO("Module unloaded\n"); DRM_INFO("Module unloaded\n");
} }
...@@ -432,14 +432,17 @@ static int drm_version(struct inode *inode, struct file *filp, ...@@ -432,14 +432,17 @@ static int drm_version(struct inode *inode, struct file *filp,
drm_device_t *dev = priv->head->dev; drm_device_t *dev = priv->head->dev;
drm_version_t __user *argp = (void __user *)arg; drm_version_t __user *argp = (void __user *)arg;
drm_version_t version; drm_version_t version;
int ret; int len;
if (copy_from_user(&version, argp, sizeof(version))) if (copy_from_user(&version, argp, sizeof(version)))
return -EFAULT; return -EFAULT;
/* version is a required function to return the personality module version */ version.version_major = dev->driver->major;
if ((ret = dev->driver->version(&version))) version.version_minor = dev->driver->minor;
return ret; version.version_patchlevel = dev->driver->patchlevel;
DRM_COPY(version.name, dev->driver->name);
DRM_COPY(version.date, dev->driver->date);
DRM_COPY(version.desc, dev->driver->desc);
if (copy_to_user(argp, &version, sizeof(version))) if (copy_to_user(argp, &version, sizeof(version)))
return -EFAULT; return -EFAULT;
...@@ -493,8 +496,9 @@ int drm_ioctl(struct inode *inode, struct file *filp, ...@@ -493,8 +496,9 @@ int drm_ioctl(struct inode *inode, struct file *filp,
if (!func) { if (!func) {
DRM_DEBUG("no function\n"); DRM_DEBUG("no function\n");
retcode = -EINVAL; retcode = -EINVAL;
} else if ((ioctl->root_only && !capable(CAP_SYS_ADMIN)) || } else if (((ioctl->flags & DRM_ROOT_ONLY) && !capable(CAP_SYS_ADMIN)) ||
(ioctl->auth_needed && !priv->authenticated)) { ((ioctl->flags & DRM_AUTH) && !priv->authenticated) ||
((ioctl->flags & DRM_MASTER) && !priv->master)) {
retcode = -EACCES; retcode = -EACCES;
} else { } else {
retcode = func(inode, filp, cmd, arg); retcode = func(inode, filp, cmd, arg);
......
This diff is collapsed.
/**
* \file drm_init.c
* Setup/Cleanup 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"
/**
* Check whether DRI will run on this CPU.
*
* \return non-zero if the DRI will run on this CPU, or zero otherwise.
*/
int drm_cpu_valid(void)
{
#if defined(__i386__)
if (boot_cpu_data.x86 == 3)
return 0; /* No cmpxchg on a 386 */
#endif
#if defined(__sparc__) && !defined(__sparc_v9__)
return 0; /* No cmpxchg before v9 sparc. */
#endif
return 1;
}
...@@ -137,17 +137,22 @@ int drm_setunique(struct inode *inode, struct file *filp, ...@@ -137,17 +137,22 @@ int drm_setunique(struct inode *inode, struct file *filp,
static int drm_set_busid(drm_device_t * dev) static int drm_set_busid(drm_device_t * dev)
{ {
int len;
if (dev->unique != NULL) if (dev->unique != NULL)
return EBUSY; return EBUSY;
dev->unique_len = 20; dev->unique_len = 40;
dev->unique = drm_alloc(dev->unique_len + 1, DRM_MEM_DRIVER); dev->unique = drm_alloc(dev->unique_len + 1, DRM_MEM_DRIVER);
if (dev->unique == NULL) if (dev->unique == NULL)
return ENOMEM; return ENOMEM;
snprintf(dev->unique, dev->unique_len, "pci:%04x:%02x:%02x.%d", len = snprintf(dev->unique, dev->unique_len, "pci:%04x:%02x:%02x.%d",
dev->pci_domain, dev->pci_bus, dev->pci_slot, dev->pci_func); dev->pci_domain, dev->pci_bus, dev->pci_slot, dev->pci_func);
if (len > dev->unique_len)
DRM_ERROR("Unique buffer overflowed\n");
dev->devname = dev->devname =
drm_alloc(strlen(dev->driver->pci_driver.name) + dev->unique_len + drm_alloc(strlen(dev->driver->pci_driver.name) + dev->unique_len +
2, DRM_MEM_DRIVER); 2, DRM_MEM_DRIVER);
...@@ -239,7 +244,7 @@ int drm_getclient(struct inode *inode, struct file *filp, ...@@ -239,7 +244,7 @@ int drm_getclient(struct inode *inode, struct file *filp,
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->head->dev; drm_device_t *dev = priv->head->dev;
drm_client_t __user *argp = (void __user *)arg; drm_client_t __user *argp = (drm_client_t __user *)arg;
drm_client_t client; drm_client_t client;
drm_file_t *pt; drm_file_t *pt;
int idx; int idx;
...@@ -262,7 +267,7 @@ int drm_getclient(struct inode *inode, struct file *filp, ...@@ -262,7 +267,7 @@ int drm_getclient(struct inode *inode, struct file *filp,
client.iocs = pt->ioctl_count; client.iocs = pt->ioctl_count;
up(&dev->struct_sem); up(&dev->struct_sem);
if (copy_to_user((drm_client_t __user *) arg, &client, sizeof(client))) if (copy_to_user(argp, &client, sizeof(client)))
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
...@@ -325,17 +330,13 @@ int drm_setversion(DRM_IOCTL_ARGS) ...@@ -325,17 +330,13 @@ int drm_setversion(DRM_IOCTL_ARGS)
drm_set_version_t retv; drm_set_version_t retv;
int if_version; int if_version;
drm_set_version_t __user *argp = (void __user *)data; drm_set_version_t __user *argp = (void __user *)data;
drm_version_t version;
DRM_COPY_FROM_USER_IOCTL(sv, argp, sizeof(sv)); DRM_COPY_FROM_USER_IOCTL(sv, argp, sizeof(sv));
memset(&version, 0, sizeof(version));
dev->driver->version(&version);
retv.drm_di_major = DRM_IF_MAJOR; retv.drm_di_major = DRM_IF_MAJOR;
retv.drm_di_minor = DRM_IF_MINOR; retv.drm_di_minor = DRM_IF_MINOR;
retv.drm_dd_major = version.version_major; retv.drm_dd_major = dev->driver->major;
retv.drm_dd_minor = version.version_minor; retv.drm_dd_minor = dev->driver->minor;
DRM_COPY_TO_USER_IOCTL(argp, retv, sizeof(sv)); DRM_COPY_TO_USER_IOCTL(argp, retv, sizeof(sv));
...@@ -343,7 +344,7 @@ int drm_setversion(DRM_IOCTL_ARGS) ...@@ -343,7 +344,7 @@ int drm_setversion(DRM_IOCTL_ARGS)
if (sv.drm_di_major != DRM_IF_MAJOR || if (sv.drm_di_major != DRM_IF_MAJOR ||
sv.drm_di_minor < 0 || sv.drm_di_minor > DRM_IF_MINOR) sv.drm_di_minor < 0 || sv.drm_di_minor > DRM_IF_MINOR)
return EINVAL; return EINVAL;
if_version = DRM_IF_VERSION(sv.drm_di_major, sv.drm_dd_minor); if_version = DRM_IF_VERSION(sv.drm_di_major, sv.drm_di_minor);
dev->if_version = DRM_MAX(if_version, dev->if_version); dev->if_version = DRM_MAX(if_version, dev->if_version);
if (sv.drm_di_minor >= 1) { if (sv.drm_di_minor >= 1) {
/* /*
...@@ -354,9 +355,9 @@ int drm_setversion(DRM_IOCTL_ARGS) ...@@ -354,9 +355,9 @@ int drm_setversion(DRM_IOCTL_ARGS)
} }
if (sv.drm_dd_major != -1) { if (sv.drm_dd_major != -1) {
if (sv.drm_dd_major != version.version_major || if (sv.drm_dd_major != dev->driver->major ||
sv.drm_dd_minor < 0 sv.drm_dd_minor < 0
|| sv.drm_dd_minor > version.version_minor) || sv.drm_dd_minor > dev->driver->minor)
return EINVAL; return EINVAL;
if (dev->driver->set_version) if (dev->driver->set_version)
......
...@@ -130,7 +130,6 @@ int drm_lock(struct inode *inode, struct file *filp, ...@@ -130,7 +130,6 @@ int drm_lock(struct inode *inode, struct file *filp,
/* dev->driver->kernel_context_switch isn't used by any of the x86 /* dev->driver->kernel_context_switch isn't used by any of the x86
* drivers but is used by the Sparc driver. * drivers but is used by the Sparc driver.
*/ */
if (dev->driver->kernel_context_switch && if (dev->driver->kernel_context_switch &&
dev->last_context != lock.context) { dev->last_context != lock.context) {
dev->driver->kernel_context_switch(dev, dev->last_context, dev->driver->kernel_context_switch(dev, dev->last_context,
......
...@@ -145,30 +145,22 @@ DRM_AGP_MEM *drm_alloc_agp(drm_device_t * dev, int pages, u32 type) ...@@ -145,30 +145,22 @@ DRM_AGP_MEM *drm_alloc_agp(drm_device_t * dev, int pages, u32 type)
return drm_agp_allocate_memory(dev->agp->bridge, pages, type); return drm_agp_allocate_memory(dev->agp->bridge, pages, type);
} }
EXPORT_SYMBOL(drm_alloc_agp);
/** Wrapper around agp_free_memory() */ /** Wrapper around agp_free_memory() */
int drm_free_agp(DRM_AGP_MEM * handle, int pages) int drm_free_agp(DRM_AGP_MEM * handle, int pages)
{ {
return drm_agp_free_memory(handle) ? 0 : -EINVAL; return drm_agp_free_memory(handle) ? 0 : -EINVAL;
} }
EXPORT_SYMBOL(drm_free_agp);
/** Wrapper around agp_bind_memory() */ /** Wrapper around agp_bind_memory() */
int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start) int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start)
{ {
return drm_agp_bind_memory(handle, start); return drm_agp_bind_memory(handle, start);
} }
EXPORT_SYMBOL(drm_bind_agp);
/** Wrapper around agp_unbind_memory() */ /** Wrapper around agp_unbind_memory() */
int drm_unbind_agp(DRM_AGP_MEM * handle) int drm_unbind_agp(DRM_AGP_MEM * handle)
{ {
return drm_agp_unbind_memory(handle); return drm_agp_unbind_memory(handle);
} }
EXPORT_SYMBOL(drm_unbind_agp);
#endif /* agp */ #endif /* agp */
#endif /* debug_memory */ #endif /* debug_memory */
This diff is collapsed.
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#define DRM_ERR(d) -(d) #define DRM_ERR(d) -(d)
/** Current process ID */ /** Current process ID */
#define DRM_CURRENTPID current->pid #define DRM_CURRENTPID current->pid
#define DRM_SUSER(p) capable(CAP_SYS_ADMIN)
#define DRM_UDELAY(d) udelay(d) #define DRM_UDELAY(d) udelay(d)
/** Read a byte from a MMIO region */ /** Read a byte from a MMIO region */
#define DRM_READ8(map, offset) readb(((void __iomem *)(map)->handle) + (offset)) #define DRM_READ8(map, offset) readb(((void __iomem *)(map)->handle) + (offset))
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
{0x1002, 0x4E50, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350|CHIP_IS_MOBILITY}, \ {0x1002, 0x4E50, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350|CHIP_IS_MOBILITY}, \
{0x1002, 0x4E51, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350|CHIP_IS_MOBILITY}, \ {0x1002, 0x4E51, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350|CHIP_IS_MOBILITY}, \
{0x1002, 0x4E54, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350|CHIP_IS_MOBILITY}, \ {0x1002, 0x4E54, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350|CHIP_IS_MOBILITY}, \
{0x1002, 0x4E56, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350|CHIP_IS_MOBILITY}, \
{0x1002, 0x5144, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R100|CHIP_SINGLE_CRTC}, \ {0x1002, 0x5144, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R100|CHIP_SINGLE_CRTC}, \
{0x1002, 0x5145, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R100|CHIP_SINGLE_CRTC}, \ {0x1002, 0x5145, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R100|CHIP_SINGLE_CRTC}, \
{0x1002, 0x5146, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R100|CHIP_SINGLE_CRTC}, \ {0x1002, 0x5146, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R100|CHIP_SINGLE_CRTC}, \
...@@ -69,6 +70,7 @@ ...@@ -69,6 +70,7 @@
{0x1002, 0x516B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R200}, \ {0x1002, 0x516B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R200}, \
{0x1002, 0x516C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R200}, \ {0x1002, 0x516C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R200}, \
{0x1002, 0x5460, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350}, \ {0x1002, 0x5460, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350}, \
{0x1002, 0x554F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R350}, \
{0x1002, 0x5834, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|CHIP_IS_IGP}, \ {0x1002, 0x5834, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|CHIP_IS_IGP}, \
{0x1002, 0x5835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|CHIP_IS_IGP|CHIP_IS_MOBILITY}, \ {0x1002, 0x5835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|CHIP_IS_IGP|CHIP_IS_MOBILITY}, \
{0x1002, 0x5836, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|CHIP_IS_IGP}, \ {0x1002, 0x5836, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|CHIP_IS_IGP}, \
...@@ -82,10 +84,13 @@ ...@@ -82,10 +84,13 @@
{0x1002, 0x5969, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV100}, \ {0x1002, 0x5969, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV100}, \
{0x1002, 0x596A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \ {0x1002, 0x596A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \
{0x1002, 0x596B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \ {0x1002, 0x596B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \
{0x1002, 0x5b60, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350}, \
{0x1002, 0x5c61, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280|CHIP_IS_MOBILITY}, \ {0x1002, 0x5c61, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280|CHIP_IS_MOBILITY}, \
{0x1002, 0x5c62, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \ {0x1002, 0x5c62, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \
{0x1002, 0x5c63, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280|CHIP_IS_MOBILITY}, \ {0x1002, 0x5c63, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280|CHIP_IS_MOBILITY}, \
{0x1002, 0x5c64, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \ {0x1002, 0x5c64, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \
{0x1002, 0x5d4d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R350}, \
{0x1002, 0x5e4b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420}, \
{0, 0, 0} {0, 0, 0}
#define r128_PCI_IDS \ #define r128_PCI_IDS \
...@@ -176,7 +181,7 @@ ...@@ -176,7 +181,7 @@
#define viadrv_PCI_IDS \ #define viadrv_PCI_IDS \
{0x1106, 0x3022, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1106, 0x3022, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1106, 0x3118, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1106, 0x3118, PCI_ANY_ID, PCI_ANY_ID, 0, 0, VIA_PRO_GROUP_A}, \
{0x1106, 0x3122, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1106, 0x3122, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1106, 0x7205, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1106, 0x7205, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x1106, 0x3108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1106, 0x3108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
...@@ -196,6 +201,10 @@ ...@@ -196,6 +201,10 @@
{0x8086, 0x2572, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x8086, 0x2572, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0, 0, 0} {0, 0, 0}
#define gamma_PCI_IDS \
{0x3d3d, 0x0008, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0, 0, 0}
#define savage_PCI_IDS \ #define savage_PCI_IDS \
{0x5333, 0x8a20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SAVAGE3D}, \ {0x5333, 0x8a20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SAVAGE3D}, \
{0x5333, 0x8a21, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SAVAGE3D}, \ {0x5333, 0x8a21, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SAVAGE3D}, \
...@@ -234,3 +243,4 @@ ...@@ -234,3 +243,4 @@
{0x8086, 0x2592, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x8086, 0x2592, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0x8086, 0x2772, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x8086, 0x2772, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0, 0, 0} {0, 0, 0}
...@@ -61,16 +61,14 @@ static struct drm_proc_list { ...@@ -61,16 +61,14 @@ static struct drm_proc_list {
const char *name; /**< file name */ const char *name; /**< file name */
int (*f) (char *, char **, off_t, int, int *, void *); /**< proc callback*/ int (*f) (char *, char **, off_t, int, int *, void *); /**< proc callback*/
} drm_proc_list[] = { } drm_proc_list[] = {
{ {"name", drm_name_info},
"name", drm_name_info}, { {"mem", drm_mem_info},
"mem", drm_mem_info}, { {"vm", drm_vm_info},
"vm", drm_vm_info}, { {"clients", drm_clients_info},
"clients", drm_clients_info}, { {"queues", drm_queues_info},
"queues", drm_queues_info}, { {"bufs", drm_bufs_info},
"bufs", drm_bufs_info},
#if DRM_DEBUG_CODE #if DRM_DEBUG_CODE
{ {"vma", drm_vma_info},
"vma", drm_vma_info},
#endif #endif
}; };
......
...@@ -93,8 +93,8 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev, ...@@ -93,8 +93,8 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
dev->driver = driver; dev->driver = driver;
if (dev->driver->preinit) if (dev->driver->load)
if ((retcode = dev->driver->preinit(dev, ent->driver_data))) if ((retcode = dev->driver->load(dev, ent->driver_data)))
goto error_out_unreg; goto error_out_unreg;
if (drm_core_has_AGP(dev)) { if (drm_core_has_AGP(dev)) {
...@@ -124,47 +124,10 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev, ...@@ -124,47 +124,10 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
return 0; return 0;
error_out_unreg: error_out_unreg:
drm_takedown(dev); drm_lastclose(dev);
return retcode; return retcode;
} }
/**
* File \c open operation.
*
* \param inode device inode.
* \param filp file pointer.
*
* Puts the dev->fops corresponding to the device minor number into
* \p filp, call the \c open method, and restore the file operations.
*/
int drm_stub_open(struct inode *inode, struct file *filp)
{
drm_device_t *dev = NULL;
int minor = iminor(inode);
int err = -ENODEV;
struct file_operations *old_fops;
DRM_DEBUG("\n");
if (!((minor >= 0) && (minor < drm_cards_limit)))
return -ENODEV;
if (!drm_heads[minor])
return -ENODEV;
if (!(dev = drm_heads[minor]->dev))
return -ENODEV;
old_fops = filp->f_op;
filp->f_op = fops_get(&dev->driver->fops);
if (filp->f_op->open && (err = filp->f_op->open(inode, filp))) {
fops_put(filp->f_op);
filp->f_op = fops_get(old_fops);
}
fops_put(old_fops);
return err;
}
/** /**
* Get a secondary minor number. * Get a secondary minor number.
...@@ -200,11 +163,7 @@ static int drm_get_head(drm_device_t * dev, drm_head_t * head) ...@@ -200,11 +163,7 @@ static int drm_get_head(drm_device_t * dev, drm_head_t * head)
goto err_g1; goto err_g1;
} }
head->dev_class = drm_sysfs_device_add(drm_class, head->dev_class = drm_sysfs_device_add(drm_class, head);
MKDEV(DRM_MAJOR,
minor),
&dev->pdev->dev,
"card%d", minor);
if (IS_ERR(head->dev_class)) { if (IS_ERR(head->dev_class)) {
printk(KERN_ERR printk(KERN_ERR
"DRM: Error sysfs_device_add.\n"); "DRM: Error sysfs_device_add.\n");
...@@ -259,10 +218,9 @@ int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent, ...@@ -259,10 +218,9 @@ int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
if ((ret = drm_get_head(dev, &dev->primary))) if ((ret = drm_get_head(dev, &dev->primary)))
goto err_g1; goto err_g1;
/* postinit is a required function to display the signon banner */ DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
/* drivers add secondary heads here if needed */ driver->name, driver->major, driver->minor, driver->patchlevel,
if ((ret = dev->driver->postinit(dev, ent->driver_data))) driver->date, dev->primary.minor);
goto err_g1;
return 0; return 0;
...@@ -318,10 +276,9 @@ int drm_put_head(drm_head_t * head) ...@@ -318,10 +276,9 @@ int drm_put_head(drm_head_t * head)
DRM_DEBUG("release secondary minor %d\n", minor); DRM_DEBUG("release secondary minor %d\n", minor);
drm_proc_cleanup(minor, drm_proc_root, head->dev_root); drm_proc_cleanup(minor, drm_proc_root, head->dev_root);
drm_sysfs_device_remove(MKDEV(DRM_MAJOR, head->minor)); drm_sysfs_device_remove(head->dev_class);
*head = (drm_head_t) { *head = (drm_head_t) {.dev = NULL};
.dev = NULL};
drm_heads[minor] = NULL; drm_heads[minor] = NULL;
......
...@@ -15,8 +15,6 @@ ...@@ -15,8 +15,6 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/kdev_t.h> #include <linux/kdev_t.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/slab.h>
#include <linux/string.h>
#include "drm_core.h" #include "drm_core.h"
#include "drmP.h" #include "drmP.h"
...@@ -28,15 +26,11 @@ struct drm_sysfs_class { ...@@ -28,15 +26,11 @@ struct drm_sysfs_class {
#define to_drm_sysfs_class(d) container_of(d, struct drm_sysfs_class, class) #define to_drm_sysfs_class(d) container_of(d, struct drm_sysfs_class, class)
struct simple_dev { struct simple_dev {
struct list_head node;
dev_t dev; dev_t dev;
struct class_device class_dev; struct class_device class_dev;
}; };
#define to_simple_dev(d) container_of(d, struct simple_dev, class_dev) #define to_simple_dev(d) container_of(d, struct simple_dev, class_dev)
static LIST_HEAD(simple_dev_list);
static DEFINE_SPINLOCK(simple_dev_list_lock);
static void release_simple_dev(struct class_device *class_dev) static void release_simple_dev(struct class_device *class_dev)
{ {
struct simple_dev *s_dev = to_simple_dev(class_dev); struct simple_dev *s_dev = to_simple_dev(class_dev);
...@@ -124,6 +118,18 @@ void drm_sysfs_destroy(struct drm_sysfs_class *cs) ...@@ -124,6 +118,18 @@ void drm_sysfs_destroy(struct drm_sysfs_class *cs)
class_unregister(&cs->class); class_unregister(&cs->class);
} }
static ssize_t show_dri(struct class_device *class_device, char *buf)
{
drm_device_t * dev = ((drm_head_t *)class_get_devdata(class_device))->dev;
if (dev->driver->dri_library_name)
return dev->driver->dri_library_name(dev, buf);
return snprintf(buf, PAGE_SIZE, "%s\n", dev->driver->pci_driver.name);
}
static struct class_device_attribute class_device_attrs[] = {
__ATTR(dri_library_name, S_IRUGO, show_dri, NULL),
};
/** /**
* drm_sysfs_device_add - adds a class device to sysfs for a character driver * drm_sysfs_device_add - adds a class device to sysfs for a character driver
* @cs: pointer to the struct drm_sysfs_class that this device should be registered to. * @cs: pointer to the struct drm_sysfs_class that this device should be registered to.
...@@ -138,13 +144,11 @@ void drm_sysfs_destroy(struct drm_sysfs_class *cs) ...@@ -138,13 +144,11 @@ void drm_sysfs_destroy(struct drm_sysfs_class *cs)
* Note: the struct drm_sysfs_class passed to this function must have previously been * Note: the struct drm_sysfs_class passed to this function must have previously been
* created with a call to drm_sysfs_create(). * created with a call to drm_sysfs_create().
*/ */
struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs, dev_t dev, struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs,
struct device *device, drm_head_t *head)
const char *fmt, ...)
{ {
va_list args;
struct simple_dev *s_dev = NULL; struct simple_dev *s_dev = NULL;
int retval; int i, retval;
if ((cs == NULL) || (IS_ERR(cs))) { if ((cs == NULL) || (IS_ERR(cs))) {
retval = -ENODEV; retval = -ENODEV;
...@@ -158,26 +162,23 @@ struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs, dev_t dev, ...@@ -158,26 +162,23 @@ struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs, dev_t dev,
} }
memset(s_dev, 0x00, sizeof(*s_dev)); memset(s_dev, 0x00, sizeof(*s_dev));
s_dev->dev = dev; s_dev->dev = MKDEV(DRM_MAJOR, head->minor);
s_dev->class_dev.dev = device; s_dev->class_dev.dev = &(head->dev->pdev)->dev;
s_dev->class_dev.class = &cs->class; s_dev->class_dev.class = &cs->class;
va_start(args, fmt); snprintf(s_dev->class_dev.class_id, BUS_ID_SIZE, "card%d", head->minor);
vsnprintf(s_dev->class_dev.class_id, BUS_ID_SIZE, fmt, args);
va_end(args);
retval = class_device_register(&s_dev->class_dev); retval = class_device_register(&s_dev->class_dev);
if (retval) if (retval)
goto error; goto error;
class_device_create_file(&s_dev->class_dev, &cs->attr); class_device_create_file(&s_dev->class_dev, &cs->attr);
class_set_devdata(&s_dev->class_dev, head);
spin_lock(&simple_dev_list_lock); for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
list_add(&s_dev->node, &simple_dev_list); class_device_create_file(&s_dev->class_dev, &class_device_attrs[i]);
spin_unlock(&simple_dev_list_lock);
return &s_dev->class_dev; return &s_dev->class_dev;
error: error:
kfree(s_dev); kfree(s_dev);
return ERR_PTR(retval); return ERR_PTR(retval);
} }
...@@ -189,23 +190,12 @@ struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs, dev_t dev, ...@@ -189,23 +190,12 @@ struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs, dev_t dev,
* This call unregisters and cleans up a class device that was created with a * This call unregisters and cleans up a class device that was created with a
* call to drm_sysfs_device_add() * call to drm_sysfs_device_add()
*/ */
void drm_sysfs_device_remove(dev_t dev) void drm_sysfs_device_remove(struct class_device *class_dev)
{ {
struct simple_dev *s_dev = NULL; struct simple_dev *s_dev = to_simple_dev(class_dev);
int found = 0; int i;
spin_lock(&simple_dev_list_lock); for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
list_for_each_entry(s_dev, &simple_dev_list, node) { class_device_remove_file(&s_dev->class_dev, &class_device_attrs[i]);
if (s_dev->dev == dev) {
found = 1;
break;
}
}
if (found) {
list_del(&s_dev->node);
spin_unlock(&simple_dev_list_lock);
class_device_unregister(&s_dev->class_dev); class_device_unregister(&s_dev->class_dev);
} else {
spin_unlock(&simple_dev_list_lock);
}
} }
...@@ -114,7 +114,6 @@ static int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma) ...@@ -114,7 +114,6 @@ static int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
static struct file_operations i810_buffer_fops = { static struct file_operations i810_buffer_fops = {
.open = drm_open, .open = drm_open,
.flush = drm_flush,
.release = drm_release, .release = drm_release,
.ioctl = drm_ioctl, .ioctl = drm_ioctl,
.mmap = i810_mmap_buffers, .mmap = i810_mmap_buffers,
...@@ -1319,12 +1318,24 @@ static int i810_flip_bufs(struct inode *inode, struct file *filp, ...@@ -1319,12 +1318,24 @@ static int i810_flip_bufs(struct inode *inode, struct file *filp,
return 0; return 0;
} }
void i810_driver_pretakedown(drm_device_t * dev) int i810_driver_load(drm_device_t *dev, unsigned long flags)
{
/* i810 has 4 more counters */
dev->counters += 4;
dev->types[6] = _DRM_STAT_IRQ;
dev->types[7] = _DRM_STAT_PRIMARY;
dev->types[8] = _DRM_STAT_SECONDARY;
dev->types[9] = _DRM_STAT_DMA;
return 0;
}
void i810_driver_lastclose(drm_device_t * dev)
{ {
i810_dma_cleanup(dev); i810_dma_cleanup(dev);
} }
void i810_driver_prerelease(drm_device_t * dev, DRMFILE filp) void i810_driver_preclose(drm_device_t * dev, DRMFILE filp)
{ {
if (dev->dev_private) { if (dev->dev_private) {
drm_i810_private_t *dev_priv = dev->dev_private; drm_i810_private_t *dev_priv = dev->dev_private;
...@@ -1334,7 +1345,7 @@ void i810_driver_prerelease(drm_device_t * dev, DRMFILE filp) ...@@ -1334,7 +1345,7 @@ void i810_driver_prerelease(drm_device_t * dev, DRMFILE filp)
} }
} }
void i810_driver_release(drm_device_t * dev, struct file *filp) void i810_driver_reclaim_buffers_locked(drm_device_t * dev, struct file *filp)
{ {
i810_reclaim_buffers(dev, filp); i810_reclaim_buffers(dev, filp);
} }
...@@ -1346,21 +1357,21 @@ int i810_driver_dma_quiescent(drm_device_t * dev) ...@@ -1346,21 +1357,21 @@ int i810_driver_dma_quiescent(drm_device_t * dev)
} }
drm_ioctl_desc_t i810_ioctls[] = { drm_ioctl_desc_t i810_ioctls[] = {
[DRM_IOCTL_NR(DRM_I810_INIT)] = {i810_dma_init, 1, 1}, [DRM_IOCTL_NR(DRM_I810_INIT)] = {i810_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_I810_VERTEX)] = {i810_dma_vertex, 1, 0}, [DRM_IOCTL_NR(DRM_I810_VERTEX)] = {i810_dma_vertex, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I810_CLEAR)] = {i810_clear_bufs, 1, 0}, [DRM_IOCTL_NR(DRM_I810_CLEAR)] = {i810_clear_bufs, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I810_FLUSH)] = {i810_flush_ioctl, 1, 0}, [DRM_IOCTL_NR(DRM_I810_FLUSH)] = {i810_flush_ioctl, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I810_GETAGE)] = {i810_getage, 1, 0}, [DRM_IOCTL_NR(DRM_I810_GETAGE)] = {i810_getage, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I810_GETBUF)] = {i810_getbuf, 1, 0}, [DRM_IOCTL_NR(DRM_I810_GETBUF)] = {i810_getbuf, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I810_SWAP)] = {i810_swap_bufs, 1, 0}, [DRM_IOCTL_NR(DRM_I810_SWAP)] = {i810_swap_bufs, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I810_COPY)] = {i810_copybuf, 1, 0}, [DRM_IOCTL_NR(DRM_I810_COPY)] = {i810_copybuf, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I810_DOCOPY)] = {i810_docopy, 1, 0}, [DRM_IOCTL_NR(DRM_I810_DOCOPY)] = {i810_docopy, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I810_OV0INFO)] = {i810_ov0_info, 1, 0}, [DRM_IOCTL_NR(DRM_I810_OV0INFO)] = {i810_ov0_info, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I810_FSTATUS)] = {i810_fstatus, 1, 0}, [DRM_IOCTL_NR(DRM_I810_FSTATUS)] = {i810_fstatus, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I810_OV0FLIP)] = {i810_ov0_flip, 1, 0}, [DRM_IOCTL_NR(DRM_I810_OV0FLIP)] = {i810_ov0_flip, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I810_MC)] = {i810_dma_mc, 1, 1}, [DRM_IOCTL_NR(DRM_I810_MC)] = {i810_dma_mc, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_I810_RSTATUS)] = {i810_rstatus, 1, 0}, [DRM_IOCTL_NR(DRM_I810_RSTATUS)] = {i810_rstatus, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I810_FLIP)] = {i810_flip_bufs, 1, 0} [DRM_IOCTL_NR(DRM_I810_FLIP)] = {i810_flip_bufs, DRM_AUTH}
}; };
int i810_max_ioctl = DRM_ARRAY_SIZE(i810_ioctls); int i810_max_ioctl = DRM_ARRAY_SIZE(i810_ioctls);
......
...@@ -38,38 +38,6 @@ ...@@ -38,38 +38,6 @@
#include "drm_pciids.h" #include "drm_pciids.h"
static int postinit(struct drm_device *dev, unsigned long flags)
{
/* i810 has 4 more counters */
dev->counters += 4;
dev->types[6] = _DRM_STAT_IRQ;
dev->types[7] = _DRM_STAT_PRIMARY;
dev->types[8] = _DRM_STAT_SECONDARY;
dev->types[9] = _DRM_STAT_DMA;
DRM_INFO("Initialized %s %d.%d.%d %s on minor %d: %s\n",
DRIVER_NAME,
DRIVER_MAJOR,
DRIVER_MINOR,
DRIVER_PATCHLEVEL,
DRIVER_DATE, dev->primary.minor, pci_pretty_name(dev->pdev)
);
return 0;
}
static int version(drm_version_t * version)
{
int len;
version->version_major = DRIVER_MAJOR;
version->version_minor = DRIVER_MINOR;
version->version_patchlevel = DRIVER_PATCHLEVEL;
DRM_COPY(version->name, DRIVER_NAME);
DRM_COPY(version->date, DRIVER_DATE);
DRM_COPY(version->desc, DRIVER_DESC);
return 0;
}
static struct pci_device_id pciidlist[] = { static struct pci_device_id pciidlist[] = {
i810_PCI_IDS i810_PCI_IDS
}; };
...@@ -79,16 +47,14 @@ static struct drm_driver driver = { ...@@ -79,16 +47,14 @@ static struct drm_driver driver = {
DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR |
DRIVER_HAVE_DMA | DRIVER_DMA_QUEUE, DRIVER_HAVE_DMA | DRIVER_DMA_QUEUE,
.dev_priv_size = sizeof(drm_i810_buf_priv_t), .dev_priv_size = sizeof(drm_i810_buf_priv_t),
.pretakedown = i810_driver_pretakedown, .load = i810_driver_load,
.prerelease = i810_driver_prerelease, .lastclose = i810_driver_lastclose,
.preclose = i810_driver_preclose,
.device_is_agp = i810_driver_device_is_agp, .device_is_agp = i810_driver_device_is_agp,
.release = i810_driver_release, .reclaim_buffers_locked = i810_driver_reclaim_buffers_locked,
.dma_quiescent = i810_driver_dma_quiescent, .dma_quiescent = i810_driver_dma_quiescent,
.reclaim_buffers = i810_reclaim_buffers,
.get_map_ofs = drm_core_get_map_ofs, .get_map_ofs = drm_core_get_map_ofs,
.get_reg_ofs = drm_core_get_reg_ofs, .get_reg_ofs = drm_core_get_reg_ofs,
.postinit = postinit,
.version = version,
.ioctls = i810_ioctls, .ioctls = i810_ioctls,
.fops = { .fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
...@@ -98,13 +64,19 @@ static struct drm_driver driver = { ...@@ -98,13 +64,19 @@ static struct drm_driver driver = {
.mmap = drm_mmap, .mmap = drm_mmap,
.poll = drm_poll, .poll = drm_poll,
.fasync = drm_fasync, .fasync = drm_fasync,
} },
,
.pci_driver = { .pci_driver = {
.name = DRIVER_NAME, .name = DRIVER_NAME,
.id_table = pciidlist, .id_table = pciidlist,
} },
,
.name = DRIVER_NAME,
.desc = DRIVER_DESC,
.date = DRIVER_DATE,
.major = DRIVER_MAJOR,
.minor = DRIVER_MINOR,
.patchlevel = DRIVER_PATCHLEVEL,
}; };
static int __init i810_init(void) static int __init i810_init(void)
......
...@@ -116,9 +116,13 @@ typedef struct drm_i810_private { ...@@ -116,9 +116,13 @@ typedef struct drm_i810_private {
extern void i810_reclaim_buffers(drm_device_t * dev, struct file *filp); extern void i810_reclaim_buffers(drm_device_t * dev, struct file *filp);
extern int i810_driver_dma_quiescent(drm_device_t * dev); extern int i810_driver_dma_quiescent(drm_device_t * dev);
extern void i810_driver_release(drm_device_t * dev, struct file *filp); extern void i810_driver_reclaim_buffers_locked(drm_device_t * dev,
extern void i810_driver_pretakedown(drm_device_t * dev); struct file *filp);
extern void i810_driver_prerelease(drm_device_t * dev, DRMFILE filp); extern int i810_driver_load(struct drm_device *, unsigned long flags);
extern void i810_driver_lastclose(drm_device_t * dev);
extern void i810_driver_preclose(drm_device_t * dev, DRMFILE filp);
extern void i810_driver_reclaim_buffers_locked(drm_device_t * dev,
struct file *filp);
extern int i810_driver_device_is_agp(drm_device_t * dev); extern int i810_driver_device_is_agp(drm_device_t * dev);
extern drm_ioctl_desc_t i810_ioctls[]; extern drm_ioctl_desc_t i810_ioctls[];
......
...@@ -116,7 +116,6 @@ static int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma) ...@@ -116,7 +116,6 @@ static int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
static struct file_operations i830_buffer_fops = { static struct file_operations i830_buffer_fops = {
.open = drm_open, .open = drm_open,
.flush = drm_flush,
.release = drm_release, .release = drm_release,
.ioctl = drm_ioctl, .ioctl = drm_ioctl,
.mmap = i830_mmap_buffers, .mmap = i830_mmap_buffers,
...@@ -1517,12 +1516,24 @@ static int i830_setparam(struct inode *inode, struct file *filp, ...@@ -1517,12 +1516,24 @@ static int i830_setparam(struct inode *inode, struct file *filp,
return 0; return 0;
} }
void i830_driver_pretakedown(drm_device_t * dev) int i830_driver_load(drm_device_t *dev, unsigned long flags)
{
/* i830 has 4 more counters */
dev->counters += 4;
dev->types[6] = _DRM_STAT_IRQ;
dev->types[7] = _DRM_STAT_PRIMARY;
dev->types[8] = _DRM_STAT_SECONDARY;
dev->types[9] = _DRM_STAT_DMA;
return 0;
}
void i830_driver_lastclose(drm_device_t * dev)
{ {
i830_dma_cleanup(dev); i830_dma_cleanup(dev);
} }
void i830_driver_prerelease(drm_device_t * dev, DRMFILE filp) void i830_driver_preclose(drm_device_t * dev, DRMFILE filp)
{ {
if (dev->dev_private) { if (dev->dev_private) {
drm_i830_private_t *dev_priv = dev->dev_private; drm_i830_private_t *dev_priv = dev->dev_private;
...@@ -1532,7 +1543,7 @@ void i830_driver_prerelease(drm_device_t * dev, DRMFILE filp) ...@@ -1532,7 +1543,7 @@ void i830_driver_prerelease(drm_device_t * dev, DRMFILE filp)
} }
} }
void i830_driver_release(drm_device_t * dev, struct file *filp) void i830_driver_reclaim_buffers_locked(drm_device_t * dev, struct file *filp)
{ {
i830_reclaim_buffers(dev, filp); i830_reclaim_buffers(dev, filp);
} }
...@@ -1544,20 +1555,20 @@ int i830_driver_dma_quiescent(drm_device_t * dev) ...@@ -1544,20 +1555,20 @@ int i830_driver_dma_quiescent(drm_device_t * dev)
} }
drm_ioctl_desc_t i830_ioctls[] = { drm_ioctl_desc_t i830_ioctls[] = {
[DRM_IOCTL_NR(DRM_I830_INIT)] = {i830_dma_init, 1, 1}, [DRM_IOCTL_NR(DRM_I830_INIT)] = {i830_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_I830_VERTEX)] = {i830_dma_vertex, 1, 0}, [DRM_IOCTL_NR(DRM_I830_VERTEX)] = {i830_dma_vertex, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I830_CLEAR)] = {i830_clear_bufs, 1, 0}, [DRM_IOCTL_NR(DRM_I830_CLEAR)] = {i830_clear_bufs, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I830_FLUSH)] = {i830_flush_ioctl, 1, 0}, [DRM_IOCTL_NR(DRM_I830_FLUSH)] = {i830_flush_ioctl, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I830_GETAGE)] = {i830_getage, 1, 0}, [DRM_IOCTL_NR(DRM_I830_GETAGE)] = {i830_getage, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I830_GETBUF)] = {i830_getbuf, 1, 0}, [DRM_IOCTL_NR(DRM_I830_GETBUF)] = {i830_getbuf, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I830_SWAP)] = {i830_swap_bufs, 1, 0}, [DRM_IOCTL_NR(DRM_I830_SWAP)] = {i830_swap_bufs, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I830_COPY)] = {i830_copybuf, 1, 0}, [DRM_IOCTL_NR(DRM_I830_COPY)] = {i830_copybuf, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I830_DOCOPY)] = {i830_docopy, 1, 0}, [DRM_IOCTL_NR(DRM_I830_DOCOPY)] = {i830_docopy, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I830_FLIP)] = {i830_flip_bufs, 1, 0}, [DRM_IOCTL_NR(DRM_I830_FLIP)] = {i830_flip_bufs, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I830_IRQ_EMIT)] = {i830_irq_emit, 1, 0}, [DRM_IOCTL_NR(DRM_I830_IRQ_EMIT)] = {i830_irq_emit, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I830_IRQ_WAIT)] = {i830_irq_wait, 1, 0}, [DRM_IOCTL_NR(DRM_I830_IRQ_WAIT)] = {i830_irq_wait, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I830_GETPARAM)] = {i830_getparam, 1, 0}, [DRM_IOCTL_NR(DRM_I830_GETPARAM)] = {i830_getparam, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I830_SETPARAM)] = {i830_setparam, 1, 0} [DRM_IOCTL_NR(DRM_I830_SETPARAM)] = {i830_setparam, DRM_AUTH}
}; };
int i830_max_ioctl = DRM_ARRAY_SIZE(i830_ioctls); int i830_max_ioctl = DRM_ARRAY_SIZE(i830_ioctls);
......
...@@ -40,37 +40,6 @@ ...@@ -40,37 +40,6 @@
#include "drm_pciids.h" #include "drm_pciids.h"
static int postinit(struct drm_device *dev, unsigned long flags)
{
dev->counters += 4;
dev->types[6] = _DRM_STAT_IRQ;
dev->types[7] = _DRM_STAT_PRIMARY;
dev->types[8] = _DRM_STAT_SECONDARY;
dev->types[9] = _DRM_STAT_DMA;
DRM_INFO("Initialized %s %d.%d.%d %s on minor %d: %s\n",
DRIVER_NAME,
DRIVER_MAJOR,
DRIVER_MINOR,
DRIVER_PATCHLEVEL,
DRIVER_DATE, dev->primary.minor, pci_pretty_name(dev->pdev)
);
return 0;
}
static int version(drm_version_t * version)
{
int len;
version->version_major = DRIVER_MAJOR;
version->version_minor = DRIVER_MINOR;
version->version_patchlevel = DRIVER_PATCHLEVEL;
DRM_COPY(version->name, DRIVER_NAME);
DRM_COPY(version->date, DRIVER_DATE);
DRM_COPY(version->desc, DRIVER_DESC);
return 0;
}
static struct pci_device_id pciidlist[] = { static struct pci_device_id pciidlist[] = {
i830_PCI_IDS i830_PCI_IDS
}; };
...@@ -83,12 +52,12 @@ static struct drm_driver driver = { ...@@ -83,12 +52,12 @@ static struct drm_driver driver = {
.driver_features |= DRIVER_HAVE_IRQ | DRIVER_SHARED_IRQ, .driver_features |= DRIVER_HAVE_IRQ | DRIVER_SHARED_IRQ,
#endif #endif
.dev_priv_size = sizeof(drm_i830_buf_priv_t), .dev_priv_size = sizeof(drm_i830_buf_priv_t),
.pretakedown = i830_driver_pretakedown, .load = i830_driver_load,
.prerelease = i830_driver_prerelease, .lastclose = i830_driver_lastclose,
.preclose = i830_driver_preclose,
.device_is_agp = i830_driver_device_is_agp, .device_is_agp = i830_driver_device_is_agp,
.release = i830_driver_release, .reclaim_buffers_locked = i830_driver_reclaim_buffers_locked,
.dma_quiescent = i830_driver_dma_quiescent, .dma_quiescent = i830_driver_dma_quiescent,
.reclaim_buffers = i830_reclaim_buffers,
.get_map_ofs = drm_core_get_map_ofs, .get_map_ofs = drm_core_get_map_ofs,
.get_reg_ofs = drm_core_get_reg_ofs, .get_reg_ofs = drm_core_get_reg_ofs,
#if USE_IRQS #if USE_IRQS
...@@ -97,8 +66,6 @@ static struct drm_driver driver = { ...@@ -97,8 +66,6 @@ static struct drm_driver driver = {
.irq_uninstall = i830_driver_irq_uninstall, .irq_uninstall = i830_driver_irq_uninstall,
.irq_handler = i830_driver_irq_handler, .irq_handler = i830_driver_irq_handler,
#endif #endif
.postinit = postinit,
.version = version,
.ioctls = i830_ioctls, .ioctls = i830_ioctls,
.fops = { .fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
...@@ -108,13 +75,19 @@ static struct drm_driver driver = { ...@@ -108,13 +75,19 @@ static struct drm_driver driver = {
.mmap = drm_mmap, .mmap = drm_mmap,
.poll = drm_poll, .poll = drm_poll,
.fasync = drm_fasync, .fasync = drm_fasync,
} },
,
.pci_driver = { .pci_driver = {
.name = DRIVER_NAME, .name = DRIVER_NAME,
.id_table = pciidlist, .id_table = pciidlist,
} },
.name = DRIVER_NAME,
.desc = DRIVER_DESC,
.date = DRIVER_DATE,
.major = DRIVER_MAJOR,
.minor = DRIVER_MINOR,
.patchlevel = DRIVER_PATCHLEVEL,
}; };
static int __init i830_init(void) static int __init i830_init(void)
......
...@@ -136,10 +136,12 @@ extern irqreturn_t i830_driver_irq_handler(DRM_IRQ_ARGS); ...@@ -136,10 +136,12 @@ extern irqreturn_t i830_driver_irq_handler(DRM_IRQ_ARGS);
extern void i830_driver_irq_preinstall(drm_device_t * dev); extern void i830_driver_irq_preinstall(drm_device_t * dev);
extern void i830_driver_irq_postinstall(drm_device_t * dev); extern void i830_driver_irq_postinstall(drm_device_t * dev);
extern void i830_driver_irq_uninstall(drm_device_t * dev); extern void i830_driver_irq_uninstall(drm_device_t * dev);
extern void i830_driver_pretakedown(drm_device_t * dev); extern int i830_driver_load(struct drm_device *, unsigned long flags);
extern void i830_driver_release(drm_device_t * dev, struct file *filp); extern void i830_driver_preclose(drm_device_t * dev, DRMFILE filp);
extern void i830_driver_lastclose(drm_device_t * dev);
extern void i830_driver_reclaim_buffers_locked(drm_device_t * dev,
struct file *filp);
extern int i830_driver_dma_quiescent(drm_device_t * dev); extern int i830_driver_dma_quiescent(drm_device_t * dev);
extern void i830_driver_prerelease(drm_device_t * dev, DRMFILE filp);
extern int i830_driver_device_is_agp(drm_device_t * dev); extern int i830_driver_device_is_agp(drm_device_t * dev);
#define I830_READ(reg) DRM_READ32(dev_priv->mmio_map, reg) #define I830_READ(reg) DRM_READ32(dev_priv->mmio_map, reg)
......
/* i915_dma.c -- DMA support for the I915 -*- linux-c -*- /* i915_dma.c -- DMA support for the I915 -*- linux-c -*-
*/ */
/************************************************************************** /*
*
* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved. * All Rights Reserved.
* *
...@@ -25,7 +24,7 @@ ...@@ -25,7 +24,7 @@
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
**************************************************************************/ */
#include "drmP.h" #include "drmP.h"
#include "drm.h" #include "drm.h"
...@@ -196,7 +195,7 @@ static int i915_initialize(drm_device_t * dev, ...@@ -196,7 +195,7 @@ static int i915_initialize(drm_device_t * dev,
return 0; return 0;
} }
static int i915_resume(drm_device_t * dev) static int i915_dma_resume(drm_device_t * dev)
{ {
drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
...@@ -253,7 +252,7 @@ static int i915_dma_init(DRM_IOCTL_ARGS) ...@@ -253,7 +252,7 @@ static int i915_dma_init(DRM_IOCTL_ARGS)
retcode = i915_dma_cleanup(dev); retcode = i915_dma_cleanup(dev);
break; break;
case I915_RESUME_DMA: case I915_RESUME_DMA:
retcode = i915_resume(dev); retcode = i915_dma_resume(dev);
break; break;
default: default:
retcode = -EINVAL; retcode = -EINVAL;
...@@ -654,6 +653,9 @@ static int i915_getparam(DRM_IOCTL_ARGS) ...@@ -654,6 +653,9 @@ static int i915_getparam(DRM_IOCTL_ARGS)
case I915_PARAM_ALLOW_BATCHBUFFER: case I915_PARAM_ALLOW_BATCHBUFFER:
value = dev_priv->allow_batchbuffer ? 1 : 0; value = dev_priv->allow_batchbuffer ? 1 : 0;
break; break;
case I915_PARAM_LAST_DISPATCH:
value = READ_BREADCRUMB(dev_priv);
break;
default: default:
DRM_ERROR("Unkown parameter %d\n", param.param); DRM_ERROR("Unkown parameter %d\n", param.param);
return DRM_ERR(EINVAL); return DRM_ERR(EINVAL);
...@@ -699,7 +701,19 @@ static int i915_setparam(DRM_IOCTL_ARGS) ...@@ -699,7 +701,19 @@ static int i915_setparam(DRM_IOCTL_ARGS)
return 0; return 0;
} }
void i915_driver_pretakedown(drm_device_t * dev) int i915_driver_load(drm_device_t *dev, unsigned long flags)
{
/* i915 has 4 more counters */
dev->counters += 4;
dev->types[6] = _DRM_STAT_IRQ;
dev->types[7] = _DRM_STAT_PRIMARY;
dev->types[8] = _DRM_STAT_SECONDARY;
dev->types[9] = _DRM_STAT_DMA;
return 0;
}
void i915_driver_lastclose(drm_device_t * dev)
{ {
if (dev->dev_private) { if (dev->dev_private) {
drm_i915_private_t *dev_priv = dev->dev_private; drm_i915_private_t *dev_priv = dev->dev_private;
...@@ -708,7 +722,7 @@ void i915_driver_pretakedown(drm_device_t * dev) ...@@ -708,7 +722,7 @@ void i915_driver_pretakedown(drm_device_t * dev)
i915_dma_cleanup(dev); i915_dma_cleanup(dev);
} }
void i915_driver_prerelease(drm_device_t * dev, DRMFILE filp) void i915_driver_preclose(drm_device_t * dev, DRMFILE filp)
{ {
if (dev->dev_private) { if (dev->dev_private) {
drm_i915_private_t *dev_priv = dev->dev_private; drm_i915_private_t *dev_priv = dev->dev_private;
...@@ -717,18 +731,18 @@ void i915_driver_prerelease(drm_device_t * dev, DRMFILE filp) ...@@ -717,18 +731,18 @@ void i915_driver_prerelease(drm_device_t * dev, DRMFILE filp)
} }
drm_ioctl_desc_t i915_ioctls[] = { drm_ioctl_desc_t i915_ioctls[] = {
[DRM_IOCTL_NR(DRM_I915_INIT)] = {i915_dma_init, 1, 1}, [DRM_IOCTL_NR(DRM_I915_INIT)] = {i915_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_I915_FLUSH)] = {i915_flush_ioctl, 1, 0}, [DRM_IOCTL_NR(DRM_I915_FLUSH)] = {i915_flush_ioctl, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I915_FLIP)] = {i915_flip_bufs, 1, 0}, [DRM_IOCTL_NR(DRM_I915_FLIP)] = {i915_flip_bufs, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I915_BATCHBUFFER)] = {i915_batchbuffer, 1, 0}, [DRM_IOCTL_NR(DRM_I915_BATCHBUFFER)] = {i915_batchbuffer, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I915_IRQ_EMIT)] = {i915_irq_emit, 1, 0}, [DRM_IOCTL_NR(DRM_I915_IRQ_EMIT)] = {i915_irq_emit, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I915_IRQ_WAIT)] = {i915_irq_wait, 1, 0}, [DRM_IOCTL_NR(DRM_I915_IRQ_WAIT)] = {i915_irq_wait, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I915_GETPARAM)] = {i915_getparam, 1, 0}, [DRM_IOCTL_NR(DRM_I915_GETPARAM)] = {i915_getparam, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I915_SETPARAM)] = {i915_setparam, 1, 1}, [DRM_IOCTL_NR(DRM_I915_SETPARAM)] = {i915_setparam, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_I915_ALLOC)] = {i915_mem_alloc, 1, 0}, [DRM_IOCTL_NR(DRM_I915_ALLOC)] = {i915_mem_alloc, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I915_FREE)] = {i915_mem_free, 1, 0}, [DRM_IOCTL_NR(DRM_I915_FREE)] = {i915_mem_free, DRM_AUTH},
[DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = {i915_mem_init_heap, 1, 1}, [DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = {i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = {i915_cmdbuffer, 1, 0} [DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = {i915_cmdbuffer, DRM_AUTH}
}; };
int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
......
/************************************************************************** /*
*
* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved. * All Rights Reserved.
* *
...@@ -23,7 +22,7 @@ ...@@ -23,7 +22,7 @@
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
**************************************************************************/ */
#ifndef _I915_DRM_H_ #ifndef _I915_DRM_H_
#define _I915_DRM_H_ #define _I915_DRM_H_
...@@ -152,6 +151,7 @@ typedef struct drm_i915_irq_wait { ...@@ -152,6 +151,7 @@ typedef struct drm_i915_irq_wait {
*/ */
#define I915_PARAM_IRQ_ACTIVE 1 #define I915_PARAM_IRQ_ACTIVE 1
#define I915_PARAM_ALLOW_BATCHBUFFER 2 #define I915_PARAM_ALLOW_BATCHBUFFER 2
#define I915_PARAM_LAST_DISPATCH 3
typedef struct drm_i915_getparam { typedef struct drm_i915_getparam {
int param; int param;
......
/* i915_drv.c -- i830,i845,i855,i865,i915 driver -*- linux-c -*- /* i915_drv.c -- i830,i845,i855,i865,i915 driver -*- linux-c -*-
*/ */
/************************************************************************** /*
* *
* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved. * All Rights Reserved.
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
**************************************************************************/ */
#include "drmP.h" #include "drmP.h"
#include "drm.h" #include "drm.h"
...@@ -34,48 +34,22 @@ ...@@ -34,48 +34,22 @@
#include "drm_pciids.h" #include "drm_pciids.h"
static int postinit(struct drm_device *dev, unsigned long flags)
{
dev->counters += 4;
dev->types[6] = _DRM_STAT_IRQ;
dev->types[7] = _DRM_STAT_PRIMARY;
dev->types[8] = _DRM_STAT_SECONDARY;
dev->types[9] = _DRM_STAT_DMA;
DRM_INFO("Initialized %s %d.%d.%d %s on minor %d: %s\n",
DRIVER_NAME,
DRIVER_MAJOR,
DRIVER_MINOR,
DRIVER_PATCHLEVEL,
DRIVER_DATE, dev->primary.minor, pci_pretty_name(dev->pdev)
);
return 0;
}
static int version(drm_version_t * version)
{
int len;
version->version_major = DRIVER_MAJOR;
version->version_minor = DRIVER_MINOR;
version->version_patchlevel = DRIVER_PATCHLEVEL;
DRM_COPY(version->name, DRIVER_NAME);
DRM_COPY(version->date, DRIVER_DATE);
DRM_COPY(version->desc, DRIVER_DESC);
return 0;
}
static struct pci_device_id pciidlist[] = { static struct pci_device_id pciidlist[] = {
i915_PCI_IDS i915_PCI_IDS
}; };
static struct drm_driver driver = { static struct drm_driver driver = {
/* don't use mtrr's here, the Xserver or user space app should
* deal with them for intel hardware.
*/
.driver_features = .driver_features =
DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | /* DRIVER_USE_MTRR |*/
DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED, DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL,
.pretakedown = i915_driver_pretakedown, .load = i915_driver_load,
.prerelease = i915_driver_prerelease, .lastclose = i915_driver_lastclose,
.preclose = i915_driver_preclose,
.device_is_agp = i915_driver_device_is_agp, .device_is_agp = i915_driver_device_is_agp,
.vblank_wait = i915_driver_vblank_wait,
.irq_preinstall = i915_driver_irq_preinstall, .irq_preinstall = i915_driver_irq_preinstall,
.irq_postinstall = i915_driver_irq_postinstall, .irq_postinstall = i915_driver_irq_postinstall,
.irq_uninstall = i915_driver_irq_uninstall, .irq_uninstall = i915_driver_irq_uninstall,
...@@ -83,8 +57,6 @@ static struct drm_driver driver = { ...@@ -83,8 +57,6 @@ static struct drm_driver driver = {
.reclaim_buffers = drm_core_reclaim_buffers, .reclaim_buffers = drm_core_reclaim_buffers,
.get_map_ofs = drm_core_get_map_ofs, .get_map_ofs = drm_core_get_map_ofs,
.get_reg_ofs = drm_core_get_reg_ofs, .get_reg_ofs = drm_core_get_reg_ofs,
.postinit = postinit,
.version = version,
.ioctls = i915_ioctls, .ioctls = i915_ioctls,
.fops = { .fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
...@@ -98,10 +70,18 @@ static struct drm_driver driver = { ...@@ -98,10 +70,18 @@ static struct drm_driver driver = {
.compat_ioctl = i915_compat_ioctl, .compat_ioctl = i915_compat_ioctl,
#endif #endif
}, },
.pci_driver = { .pci_driver = {
.name = DRIVER_NAME, .name = DRIVER_NAME,
.id_table = pciidlist, .id_table = pciidlist,
} },
.name = DRIVER_NAME,
.desc = DRIVER_DESC,
.date = DRIVER_DATE,
.major = DRIVER_MAJOR,
.minor = DRIVER_MINOR,
.patchlevel = DRIVER_PATCHLEVEL,
}; };
static int __init i915_init(void) static int __init i915_init(void)
......
/* i915_drv.h -- Private header for the I915 driver -*- linux-c -*- /* i915_drv.h -- Private header for the I915 driver -*- linux-c -*-
*/ */
/************************************************************************** /*
* *
* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved. * All Rights Reserved.
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
**************************************************************************/ */
#ifndef _I915_DRV_H_ #ifndef _I915_DRV_H_
#define _I915_DRV_H_ #define _I915_DRV_H_
...@@ -37,21 +37,18 @@ ...@@ -37,21 +37,18 @@
#define DRIVER_NAME "i915" #define DRIVER_NAME "i915"
#define DRIVER_DESC "Intel Graphics" #define DRIVER_DESC "Intel Graphics"
#define DRIVER_DATE "20040405" #define DRIVER_DATE "20051209"
/* Interface history: /* Interface history:
* *
* 1.1: Original. * 1.1: Original.
* 1.2: Add Power Management
* 1.3: Add vblank support
*/ */
#define DRIVER_MAJOR 1 #define DRIVER_MAJOR 1
#define DRIVER_MINOR 1 #define DRIVER_MINOR 3
#define DRIVER_PATCHLEVEL 0 #define DRIVER_PATCHLEVEL 0
/* We use our own dma mechanisms, not the drm template code. However,
* the shared IRQ code is useful to us:
*/
#define __HAVE_PM 1
typedef struct _drm_i915_ring_buffer { typedef struct _drm_i915_ring_buffer {
int tail_mask; int tail_mask;
unsigned long Start; unsigned long Start;
...@@ -97,6 +94,7 @@ typedef struct drm_i915_private { ...@@ -97,6 +94,7 @@ typedef struct drm_i915_private {
int tex_lru_log_granularity; int tex_lru_log_granularity;
int allow_batchbuffer; int allow_batchbuffer;
struct mem_block *agp_heap; struct mem_block *agp_heap;
unsigned int sr01, adpa, ppcr, dvob, dvoc, lvds;
} drm_i915_private_t; } drm_i915_private_t;
extern drm_ioctl_desc_t i915_ioctls[]; extern drm_ioctl_desc_t i915_ioctls[];
...@@ -104,14 +102,18 @@ extern int i915_max_ioctl; ...@@ -104,14 +102,18 @@ extern int i915_max_ioctl;
/* i915_dma.c */ /* i915_dma.c */
extern void i915_kernel_lost_context(drm_device_t * dev); extern void i915_kernel_lost_context(drm_device_t * dev);
extern void i915_driver_pretakedown(drm_device_t * dev); extern int i915_driver_load(struct drm_device *, unsigned long flags);
extern void i915_driver_prerelease(drm_device_t * dev, DRMFILE filp); extern void i915_driver_lastclose(drm_device_t * dev);
extern void i915_driver_preclose(drm_device_t * dev, DRMFILE filp);
extern int i915_driver_device_is_agp(drm_device_t * dev); extern int i915_driver_device_is_agp(drm_device_t * dev);
extern long i915_compat_ioctl(struct file *filp, unsigned int cmd,
unsigned long arg);
/* i915_irq.c */ /* i915_irq.c */
extern int i915_irq_emit(DRM_IOCTL_ARGS); extern int i915_irq_emit(DRM_IOCTL_ARGS);
extern int i915_irq_wait(DRM_IOCTL_ARGS); extern int i915_irq_wait(DRM_IOCTL_ARGS);
extern int i915_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence);
extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS); extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS);
extern void i915_driver_irq_preinstall(drm_device_t * dev); extern void i915_driver_irq_preinstall(drm_device_t * dev);
extern void i915_driver_irq_postinstall(drm_device_t * dev); extern void i915_driver_irq_postinstall(drm_device_t * dev);
...@@ -125,13 +127,10 @@ extern void i915_mem_takedown(struct mem_block **heap); ...@@ -125,13 +127,10 @@ extern void i915_mem_takedown(struct mem_block **heap);
extern void i915_mem_release(drm_device_t * dev, extern void i915_mem_release(drm_device_t * dev,
DRMFILE filp, struct mem_block *heap); DRMFILE filp, struct mem_block *heap);
extern long i915_compat_ioctl(struct file *filp, unsigned int cmd, #define I915_READ(reg) DRM_READ32(dev_priv->mmio_map, (reg))
unsigned long arg); #define I915_WRITE(reg,val) DRM_WRITE32(dev_priv->mmio_map, (reg), (val))
#define I915_READ16(reg) DRM_READ16(dev_priv->mmio_map, (reg))
#define I915_READ(reg) DRM_READ32(dev_priv->mmio_map, reg) #define I915_WRITE16(reg,val) DRM_WRITE16(dev_priv->mmio_map, (reg), (val))
#define I915_WRITE(reg,val) DRM_WRITE32(dev_priv->mmio_map, reg, val)
#define I915_READ16(reg) DRM_READ16(dev_priv->mmio_map, reg)
#define I915_WRITE16(reg,val) DRM_WRITE16(dev_priv->mmio_map, reg, val)
#define I915_VERBOSE 0 #define I915_VERBOSE 0
...@@ -195,6 +194,13 @@ extern int i915_wait_ring(drm_device_t * dev, int n, const char *caller); ...@@ -195,6 +194,13 @@ extern int i915_wait_ring(drm_device_t * dev, int n, const char *caller);
#define PPCR 0x61204 #define PPCR 0x61204
#define PPCR_ON (1<<0) #define PPCR_ON (1<<0)
#define DVOB 0x61140
#define DVOB_ON (1<<31)
#define DVOC 0x61160
#define DVOC_ON (1<<31)
#define LVDS 0x61180
#define LVDS_ON (1<<31)
#define ADPA 0x61100 #define ADPA 0x61100
#define ADPA_DPMS_MASK (~(3<<10)) #define ADPA_DPMS_MASK (~(3<<10))
#define ADPA_DPMS_ON (0<<10) #define ADPA_DPMS_ON (0<<10)
...@@ -258,4 +264,6 @@ extern int i915_wait_ring(drm_device_t * dev, int n, const char *caller); ...@@ -258,4 +264,6 @@ extern int i915_wait_ring(drm_device_t * dev, int n, const char *caller);
#define CMD_OP_DESTBUFFER_INFO ((0x3<<29)|(0x1d<<24)|(0x8e<<16)|1) #define CMD_OP_DESTBUFFER_INFO ((0x3<<29)|(0x1d<<24)|(0x8e<<16)|1)
#define READ_BREADCRUMB(dev_priv) (((u32 *)(dev_priv->hw_status_page))[5])
#endif #endif
/* i915_dma.c -- DMA support for the I915 -*- linux-c -*- /* i915_irq.c -- IRQ support for the I915 -*- linux-c -*-
*/ */
/************************************************************************** /*
*
* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved. * All Rights Reserved.
* *
...@@ -25,16 +24,18 @@ ...@@ -25,16 +24,18 @@
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
**************************************************************************/ */
#include "drmP.h" #include "drmP.h"
#include "drm.h" #include "drm.h"
#include "i915_drm.h" #include "i915_drm.h"
#include "i915_drv.h" #include "i915_drv.h"
#define USER_INT_FLAG 0x2 #define USER_INT_FLAG (1<<1)
#define VSYNC_PIPEB_FLAG (1<<5)
#define VSYNC_PIPEA_FLAG (1<<7)
#define MAX_NOPID ((u32)~0) #define MAX_NOPID ((u32)~0)
#define READ_BREADCRUMB(dev_priv) (((u32*)(dev_priv->hw_status_page))[5])
irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS) irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
{ {
...@@ -43,7 +44,7 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS) ...@@ -43,7 +44,7 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
u16 temp; u16 temp;
temp = I915_READ16(I915REG_INT_IDENTITY_R); temp = I915_READ16(I915REG_INT_IDENTITY_R);
temp &= USER_INT_FLAG; temp &= (USER_INT_FLAG | VSYNC_PIPEA_FLAG);
DRM_DEBUG("%s flag=%08x\n", __FUNCTION__, temp); DRM_DEBUG("%s flag=%08x\n", __FUNCTION__, temp);
...@@ -51,8 +52,16 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS) ...@@ -51,8 +52,16 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
return IRQ_NONE; return IRQ_NONE;
I915_WRITE16(I915REG_INT_IDENTITY_R, temp); I915_WRITE16(I915REG_INT_IDENTITY_R, temp);
if (temp & USER_INT_FLAG)
DRM_WAKEUP(&dev_priv->irq_queue); DRM_WAKEUP(&dev_priv->irq_queue);
if (temp & VSYNC_PIPEA_FLAG) {
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
drm_vbl_send_signals(dev);
}
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -102,6 +111,27 @@ static int i915_wait_irq(drm_device_t * dev, int irq_nr) ...@@ -102,6 +111,27 @@ static int i915_wait_irq(drm_device_t * dev, int irq_nr)
return ret; return ret;
} }
int i915_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence)
{
drm_i915_private_t *dev_priv = dev->dev_private;
unsigned int cur_vblank;
int ret = 0;
if (!dev_priv) {
DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
return DRM_ERR(EINVAL);
}
DRM_WAIT_ON(ret, dev->vbl_queue, 3 * DRM_HZ,
(((cur_vblank = atomic_read(&dev->vbl_received))
- *sequence) <= (1<<23)));
*sequence = cur_vblank;
return ret;
}
/* Needs the lock as it touches the ring. /* Needs the lock as it touches the ring.
*/ */
int i915_irq_emit(DRM_IOCTL_ARGS) int i915_irq_emit(DRM_IOCTL_ARGS)
...@@ -165,7 +195,7 @@ void i915_driver_irq_postinstall(drm_device_t * dev) ...@@ -165,7 +195,7 @@ void i915_driver_irq_postinstall(drm_device_t * dev)
{ {
drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
I915_WRITE16(I915REG_INT_ENABLE_R, USER_INT_FLAG); I915_WRITE16(I915REG_INT_ENABLE_R, USER_INT_FLAG | VSYNC_PIPEA_FLAG);
DRM_INIT_WAITQUEUE(&dev_priv->irq_queue); DRM_INIT_WAITQUEUE(&dev_priv->irq_queue);
} }
......
/* i915_mem.c -- Simple agp/fb memory manager for i915 -*- linux-c -*- /* i915_mem.c -- Simple agp/fb memory manager for i915 -*- linux-c -*-
*/ */
/************************************************************************** /*
*
* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved. * All Rights Reserved.
* *
...@@ -25,7 +24,7 @@ ...@@ -25,7 +24,7 @@
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
**************************************************************************/ */
#include "drmP.h" #include "drmP.h"
#include "drm.h" #include "drm.h"
......
This diff is collapsed.
...@@ -38,41 +38,6 @@ ...@@ -38,41 +38,6 @@
#include "drm_pciids.h" #include "drm_pciids.h"
static int mga_driver_device_is_agp(drm_device_t * dev); static int mga_driver_device_is_agp(drm_device_t * dev);
static int postinit(struct drm_device *dev, unsigned long flags)
{
drm_mga_private_t *const dev_priv =
(drm_mga_private_t *) dev->dev_private;
dev_priv->mmio_base = pci_resource_start(dev->pdev, 1);
dev_priv->mmio_size = pci_resource_len(dev->pdev, 1);
dev->counters += 3;
dev->types[6] = _DRM_STAT_IRQ;
dev->types[7] = _DRM_STAT_PRIMARY;
dev->types[8] = _DRM_STAT_SECONDARY;
DRM_INFO("Initialized %s %d.%d.%d %s on minor %d: %s\n",
DRIVER_NAME,
DRIVER_MAJOR,
DRIVER_MINOR,
DRIVER_PATCHLEVEL,
DRIVER_DATE, dev->primary.minor, pci_pretty_name(dev->pdev)
);
return 0;
}
static int version(drm_version_t * version)
{
int len;
version->version_major = DRIVER_MAJOR;
version->version_minor = DRIVER_MINOR;
version->version_patchlevel = DRIVER_PATCHLEVEL;
DRM_COPY(version->name, DRIVER_NAME);
DRM_COPY(version->date, DRIVER_DATE);
DRM_COPY(version->desc, DRIVER_DESC);
return 0;
}
static struct pci_device_id pciidlist[] = { static struct pci_device_id pciidlist[] = {
mga_PCI_IDS mga_PCI_IDS
...@@ -80,12 +45,12 @@ static struct pci_device_id pciidlist[] = { ...@@ -80,12 +45,12 @@ static struct pci_device_id pciidlist[] = {
static struct drm_driver driver = { static struct drm_driver driver = {
.driver_features = .driver_features =
DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA |
DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED |
DRIVER_IRQ_VBL, DRIVER_IRQ_VBL,
.preinit = mga_driver_preinit, .load = mga_driver_load,
.postcleanup = mga_driver_postcleanup, .unload = mga_driver_unload,
.pretakedown = mga_driver_pretakedown, .lastclose = mga_driver_lastclose,
.dma_quiescent = mga_driver_dma_quiescent, .dma_quiescent = mga_driver_dma_quiescent,
.device_is_agp = mga_driver_device_is_agp, .device_is_agp = mga_driver_device_is_agp,
.vblank_wait = mga_driver_vblank_wait, .vblank_wait = mga_driver_vblank_wait,
...@@ -96,8 +61,6 @@ static struct drm_driver driver = { ...@@ -96,8 +61,6 @@ static struct drm_driver driver = {
.reclaim_buffers = drm_core_reclaim_buffers, .reclaim_buffers = drm_core_reclaim_buffers,
.get_map_ofs = drm_core_get_map_ofs, .get_map_ofs = drm_core_get_map_ofs,
.get_reg_ofs = drm_core_get_reg_ofs, .get_reg_ofs = drm_core_get_reg_ofs,
.postinit = postinit,
.version = version,
.ioctls = mga_ioctls, .ioctls = mga_ioctls,
.dma_ioctl = mga_dma_buffers, .dma_ioctl = mga_dma_buffers,
.fops = { .fops = {
...@@ -115,7 +78,14 @@ static struct drm_driver driver = { ...@@ -115,7 +78,14 @@ static struct drm_driver driver = {
.pci_driver = { .pci_driver = {
.name = DRIVER_NAME, .name = DRIVER_NAME,
.id_table = pciidlist, .id_table = pciidlist,
} },
.name = DRIVER_NAME,
.desc = DRIVER_DESC,
.date = DRIVER_DATE,
.major = DRIVER_MAJOR,
.minor = DRIVER_MINOR,
.patchlevel = DRIVER_PATCHLEVEL,
}; };
static int __init mga_init(void) static int __init mga_init(void)
......
...@@ -38,11 +38,11 @@ ...@@ -38,11 +38,11 @@
#define DRIVER_NAME "mga" #define DRIVER_NAME "mga"
#define DRIVER_DESC "Matrox G200/G400" #define DRIVER_DESC "Matrox G200/G400"
#define DRIVER_DATE "20050607" #define DRIVER_DATE "20051102"
#define DRIVER_MAJOR 3 #define DRIVER_MAJOR 3
#define DRIVER_MINOR 2 #define DRIVER_MINOR 2
#define DRIVER_PATCHLEVEL 0 #define DRIVER_PATCHLEVEL 1
typedef struct drm_mga_primary_buffer { typedef struct drm_mga_primary_buffer {
u8 *start; u8 *start;
...@@ -144,22 +144,22 @@ typedef struct drm_mga_private { ...@@ -144,22 +144,22 @@ typedef struct drm_mga_private {
drm_local_map_t *primary; drm_local_map_t *primary;
drm_local_map_t *agp_textures; drm_local_map_t *agp_textures;
DRM_AGP_MEM *agp_mem; unsigned long agp_handle;
unsigned int agp_pages; unsigned int agp_size;
} drm_mga_private_t; } drm_mga_private_t;
extern drm_ioctl_desc_t mga_ioctls[]; extern drm_ioctl_desc_t mga_ioctls[];
extern int mga_max_ioctl; extern int mga_max_ioctl;
/* mga_dma.c */ /* mga_dma.c */
extern int mga_driver_preinit(drm_device_t * dev, unsigned long flags);
extern int mga_dma_bootstrap(DRM_IOCTL_ARGS); extern int mga_dma_bootstrap(DRM_IOCTL_ARGS);
extern int mga_dma_init(DRM_IOCTL_ARGS); extern int mga_dma_init(DRM_IOCTL_ARGS);
extern int mga_dma_flush(DRM_IOCTL_ARGS); extern int mga_dma_flush(DRM_IOCTL_ARGS);
extern int mga_dma_reset(DRM_IOCTL_ARGS); extern int mga_dma_reset(DRM_IOCTL_ARGS);
extern int mga_dma_buffers(DRM_IOCTL_ARGS); extern int mga_dma_buffers(DRM_IOCTL_ARGS);
extern int mga_driver_postcleanup(drm_device_t * dev); extern int mga_driver_load(drm_device_t *dev, unsigned long flags);
extern void mga_driver_pretakedown(drm_device_t * dev); extern int mga_driver_unload(drm_device_t * dev);
extern void mga_driver_lastclose(drm_device_t * dev);
extern int mga_driver_dma_quiescent(drm_device_t * dev); extern int mga_driver_dma_quiescent(drm_device_t * dev);
extern int mga_do_wait_for_idle(drm_mga_private_t * dev_priv); extern int mga_do_wait_for_idle(drm_mga_private_t * dev_priv);
......
...@@ -1127,19 +1127,19 @@ static int mga_wait_fence(DRM_IOCTL_ARGS) ...@@ -1127,19 +1127,19 @@ static int mga_wait_fence(DRM_IOCTL_ARGS)
} }
drm_ioctl_desc_t mga_ioctls[] = { drm_ioctl_desc_t mga_ioctls[] = {
[DRM_IOCTL_NR(DRM_MGA_INIT)] = {mga_dma_init, 1, 1}, [DRM_IOCTL_NR(DRM_MGA_INIT)] = {mga_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_MGA_FLUSH)] = {mga_dma_flush, 1, 0}, [DRM_IOCTL_NR(DRM_MGA_FLUSH)] = {mga_dma_flush, DRM_AUTH},
[DRM_IOCTL_NR(DRM_MGA_RESET)] = {mga_dma_reset, 1, 0}, [DRM_IOCTL_NR(DRM_MGA_RESET)] = {mga_dma_reset, DRM_AUTH},
[DRM_IOCTL_NR(DRM_MGA_SWAP)] = {mga_dma_swap, 1, 0}, [DRM_IOCTL_NR(DRM_MGA_SWAP)] = {mga_dma_swap, DRM_AUTH},
[DRM_IOCTL_NR(DRM_MGA_CLEAR)] = {mga_dma_clear, 1, 0}, [DRM_IOCTL_NR(DRM_MGA_CLEAR)] = {mga_dma_clear, DRM_AUTH},
[DRM_IOCTL_NR(DRM_MGA_VERTEX)] = {mga_dma_vertex, 1, 0}, [DRM_IOCTL_NR(DRM_MGA_VERTEX)] = {mga_dma_vertex, DRM_AUTH},
[DRM_IOCTL_NR(DRM_MGA_INDICES)] = {mga_dma_indices, 1, 0}, [DRM_IOCTL_NR(DRM_MGA_INDICES)] = {mga_dma_indices, DRM_AUTH},
[DRM_IOCTL_NR(DRM_MGA_ILOAD)] = {mga_dma_iload, 1, 0}, [DRM_IOCTL_NR(DRM_MGA_ILOAD)] = {mga_dma_iload, DRM_AUTH},
[DRM_IOCTL_NR(DRM_MGA_BLIT)] = {mga_dma_blit, 1, 0}, [DRM_IOCTL_NR(DRM_MGA_BLIT)] = {mga_dma_blit, DRM_AUTH},
[DRM_IOCTL_NR(DRM_MGA_GETPARAM)] = {mga_getparam, 1, 0}, [DRM_IOCTL_NR(DRM_MGA_GETPARAM)] = {mga_getparam, DRM_AUTH},
[DRM_IOCTL_NR(DRM_MGA_SET_FENCE)] = {mga_set_fence, 1, 0}, [DRM_IOCTL_NR(DRM_MGA_SET_FENCE)] = {mga_set_fence, DRM_AUTH},
[DRM_IOCTL_NR(DRM_MGA_WAIT_FENCE)] = {mga_wait_fence, 1, 0}, [DRM_IOCTL_NR(DRM_MGA_WAIT_FENCE)] = {mga_wait_fence, DRM_AUTH},
[DRM_IOCTL_NR(DRM_MGA_DMA_BOOTSTRAP)] = {mga_dma_bootstrap, 1, 1}, [DRM_IOCTL_NR(DRM_MGA_DMA_BOOTSTRAP)] = {mga_dma_bootstrap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
}; };
int mga_max_ioctl = DRM_ARRAY_SIZE(mga_ioctls); int mga_max_ioctl = DRM_ARRAY_SIZE(mga_ioctls);
/* r128_cce.c -- ATI Rage 128 driver -*- linux-c -*- /* r128_cce.c -- ATI Rage 128 driver -*- linux-c -*-
* Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com * Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com
* */
/*
* Copyright 2000 Precision Insight, Inc., Cedar Park, Texas. * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved. * All Rights Reserved.
...@@ -559,7 +560,8 @@ static int r128_do_init_cce(drm_device_t * dev, drm_r128_init_t * init) ...@@ -559,7 +560,8 @@ static int r128_do_init_cce(drm_device_t * dev, drm_r128_init_t * init)
if (dev_priv->is_pci) { if (dev_priv->is_pci) {
#endif #endif
dev_priv->gart_info.gart_table_location = DRM_ATI_GART_MAIN; dev_priv->gart_info.gart_table_location = DRM_ATI_GART_MAIN;
dev_priv->gart_info.addr = dev_priv->gart_info.bus_addr = 0; dev_priv->gart_info.addr = NULL;
dev_priv->gart_info.bus_addr = 0;
dev_priv->gart_info.is_pcie = 0; dev_priv->gart_info.is_pcie = 0;
if (!drm_ati_pcigart_init(dev, &dev_priv->gart_info)) { if (!drm_ati_pcigart_init(dev, &dev_priv->gart_info)) {
DRM_ERROR("failed to init PCI GART!\n"); DRM_ERROR("failed to init PCI GART!\n");
...@@ -601,15 +603,16 @@ int r128_do_cleanup_cce(drm_device_t * dev) ...@@ -601,15 +603,16 @@ int r128_do_cleanup_cce(drm_device_t * dev)
drm_core_ioremapfree(dev_priv->cce_ring, dev); drm_core_ioremapfree(dev_priv->cce_ring, dev);
if (dev_priv->ring_rptr != NULL) if (dev_priv->ring_rptr != NULL)
drm_core_ioremapfree(dev_priv->ring_rptr, dev); drm_core_ioremapfree(dev_priv->ring_rptr, dev);
if (dev->agp_buffer_map != NULL) if (dev->agp_buffer_map != NULL) {
drm_core_ioremapfree(dev->agp_buffer_map, dev); drm_core_ioremapfree(dev->agp_buffer_map, dev);
dev->agp_buffer_map = NULL;
}
} else } else
#endif #endif
{ {
if (dev_priv->gart_info.bus_addr) if (dev_priv->gart_info.bus_addr)
if (!drm_ati_pcigart_cleanup(dev, if (!drm_ati_pcigart_cleanup(dev,
&dev_priv-> &dev_priv->gart_info))
gart_info))
DRM_ERROR DRM_ERROR
("failed to cleanup PCI GART!\n"); ("failed to cleanup PCI GART!\n");
} }
......
/* r128_drm.h -- Public header for the r128 driver -*- linux-c -*- /* r128_drm.h -- Public header for the r128 driver -*- linux-c -*-
* Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com * Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com
* */
* Copyright 2000 Precision Insight, Inc., Cedar Park, Texas. /* Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All rights reserved. * All rights reserved.
* *
......
...@@ -37,31 +37,6 @@ ...@@ -37,31 +37,6 @@
#include "drm_pciids.h" #include "drm_pciids.h"
static int postinit(struct drm_device *dev, unsigned long flags)
{
DRM_INFO("Initialized %s %d.%d.%d %s on minor %d: %s\n",
DRIVER_NAME,
DRIVER_MAJOR,
DRIVER_MINOR,
DRIVER_PATCHLEVEL,
DRIVER_DATE, dev->primary.minor, pci_pretty_name(dev->pdev)
);
return 0;
}
static int version(drm_version_t * version)
{
int len;
version->version_major = DRIVER_MAJOR;
version->version_minor = DRIVER_MINOR;
version->version_patchlevel = DRIVER_PATCHLEVEL;
DRM_COPY(version->name, DRIVER_NAME);
DRM_COPY(version->date, DRIVER_DATE);
DRM_COPY(version->desc, DRIVER_DESC);
return 0;
}
static struct pci_device_id pciidlist[] = { static struct pci_device_id pciidlist[] = {
r128_PCI_IDS r128_PCI_IDS
}; };
...@@ -72,8 +47,8 @@ static struct drm_driver driver = { ...@@ -72,8 +47,8 @@ static struct drm_driver driver = {
DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED |
DRIVER_IRQ_VBL, DRIVER_IRQ_VBL,
.dev_priv_size = sizeof(drm_r128_buf_priv_t), .dev_priv_size = sizeof(drm_r128_buf_priv_t),
.prerelease = r128_driver_prerelease, .preclose = r128_driver_preclose,
.pretakedown = r128_driver_pretakedown, .lastclose = r128_driver_lastclose,
.vblank_wait = r128_driver_vblank_wait, .vblank_wait = r128_driver_vblank_wait,
.irq_preinstall = r128_driver_irq_preinstall, .irq_preinstall = r128_driver_irq_preinstall,
.irq_postinstall = r128_driver_irq_postinstall, .irq_postinstall = r128_driver_irq_postinstall,
...@@ -82,8 +57,6 @@ static struct drm_driver driver = { ...@@ -82,8 +57,6 @@ static struct drm_driver driver = {
.reclaim_buffers = drm_core_reclaim_buffers, .reclaim_buffers = drm_core_reclaim_buffers,
.get_map_ofs = drm_core_get_map_ofs, .get_map_ofs = drm_core_get_map_ofs,
.get_reg_ofs = drm_core_get_reg_ofs, .get_reg_ofs = drm_core_get_reg_ofs,
.postinit = postinit,
.version = version,
.ioctls = r128_ioctls, .ioctls = r128_ioctls,
.dma_ioctl = r128_cce_buffers, .dma_ioctl = r128_cce_buffers,
.fops = { .fops = {
...@@ -97,12 +70,19 @@ static struct drm_driver driver = { ...@@ -97,12 +70,19 @@ static struct drm_driver driver = {
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
.compat_ioctl = r128_compat_ioctl, .compat_ioctl = r128_compat_ioctl,
#endif #endif
} },
,
.pci_driver = { .pci_driver = {
.name = DRIVER_NAME, .name = DRIVER_NAME,
.id_table = pciidlist, .id_table = pciidlist,
} },
.name = DRIVER_NAME,
.desc = DRIVER_DESC,
.date = DRIVER_DATE,
.major = DRIVER_MAJOR,
.minor = DRIVER_MINOR,
.patchlevel = DRIVER_PATCHLEVEL,
}; };
static int __init r128_init(void) static int __init r128_init(void)
......
/* r128_drv.h -- Private header for r128 driver -*- linux-c -*- /* r128_drv.h -- Private header for r128 driver -*- linux-c -*-
* Created: Mon Dec 13 09:51:11 1999 by faith@precisioninsight.com * Created: Mon Dec 13 09:51:11 1999 by faith@precisioninsight.com
* */
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. /* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All rights reserved. * All rights reserved.
* *
...@@ -154,8 +154,8 @@ extern irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS); ...@@ -154,8 +154,8 @@ extern irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS);
extern void r128_driver_irq_preinstall(drm_device_t * dev); extern void r128_driver_irq_preinstall(drm_device_t * dev);
extern void r128_driver_irq_postinstall(drm_device_t * dev); extern void r128_driver_irq_postinstall(drm_device_t * dev);
extern void r128_driver_irq_uninstall(drm_device_t * dev); extern void r128_driver_irq_uninstall(drm_device_t * dev);
extern void r128_driver_pretakedown(drm_device_t * dev); extern void r128_driver_lastclose(drm_device_t * dev);
extern void r128_driver_prerelease(drm_device_t * dev, DRMFILE filp); extern void r128_driver_preclose(drm_device_t * dev, DRMFILE filp);
extern long r128_compat_ioctl(struct file *filp, unsigned int cmd, extern long r128_compat_ioctl(struct file *filp, unsigned int cmd,
unsigned long arg); unsigned long arg);
......
/* r128_irq.c -- IRQ handling for radeon -*- linux-c -*- /* r128_irq.c -- IRQ handling for radeon -*- linux-c -*- */
* /*
* Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved. * Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
* *
* The Weather Channel (TM) funded Tungsten Graphics to develop the * The Weather Channel (TM) funded Tungsten Graphics to develop the
......
/* r128_state.c -- State support for r128 -*- linux-c -*- /* r128_state.c -- State support for r128 -*- linux-c -*-
* Created: Thu Jan 27 02:53:43 2000 by gareth@valinux.com * Created: Thu Jan 27 02:53:43 2000 by gareth@valinux.com
* */
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. /* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved. * All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
...@@ -1674,7 +1674,7 @@ static int r128_getparam(DRM_IOCTL_ARGS) ...@@ -1674,7 +1674,7 @@ static int r128_getparam(DRM_IOCTL_ARGS)
return 0; return 0;
} }
void r128_driver_prerelease(drm_device_t * dev, DRMFILE filp) void r128_driver_preclose(drm_device_t * dev, DRMFILE filp)
{ {
if (dev->dev_private) { if (dev->dev_private) {
drm_r128_private_t *dev_priv = dev->dev_private; drm_r128_private_t *dev_priv = dev->dev_private;
...@@ -1684,29 +1684,29 @@ void r128_driver_prerelease(drm_device_t * dev, DRMFILE filp) ...@@ -1684,29 +1684,29 @@ void r128_driver_prerelease(drm_device_t * dev, DRMFILE filp)
} }
} }
void r128_driver_pretakedown(drm_device_t * dev) void r128_driver_lastclose(drm_device_t * dev)
{ {
r128_do_cleanup_cce(dev); r128_do_cleanup_cce(dev);
} }
drm_ioctl_desc_t r128_ioctls[] = { drm_ioctl_desc_t r128_ioctls[] = {
[DRM_IOCTL_NR(DRM_R128_INIT)] = {r128_cce_init, 1, 1}, [DRM_IOCTL_NR(DRM_R128_INIT)] = {r128_cce_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_R128_CCE_START)] = {r128_cce_start, 1, 1}, [DRM_IOCTL_NR(DRM_R128_CCE_START)] = {r128_cce_start, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_R128_CCE_STOP)] = {r128_cce_stop, 1, 1}, [DRM_IOCTL_NR(DRM_R128_CCE_STOP)] = {r128_cce_stop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_R128_CCE_RESET)] = {r128_cce_reset, 1, 1}, [DRM_IOCTL_NR(DRM_R128_CCE_RESET)] = {r128_cce_reset, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_R128_CCE_IDLE)] = {r128_cce_idle, 1, 0}, [DRM_IOCTL_NR(DRM_R128_CCE_IDLE)] = {r128_cce_idle, DRM_AUTH},
[DRM_IOCTL_NR(DRM_R128_RESET)] = {r128_engine_reset, 1, 0}, [DRM_IOCTL_NR(DRM_R128_RESET)] = {r128_engine_reset, DRM_AUTH},
[DRM_IOCTL_NR(DRM_R128_FULLSCREEN)] = {r128_fullscreen, 1, 0}, [DRM_IOCTL_NR(DRM_R128_FULLSCREEN)] = {r128_fullscreen, DRM_AUTH},
[DRM_IOCTL_NR(DRM_R128_SWAP)] = {r128_cce_swap, 1, 0}, [DRM_IOCTL_NR(DRM_R128_SWAP)] = {r128_cce_swap, DRM_AUTH},
[DRM_IOCTL_NR(DRM_R128_FLIP)] = {r128_cce_flip, 1, 0}, [DRM_IOCTL_NR(DRM_R128_FLIP)] = {r128_cce_flip, DRM_AUTH},
[DRM_IOCTL_NR(DRM_R128_CLEAR)] = {r128_cce_clear, 1, 0}, [DRM_IOCTL_NR(DRM_R128_CLEAR)] = {r128_cce_clear, DRM_AUTH},
[DRM_IOCTL_NR(DRM_R128_VERTEX)] = {r128_cce_vertex, 1, 0}, [DRM_IOCTL_NR(DRM_R128_VERTEX)] = {r128_cce_vertex, DRM_AUTH},
[DRM_IOCTL_NR(DRM_R128_INDICES)] = {r128_cce_indices, 1, 0}, [DRM_IOCTL_NR(DRM_R128_INDICES)] = {r128_cce_indices, DRM_AUTH},
[DRM_IOCTL_NR(DRM_R128_BLIT)] = {r128_cce_blit, 1, 0}, [DRM_IOCTL_NR(DRM_R128_BLIT)] = {r128_cce_blit, DRM_AUTH},
[DRM_IOCTL_NR(DRM_R128_DEPTH)] = {r128_cce_depth, 1, 0}, [DRM_IOCTL_NR(DRM_R128_DEPTH)] = {r128_cce_depth, DRM_AUTH},
[DRM_IOCTL_NR(DRM_R128_STIPPLE)] = {r128_cce_stipple, 1, 0}, [DRM_IOCTL_NR(DRM_R128_STIPPLE)] = {r128_cce_stipple, DRM_AUTH},
[DRM_IOCTL_NR(DRM_R128_INDIRECT)] = {r128_cce_indirect, 1, 1}, [DRM_IOCTL_NR(DRM_R128_INDIRECT)] = {r128_cce_indirect, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
[DRM_IOCTL_NR(DRM_R128_GETPARAM)] = {r128_getparam, 1, 0}, [DRM_IOCTL_NR(DRM_R128_GETPARAM)] = {r128_getparam, DRM_AUTH},
}; };
int r128_max_ioctl = DRM_ARRAY_SIZE(r128_ioctls); int r128_max_ioctl = DRM_ARRAY_SIZE(r128_ioctls);
...@@ -52,8 +52,8 @@ static const int r300_cliprect_cntl[4] = { ...@@ -52,8 +52,8 @@ static const int r300_cliprect_cntl[4] = {
* Emit up to R300_SIMULTANEOUS_CLIPRECTS cliprects from the given command * Emit up to R300_SIMULTANEOUS_CLIPRECTS cliprects from the given command
* buffer, starting with index n. * buffer, starting with index n.
*/ */
static int r300_emit_cliprects(drm_radeon_private_t * dev_priv, static int r300_emit_cliprects(drm_radeon_private_t *dev_priv,
drm_radeon_kcmd_buffer_t * cmdbuf, int n) drm_radeon_kcmd_buffer_t *cmdbuf, int n)
{ {
drm_clip_rect_t box; drm_clip_rect_t box;
int nr; int nr;
...@@ -216,6 +216,7 @@ void r300_init_reg_flags(void) ...@@ -216,6 +216,7 @@ void r300_init_reg_flags(void)
ADD_RANGE(R300_TX_UNK1_0, 16); ADD_RANGE(R300_TX_UNK1_0, 16);
ADD_RANGE(R300_TX_SIZE_0, 16); ADD_RANGE(R300_TX_SIZE_0, 16);
ADD_RANGE(R300_TX_FORMAT_0, 16); ADD_RANGE(R300_TX_FORMAT_0, 16);
ADD_RANGE(R300_TX_PITCH_0, 16);
/* Texture offset is dangerous and needs more checking */ /* Texture offset is dangerous and needs more checking */
ADD_RANGE_MARK(R300_TX_OFFSET_0, 16, MARK_CHECK_OFFSET); ADD_RANGE_MARK(R300_TX_OFFSET_0, 16, MARK_CHECK_OFFSET);
ADD_RANGE(R300_TX_UNK4_0, 16); ADD_RANGE(R300_TX_UNK4_0, 16);
...@@ -242,7 +243,7 @@ static __inline__ int r300_check_range(unsigned reg, int count) ...@@ -242,7 +243,7 @@ static __inline__ int r300_check_range(unsigned reg, int count)
/* we expect offsets passed to the framebuffer to be either within video memory or /* we expect offsets passed to the framebuffer to be either within video memory or
within AGP space */ within AGP space */
static __inline__ int r300_check_offset(drm_radeon_private_t * dev_priv, static __inline__ int r300_check_offset(drm_radeon_private_t *dev_priv,
u32 offset) u32 offset)
{ {
/* we realy want to check against end of video aperture /* we realy want to check against end of video aperture
...@@ -317,8 +318,8 @@ static __inline__ int r300_emit_carefully_checked_packet0(drm_radeon_private_t * ...@@ -317,8 +318,8 @@ static __inline__ int r300_emit_carefully_checked_packet0(drm_radeon_private_t *
* *
* Note that checks are performed on contents and addresses of the registers * Note that checks are performed on contents and addresses of the registers
*/ */
static __inline__ int r300_emit_packet0(drm_radeon_private_t * dev_priv, static __inline__ int r300_emit_packet0(drm_radeon_private_t *dev_priv,
drm_radeon_kcmd_buffer_t * cmdbuf, drm_radeon_kcmd_buffer_t *cmdbuf,
drm_r300_cmd_header_t header) drm_r300_cmd_header_t header)
{ {
int reg; int reg;
...@@ -363,8 +364,8 @@ static __inline__ int r300_emit_packet0(drm_radeon_private_t * dev_priv, ...@@ -363,8 +364,8 @@ static __inline__ int r300_emit_packet0(drm_radeon_private_t * dev_priv,
* the graphics card. * the graphics card.
* Called by r300_do_cp_cmdbuf. * Called by r300_do_cp_cmdbuf.
*/ */
static __inline__ int r300_emit_vpu(drm_radeon_private_t * dev_priv, static __inline__ int r300_emit_vpu(drm_radeon_private_t *dev_priv,
drm_radeon_kcmd_buffer_t * cmdbuf, drm_radeon_kcmd_buffer_t *cmdbuf,
drm_r300_cmd_header_t header) drm_r300_cmd_header_t header)
{ {
int sz; int sz;
...@@ -400,8 +401,8 @@ static __inline__ int r300_emit_vpu(drm_radeon_private_t * dev_priv, ...@@ -400,8 +401,8 @@ static __inline__ int r300_emit_vpu(drm_radeon_private_t * dev_priv,
* Emit a clear packet from userspace. * Emit a clear packet from userspace.
* Called by r300_emit_packet3. * Called by r300_emit_packet3.
*/ */
static __inline__ int r300_emit_clear(drm_radeon_private_t * dev_priv, static __inline__ int r300_emit_clear(drm_radeon_private_t *dev_priv,
drm_radeon_kcmd_buffer_t * cmdbuf) drm_radeon_kcmd_buffer_t *cmdbuf)
{ {
RING_LOCALS; RING_LOCALS;
...@@ -421,8 +422,8 @@ static __inline__ int r300_emit_clear(drm_radeon_private_t * dev_priv, ...@@ -421,8 +422,8 @@ static __inline__ int r300_emit_clear(drm_radeon_private_t * dev_priv,
return 0; return 0;
} }
static __inline__ int r300_emit_3d_load_vbpntr(drm_radeon_private_t * dev_priv, static __inline__ int r300_emit_3d_load_vbpntr(drm_radeon_private_t *dev_priv,
drm_radeon_kcmd_buffer_t * cmdbuf, drm_radeon_kcmd_buffer_t *cmdbuf,
u32 header) u32 header)
{ {
int count, i, k; int count, i, k;
...@@ -489,8 +490,8 @@ static __inline__ int r300_emit_3d_load_vbpntr(drm_radeon_private_t * dev_priv, ...@@ -489,8 +490,8 @@ static __inline__ int r300_emit_3d_load_vbpntr(drm_radeon_private_t * dev_priv,
return 0; return 0;
} }
static __inline__ int r300_emit_raw_packet3(drm_radeon_private_t * dev_priv, static __inline__ int r300_emit_raw_packet3(drm_radeon_private_t *dev_priv,
drm_radeon_kcmd_buffer_t * cmdbuf) drm_radeon_kcmd_buffer_t *cmdbuf)
{ {
u32 header; u32 header;
int count; int count;
...@@ -554,8 +555,8 @@ static __inline__ int r300_emit_raw_packet3(drm_radeon_private_t * dev_priv, ...@@ -554,8 +555,8 @@ static __inline__ int r300_emit_raw_packet3(drm_radeon_private_t * dev_priv,
* Emit a rendering packet3 from userspace. * Emit a rendering packet3 from userspace.
* Called by r300_do_cp_cmdbuf. * Called by r300_do_cp_cmdbuf.
*/ */
static __inline__ int r300_emit_packet3(drm_radeon_private_t * dev_priv, static __inline__ int r300_emit_packet3(drm_radeon_private_t *dev_priv,
drm_radeon_kcmd_buffer_t * cmdbuf, drm_radeon_kcmd_buffer_t *cmdbuf,
drm_r300_cmd_header_t header) drm_r300_cmd_header_t header)
{ {
int n; int n;
...@@ -623,7 +624,7 @@ static __inline__ int r300_emit_packet3(drm_radeon_private_t * dev_priv, ...@@ -623,7 +624,7 @@ static __inline__ int r300_emit_packet3(drm_radeon_private_t * dev_priv,
/** /**
* Emit the sequence to pacify R300. * Emit the sequence to pacify R300.
*/ */
static __inline__ void r300_pacify(drm_radeon_private_t * dev_priv) static __inline__ void r300_pacify(drm_radeon_private_t *dev_priv)
{ {
RING_LOCALS; RING_LOCALS;
...@@ -657,9 +658,10 @@ static void r300_discard_buffer(drm_device_t * dev, drm_buf_t * buf) ...@@ -657,9 +658,10 @@ static void r300_discard_buffer(drm_device_t * dev, drm_buf_t * buf)
* commands on the DMA ring buffer. * commands on the DMA ring buffer.
* Called by the ioctl handler function radeon_cp_cmdbuf. * Called by the ioctl handler function radeon_cp_cmdbuf.
*/ */
int r300_do_cp_cmdbuf(drm_device_t * dev, int r300_do_cp_cmdbuf(drm_device_t *dev,
DRMFILE filp, DRMFILE filp,
drm_file_t * filp_priv, drm_radeon_kcmd_buffer_t * cmdbuf) drm_file_t *filp_priv,
drm_radeon_kcmd_buffer_t *cmdbuf)
{ {
drm_radeon_private_t *dev_priv = dev->dev_private; drm_radeon_private_t *dev_priv = dev->dev_private;
drm_device_dma_t *dma = dev->dma; drm_device_dma_t *dma = dev->dma;
......
...@@ -797,6 +797,7 @@ I am fairly certain that they are correct unless stated otherwise in comments. ...@@ -797,6 +797,7 @@ I am fairly certain that they are correct unless stated otherwise in comments.
# define R300_TX_FORMAT_YUV_MODE 0x00800000 # define R300_TX_FORMAT_YUV_MODE 0x00800000
#define R300_TX_PITCH_0 0x4500
#define R300_TX_OFFSET_0 0x4540 #define R300_TX_OFFSET_0 0x4540
/* BEGIN: Guess from R200 */ /* BEGIN: Guess from R200 */
# define R300_TXO_ENDIAN_NO_SWAP (0 << 0) # define R300_TXO_ENDIAN_NO_SWAP (0 << 0)
......
This diff is collapsed.
...@@ -624,6 +624,11 @@ typedef struct drm_radeon_indirect { ...@@ -624,6 +624,11 @@ typedef struct drm_radeon_indirect {
int discard; int discard;
} drm_radeon_indirect_t; } drm_radeon_indirect_t;
/* enum for card type parameters */
#define RADEON_CARD_PCI 0
#define RADEON_CARD_AGP 1
#define RADEON_CARD_PCIE 2
/* 1.3: An ioctl to get parameters that aren't available to the 3d /* 1.3: An ioctl to get parameters that aren't available to the 3d
* client any other way. * client any other way.
*/ */
...@@ -640,6 +645,7 @@ typedef struct drm_radeon_indirect { ...@@ -640,6 +645,7 @@ typedef struct drm_radeon_indirect {
#define RADEON_PARAM_SAREA_HANDLE 9 #define RADEON_PARAM_SAREA_HANDLE 9
#define RADEON_PARAM_GART_TEX_HANDLE 10 #define RADEON_PARAM_GART_TEX_HANDLE 10
#define RADEON_PARAM_SCRATCH_OFFSET 11 #define RADEON_PARAM_SCRATCH_OFFSET 11
#define RADEON_PARAM_CARD_TYPE 12
typedef struct drm_radeon_getparam { typedef struct drm_radeon_getparam {
int param; int param;
......
...@@ -42,29 +42,15 @@ int radeon_no_wb; ...@@ -42,29 +42,15 @@ int radeon_no_wb;
MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers\n"); MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers\n");
module_param_named(no_wb, radeon_no_wb, int, 0444); module_param_named(no_wb, radeon_no_wb, int, 0444);
static int postinit(struct drm_device *dev, unsigned long flags) static int dri_library_name(struct drm_device *dev, char *buf)
{ {
DRM_INFO("Initialized %s %d.%d.%d %s on minor %d: %s\n", drm_radeon_private_t *dev_priv = dev->dev_private;
DRIVER_NAME, int family = dev_priv->flags & CHIP_FAMILY_MASK;
DRIVER_MAJOR,
DRIVER_MINOR,
DRIVER_PATCHLEVEL,
DRIVER_DATE, dev->primary.minor, pci_pretty_name(dev->pdev)
);
return 0;
}
static int version(drm_version_t * version)
{
int len;
version->version_major = DRIVER_MAJOR; return snprintf(buf, PAGE_SIZE, "%s\n",
version->version_minor = DRIVER_MINOR; (family < CHIP_R200) ? "radeon" :
version->version_patchlevel = DRIVER_PATCHLEVEL; ((family < CHIP_R300) ? "r200" :
DRM_COPY(version->name, DRIVER_NAME); "r300"));
DRM_COPY(version->date, DRIVER_DATE);
DRM_COPY(version->desc, DRIVER_DESC);
return 0;
} }
static struct pci_device_id pciidlist[] = { static struct pci_device_id pciidlist[] = {
...@@ -77,23 +63,22 @@ static struct drm_driver driver = { ...@@ -77,23 +63,22 @@ static struct drm_driver driver = {
DRIVER_HAVE_IRQ | DRIVER_HAVE_DMA | DRIVER_IRQ_SHARED | DRIVER_HAVE_IRQ | DRIVER_HAVE_DMA | DRIVER_IRQ_SHARED |
DRIVER_IRQ_VBL, DRIVER_IRQ_VBL,
.dev_priv_size = sizeof(drm_radeon_buf_priv_t), .dev_priv_size = sizeof(drm_radeon_buf_priv_t),
.preinit = radeon_driver_preinit, .load = radeon_driver_load,
.presetup = radeon_presetup, .firstopen = radeon_driver_firstopen,
.postcleanup = radeon_driver_postcleanup, .open = radeon_driver_open,
.prerelease = radeon_driver_prerelease, .preclose = radeon_driver_preclose,
.pretakedown = radeon_driver_pretakedown, .postclose = radeon_driver_postclose,
.open_helper = radeon_driver_open_helper, .lastclose = radeon_driver_lastclose,
.unload = radeon_driver_unload,
.vblank_wait = radeon_driver_vblank_wait, .vblank_wait = radeon_driver_vblank_wait,
.dri_library_name = dri_library_name,
.irq_preinstall = radeon_driver_irq_preinstall, .irq_preinstall = radeon_driver_irq_preinstall,
.irq_postinstall = radeon_driver_irq_postinstall, .irq_postinstall = radeon_driver_irq_postinstall,
.irq_uninstall = radeon_driver_irq_uninstall, .irq_uninstall = radeon_driver_irq_uninstall,
.irq_handler = radeon_driver_irq_handler, .irq_handler = radeon_driver_irq_handler,
.free_filp_priv = radeon_driver_free_filp_priv,
.reclaim_buffers = drm_core_reclaim_buffers, .reclaim_buffers = drm_core_reclaim_buffers,
.get_map_ofs = drm_core_get_map_ofs, .get_map_ofs = drm_core_get_map_ofs,
.get_reg_ofs = drm_core_get_reg_ofs, .get_reg_ofs = drm_core_get_reg_ofs,
.postinit = postinit,
.version = version,
.ioctls = radeon_ioctls, .ioctls = radeon_ioctls,
.dma_ioctl = radeon_cp_buffers, .dma_ioctl = radeon_cp_buffers,
.fops = { .fops = {
...@@ -107,12 +92,19 @@ static struct drm_driver driver = { ...@@ -107,12 +92,19 @@ static struct drm_driver driver = {
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
.compat_ioctl = radeon_compat_ioctl, .compat_ioctl = radeon_compat_ioctl,
#endif #endif
} },
,
.pci_driver = { .pci_driver = {
.name = DRIVER_NAME, .name = DRIVER_NAME,
.id_table = pciidlist, .id_table = pciidlist,
} },
.name = DRIVER_NAME,
.desc = DRIVER_DESC,
.date = DRIVER_DATE,
.major = DRIVER_MAJOR,
.minor = DRIVER_MINOR,
.patchlevel = DRIVER_PATCHLEVEL,
}; };
static int __init radeon_init(void) static int __init radeon_init(void)
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#define DRIVER_NAME "radeon" #define DRIVER_NAME "radeon"
#define DRIVER_DESC "ATI Radeon" #define DRIVER_DESC "ATI Radeon"
#define DRIVER_DATE "20050911" #define DRIVER_DATE "20051229"
/* Interface history: /* Interface history:
* *
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
* 1.11- Add packet R200_EMIT_RB3D_BLENDCOLOR to support GL_EXT_blend_color * 1.11- Add packet R200_EMIT_RB3D_BLENDCOLOR to support GL_EXT_blend_color
* and GL_EXT_blend_[func|equation]_separate on r200 * and GL_EXT_blend_[func|equation]_separate on r200
* 1.12- Add R300 CP microcode support - this just loads the CP on r300 * 1.12- Add R300 CP microcode support - this just loads the CP on r300
* (No 3D support yet - just microcode loading) * (No 3D support yet - just microcode loading).
* 1.13- Add packet R200_EMIT_TCL_POINT_SPRITE_CNTL for ARB_point_parameters * 1.13- Add packet R200_EMIT_TCL_POINT_SPRITE_CNTL for ARB_point_parameters
* - Add hyperz support, add hyperz flags to clear ioctl. * - Add hyperz support, add hyperz flags to clear ioctl.
* 1.14- Add support for color tiling * 1.14- Add support for color tiling
...@@ -88,14 +88,13 @@ ...@@ -88,14 +88,13 @@
* R200_EMIT_PP_TXFILTER_0-5, 2 more regs) and R200_EMIT_ATF_TFACTOR * R200_EMIT_PP_TXFILTER_0-5, 2 more regs) and R200_EMIT_ATF_TFACTOR
* (replaces R200_EMIT_TFACTOR_0 (8 consts instead of 6) * (replaces R200_EMIT_TFACTOR_0 (8 consts instead of 6)
* 1.19- Add support for gart table in FB memory and PCIE r300 * 1.19- Add support for gart table in FB memory and PCIE r300
* 1.20- Add support for r300 texrect
* 1.21- Add support for card type getparam
*/ */
#define DRIVER_MAJOR 1 #define DRIVER_MAJOR 1
#define DRIVER_MINOR 19 #define DRIVER_MINOR 21
#define DRIVER_PATCHLEVEL 0 #define DRIVER_PATCHLEVEL 0
#define GET_RING_HEAD(dev_priv) DRM_READ32( (dev_priv)->ring_rptr, 0 )
#define SET_RING_HEAD(dev_priv,val) DRM_WRITE32( (dev_priv)->ring_rptr, 0, (val) )
/* /*
* Radeon chip families * Radeon chip families
*/ */
...@@ -103,8 +102,8 @@ enum radeon_family { ...@@ -103,8 +102,8 @@ enum radeon_family {
CHIP_R100, CHIP_R100,
CHIP_RS100, CHIP_RS100,
CHIP_RV100, CHIP_RV100,
CHIP_R200,
CHIP_RV200, CHIP_RV200,
CHIP_R200,
CHIP_RS200, CHIP_RS200,
CHIP_R250, CHIP_R250,
CHIP_RS250, CHIP_RS250,
...@@ -138,6 +137,9 @@ enum radeon_chip_flags { ...@@ -138,6 +137,9 @@ enum radeon_chip_flags {
CHIP_IS_PCIE = 0x00200000UL, CHIP_IS_PCIE = 0x00200000UL,
}; };
#define GET_RING_HEAD(dev_priv) DRM_READ32( (dev_priv)->ring_rptr, 0 )
#define SET_RING_HEAD(dev_priv,val) DRM_WRITE32( (dev_priv)->ring_rptr, 0, (val) )
typedef struct drm_radeon_freelist { typedef struct drm_radeon_freelist {
unsigned int age; unsigned int age;
drm_buf_t *buf; drm_buf_t *buf;
...@@ -245,8 +247,6 @@ typedef struct drm_radeon_private { ...@@ -245,8 +247,6 @@ typedef struct drm_radeon_private {
drm_radeon_depth_clear_t depth_clear; drm_radeon_depth_clear_t depth_clear;
unsigned long fb_offset;
unsigned long mmio_offset;
unsigned long ring_offset; unsigned long ring_offset;
unsigned long ring_rptr_offset; unsigned long ring_rptr_offset;
unsigned long buffers_offset; unsigned long buffers_offset;
...@@ -273,7 +273,6 @@ typedef struct drm_radeon_private { ...@@ -273,7 +273,6 @@ typedef struct drm_radeon_private {
/* starting from here on, data is preserved accross an open */ /* starting from here on, data is preserved accross an open */
uint32_t flags; /* see radeon_chip_flags */ uint32_t flags; /* see radeon_chip_flags */
int is_pci;
} drm_radeon_private_t; } drm_radeon_private_t;
typedef struct drm_radeon_buf_priv { typedef struct drm_radeon_buf_priv {
...@@ -330,17 +329,14 @@ extern irqreturn_t radeon_driver_irq_handler(DRM_IRQ_ARGS); ...@@ -330,17 +329,14 @@ extern irqreturn_t radeon_driver_irq_handler(DRM_IRQ_ARGS);
extern void radeon_driver_irq_preinstall(drm_device_t * dev); extern void radeon_driver_irq_preinstall(drm_device_t * dev);
extern void radeon_driver_irq_postinstall(drm_device_t * dev); extern void radeon_driver_irq_postinstall(drm_device_t * dev);
extern void radeon_driver_irq_uninstall(drm_device_t * dev); extern void radeon_driver_irq_uninstall(drm_device_t * dev);
extern void radeon_driver_prerelease(drm_device_t * dev, DRMFILE filp);
extern void radeon_driver_pretakedown(drm_device_t * dev);
extern int radeon_driver_open_helper(drm_device_t * dev,
drm_file_t * filp_priv);
extern void radeon_driver_free_filp_priv(drm_device_t * dev,
drm_file_t * filp_priv);
extern int radeon_preinit(struct drm_device *dev, unsigned long flags);
extern int radeon_postinit(struct drm_device *dev, unsigned long flags);
extern int radeon_postcleanup(struct drm_device *dev);
extern int radeon_driver_load(struct drm_device *dev, unsigned long flags);
extern int radeon_driver_unload(struct drm_device *dev);
extern int radeon_driver_firstopen(struct drm_device *dev);
extern void radeon_driver_preclose(drm_device_t * dev, DRMFILE filp);
extern void radeon_driver_postclose(drm_device_t * dev, drm_file_t * filp);
extern void radeon_driver_lastclose(drm_device_t * dev);
extern int radeon_driver_open(drm_device_t * dev, drm_file_t * filp_priv);
extern long radeon_compat_ioctl(struct file *filp, unsigned int cmd, extern long radeon_compat_ioctl(struct file *filp, unsigned int cmd,
unsigned long arg); unsigned long arg);
...@@ -364,6 +360,8 @@ extern int r300_do_cp_cmdbuf(drm_device_t * dev, DRMFILE filp, ...@@ -364,6 +360,8 @@ extern int r300_do_cp_cmdbuf(drm_device_t * dev, DRMFILE filp,
*/ */
#define RADEON_AGP_COMMAND 0x0f60 #define RADEON_AGP_COMMAND 0x0f60
#define RADEON_AGP_COMMAND_PCI_CONFIG 0x0060 /* offset in PCI config */
# define RADEON_AGP_ENABLE (1<<8)
#define RADEON_AUX_SCISSOR_CNTL 0x26f0 #define RADEON_AUX_SCISSOR_CNTL 0x26f0
# define RADEON_EXCLUSIVE_SCISSOR_0 (1 << 24) # define RADEON_EXCLUSIVE_SCISSOR_0 (1 << 24)
# define RADEON_EXCLUSIVE_SCISSOR_1 (1 << 25) # define RADEON_EXCLUSIVE_SCISSOR_1 (1 << 25)
...@@ -651,6 +649,8 @@ extern int r300_do_cp_cmdbuf(drm_device_t * dev, DRMFILE filp, ...@@ -651,6 +649,8 @@ extern int r300_do_cp_cmdbuf(drm_device_t * dev, DRMFILE filp,
#define RADEON_WAIT_UNTIL 0x1720 #define RADEON_WAIT_UNTIL 0x1720
# define RADEON_WAIT_CRTC_PFLIP (1 << 0) # define RADEON_WAIT_CRTC_PFLIP (1 << 0)
# define RADEON_WAIT_2D_IDLE (1 << 14)
# define RADEON_WAIT_3D_IDLE (1 << 15)
# define RADEON_WAIT_2D_IDLECLEAN (1 << 16) # define RADEON_WAIT_2D_IDLECLEAN (1 << 16)
# define RADEON_WAIT_3D_IDLECLEAN (1 << 17) # define RADEON_WAIT_3D_IDLECLEAN (1 << 17)
# define RADEON_WAIT_HOST_IDLECLEAN (1 << 18) # define RADEON_WAIT_HOST_IDLECLEAN (1 << 18)
...@@ -1105,7 +1105,6 @@ do { \ ...@@ -1105,7 +1105,6 @@ do { \
write = 0; \ write = 0; \
_tab += _i; \ _tab += _i; \
} \ } \
\
while (_size > 0) { \ while (_size > 0) { \
*(ring + write) = *_tab++; \ *(ring + write) = *_tab++; \
write++; \ write++; \
......
This diff is collapsed.
This diff is collapsed.
...@@ -30,31 +30,6 @@ ...@@ -30,31 +30,6 @@
#include "drm_pciids.h" #include "drm_pciids.h"
static int postinit(struct drm_device *dev, unsigned long flags)
{
DRM_INFO("Initialized %s %d.%d.%d %s on minor %d: %s\n",
DRIVER_NAME,
DRIVER_MAJOR,
DRIVER_MINOR,
DRIVER_PATCHLEVEL,
DRIVER_DATE, dev->primary.minor, pci_pretty_name(dev->pdev)
);
return 0;
}
static int version(drm_version_t * version)
{
int len;
version->version_major = DRIVER_MAJOR;
version->version_minor = DRIVER_MINOR;
version->version_patchlevel = DRIVER_PATCHLEVEL;
DRM_COPY(version->name, DRIVER_NAME);
DRM_COPY(version->date, DRIVER_DATE);
DRM_COPY(version->desc, DRIVER_DESC);
return 0;
}
static struct pci_device_id pciidlist[] = { static struct pci_device_id pciidlist[] = {
savage_PCI_IDS savage_PCI_IDS
}; };
...@@ -63,13 +38,13 @@ static struct drm_driver driver = { ...@@ -63,13 +38,13 @@ static struct drm_driver driver = {
.driver_features = .driver_features =
DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_DMA | DRIVER_PCI_DMA, DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_DMA | DRIVER_PCI_DMA,
.dev_priv_size = sizeof(drm_savage_buf_priv_t), .dev_priv_size = sizeof(drm_savage_buf_priv_t),
.preinit = savage_preinit, .load = savage_driver_load,
.postinit = postinit, .firstopen = savage_driver_firstopen,
.postcleanup = savage_postcleanup, .lastclose = savage_driver_lastclose,
.unload = savage_driver_unload,
.reclaim_buffers = savage_reclaim_buffers, .reclaim_buffers = savage_reclaim_buffers,
.get_map_ofs = drm_core_get_map_ofs, .get_map_ofs = drm_core_get_map_ofs,
.get_reg_ofs = drm_core_get_reg_ofs, .get_reg_ofs = drm_core_get_reg_ofs,
.version = version,
.ioctls = savage_ioctls, .ioctls = savage_ioctls,
.dma_ioctl = savage_bci_buffers, .dma_ioctl = savage_bci_buffers,
.fops = { .fops = {
...@@ -80,12 +55,19 @@ static struct drm_driver driver = { ...@@ -80,12 +55,19 @@ static struct drm_driver driver = {
.mmap = drm_mmap, .mmap = drm_mmap,
.poll = drm_poll, .poll = drm_poll,
.fasync = drm_fasync, .fasync = drm_fasync,
} },
,
.pci_driver = { .pci_driver = {
.name = DRIVER_NAME, .name = DRIVER_NAME,
.id_table = pciidlist, .id_table = pciidlist,
} },
.name = DRIVER_NAME,
.desc = DRIVER_DESC,
.date = DRIVER_DATE,
.major = DRIVER_MAJOR,
.minor = DRIVER_MINOR,
.patchlevel = DRIVER_PATCHLEVEL,
}; };
static int __init savage_init(void) static int __init savage_init(void)
......
This diff is collapsed.
This diff is collapsed.
/* sis_drv.h -- Private header for sis driver -*- linux-c -*- */
/*
* Copyright 2005 Eric Anholt
* 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
* THE AUTHORS OR COPYRIGHT HOLDERS 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.
*
*/
#ifndef __SIS_DRM_H__ #ifndef __SIS_DRM_H__
#define __SIS_DRM_H__ #define __SIS_DRM_H__
......
This diff is collapsed.
/* sis_drv.h -- Private header for sis driver -*- linux-c -*- /* sis_drv.h -- Private header for sis driver -*- linux-c -*- */
* /*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All rights reserved. * All rights reserved.
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment