drm: Replace DRM_IOCTL_ARGS with (dev, data, file_priv) and remove DRM_DEVICE.
The data is now in kernel space, copied in/out as appropriate according to t This results in DRM_COPY_{TO,FROM}_USER going away, and error paths to deal with those failures. This also means that XFree86 4.2.0 support for i810 DR is lost. Signed-off-by: Dave Airlie <airlied@linux.ie>
This commit is contained in:
parent
b589ee5943
commit
c153f45f9b
|
@ -34,8 +34,6 @@
|
||||||
#ifndef _DRM_P_H_
|
#ifndef _DRM_P_H_
|
||||||
#define _DRM_P_H_
|
#define _DRM_P_H_
|
||||||
|
|
||||||
struct drm_file;
|
|
||||||
|
|
||||||
/* If you want the memory alloc debug functionality, change define below */
|
/* If you want the memory alloc debug functionality, change define below */
|
||||||
/* #define DEBUG_MEMORY */
|
/* #define DEBUG_MEMORY */
|
||||||
|
|
||||||
|
@ -82,6 +80,9 @@ struct drm_file;
|
||||||
#define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))
|
#define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))
|
||||||
#define __OS_HAS_MTRR (defined(CONFIG_MTRR))
|
#define __OS_HAS_MTRR (defined(CONFIG_MTRR))
|
||||||
|
|
||||||
|
struct drm_file;
|
||||||
|
struct drm_device;
|
||||||
|
|
||||||
#include "drm_os_linux.h"
|
#include "drm_os_linux.h"
|
||||||
#include "drm_hashtab.h"
|
#include "drm_hashtab.h"
|
||||||
|
|
||||||
|
@ -233,12 +234,13 @@ struct drm_file;
|
||||||
* \param dev DRM device.
|
* \param dev DRM device.
|
||||||
* \param filp file pointer of the caller.
|
* \param filp file pointer of the caller.
|
||||||
*/
|
*/
|
||||||
#define LOCK_TEST_WITH_RETURN( dev, filp ) \
|
#define LOCK_TEST_WITH_RETURN( dev, file_priv ) \
|
||||||
do { \
|
do { \
|
||||||
if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \
|
if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \
|
||||||
dev->lock.filp != filp ) { \
|
dev->lock.file_priv != file_priv ) { \
|
||||||
DRM_ERROR( "%s called without lock held\n", \
|
DRM_ERROR( "%s called without lock held, held %d owner %p %p\n",\
|
||||||
__FUNCTION__ ); \
|
__FUNCTION__, _DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ),\
|
||||||
|
dev->lock.file_priv, file_priv ); \
|
||||||
return -EINVAL; \
|
return -EINVAL; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
@ -263,8 +265,8 @@ do { \
|
||||||
* \param cmd command.
|
* \param cmd command.
|
||||||
* \param arg argument.
|
* \param arg argument.
|
||||||
*/
|
*/
|
||||||
typedef int drm_ioctl_t(struct inode *inode, struct drm_file *file_priv,
|
typedef int drm_ioctl_t(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
|
|
||||||
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);
|
||||||
|
@ -273,10 +275,18 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
|
||||||
#define DRM_MASTER 0x2
|
#define DRM_MASTER 0x2
|
||||||
#define DRM_ROOT_ONLY 0x4
|
#define DRM_ROOT_ONLY 0x4
|
||||||
|
|
||||||
typedef struct drm_ioctl_desc {
|
struct drm_ioctl_desc {
|
||||||
|
unsigned int cmd;
|
||||||
drm_ioctl_t *func;
|
drm_ioctl_t *func;
|
||||||
int flags;
|
int flags;
|
||||||
} drm_ioctl_desc_t;
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a driver or general drm_ioctl_desc array entry for the given
|
||||||
|
* ioctl, for use by drm_ioctl().
|
||||||
|
*/
|
||||||
|
#define DRM_IOCTL_DEF(ioctl, func, flags) \
|
||||||
|
[DRM_IOCTL_NR(ioctl)] = {ioctl, func, flags}
|
||||||
|
|
||||||
struct drm_magic_entry {
|
struct drm_magic_entry {
|
||||||
struct list_head head;
|
struct list_head head;
|
||||||
|
@ -559,7 +569,7 @@ struct drm_driver {
|
||||||
void (*postclose) (struct drm_device *, struct drm_file *);
|
void (*postclose) (struct drm_device *, struct drm_file *);
|
||||||
void (*lastclose) (struct drm_device *);
|
void (*lastclose) (struct drm_device *);
|
||||||
int (*unload) (struct drm_device *);
|
int (*unload) (struct drm_device *);
|
||||||
int (*dma_ioctl) (DRM_IOCTL_ARGS);
|
int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
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);
|
||||||
|
@ -610,7 +620,7 @@ struct drm_driver {
|
||||||
|
|
||||||
u32 driver_features;
|
u32 driver_features;
|
||||||
int dev_priv_size;
|
int dev_priv_size;
|
||||||
drm_ioctl_desc_t *ioctls;
|
struct drm_ioctl_desc *ioctls;
|
||||||
int num_ioctls;
|
int num_ioctls;
|
||||||
struct file_operations fops;
|
struct file_operations fops;
|
||||||
struct pci_driver pci_driver;
|
struct pci_driver pci_driver;
|
||||||
|
@ -854,70 +864,70 @@ extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start);
|
||||||
extern int drm_unbind_agp(DRM_AGP_MEM * handle);
|
extern int drm_unbind_agp(DRM_AGP_MEM * handle);
|
||||||
|
|
||||||
/* Misc. IOCTL support (drm_ioctl.h) */
|
/* Misc. IOCTL support (drm_ioctl.h) */
|
||||||
extern int drm_irq_by_busid(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_irq_by_busid(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_getunique(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_getunique(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_setunique(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_setunique(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_getmap(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_getmap(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_getclient(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_getclient(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_getstats(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_getstats(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_setversion(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_setversion(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_noop(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_noop(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
|
|
||||||
/* Context IOCTL support (drm_context.h) */
|
/* Context IOCTL support (drm_context.h) */
|
||||||
extern int drm_resctx(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_resctx(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_addctx(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_addctx(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_modctx(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_modctx(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_getctx(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_getctx(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_switchctx(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_switchctx(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_newctx(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_newctx(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_rmctx(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_rmctx(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
|
|
||||||
extern int drm_ctxbitmap_init(struct drm_device *dev);
|
extern int drm_ctxbitmap_init(struct drm_device *dev);
|
||||||
extern void drm_ctxbitmap_cleanup(struct drm_device *dev);
|
extern void drm_ctxbitmap_cleanup(struct drm_device *dev);
|
||||||
extern void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
|
extern void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
|
||||||
|
|
||||||
extern int drm_setsareactx(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_setsareactx(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_getsareactx(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_getsareactx(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
|
|
||||||
/* Drawable IOCTL support (drm_drawable.h) */
|
/* Drawable IOCTL support (drm_drawable.h) */
|
||||||
extern int drm_adddraw(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_adddraw(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_rmdraw(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_rmdraw(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_update_drawable_info(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_update_drawable_info(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern struct drm_drawable_info *drm_get_drawable_info(struct drm_device *dev,
|
extern struct drm_drawable_info *drm_get_drawable_info(struct drm_device *dev,
|
||||||
drm_drawable_t id);
|
drm_drawable_t id);
|
||||||
extern void drm_drawable_free_all(struct drm_device *dev);
|
extern void drm_drawable_free_all(struct drm_device *dev);
|
||||||
|
|
||||||
/* Authentication IOCTL support (drm_auth.h) */
|
/* Authentication IOCTL support (drm_auth.h) */
|
||||||
extern int drm_getmagic(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_getmagic(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_authmagic(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_authmagic(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
|
|
||||||
/* Locking IOCTL support (drm_lock.h) */
|
/* Locking IOCTL support (drm_lock.h) */
|
||||||
extern int drm_lock(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_lock(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_unlock(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_unlock(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_lock_take(struct drm_lock_data *lock_data, unsigned int context);
|
extern int drm_lock_take(struct drm_lock_data *lock_data, unsigned int context);
|
||||||
extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context);
|
extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context);
|
||||||
extern void drm_idlelock_take(struct drm_lock_data *lock_data);
|
extern void drm_idlelock_take(struct drm_lock_data *lock_data);
|
||||||
|
@ -928,7 +938,7 @@ extern void drm_idlelock_release(struct drm_lock_data *lock_data);
|
||||||
* DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
|
* DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern int drm_i_have_hw_lock(struct drm_file *file_priv);
|
extern int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv);
|
||||||
|
|
||||||
/* Buffer management support (drm_bufs.h) */
|
/* Buffer management support (drm_bufs.h) */
|
||||||
extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request);
|
extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request);
|
||||||
|
@ -936,24 +946,23 @@ extern int drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc * request
|
||||||
extern int drm_addmap(struct drm_device *dev, unsigned int offset,
|
extern int drm_addmap(struct drm_device *dev, unsigned int offset,
|
||||||
unsigned int size, enum drm_map_type type,
|
unsigned int size, enum drm_map_type type,
|
||||||
enum drm_map_flags flags, drm_local_map_t ** map_ptr);
|
enum drm_map_flags flags, drm_local_map_t ** map_ptr);
|
||||||
extern int drm_addmap_ioctl(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_addmap_ioctl(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_rmmap(struct drm_device *dev, drm_local_map_t * map);
|
extern int drm_rmmap(struct drm_device *dev, drm_local_map_t *map);
|
||||||
extern int drm_rmmap_locked(struct drm_device *dev, drm_local_map_t * map);
|
extern int drm_rmmap_locked(struct drm_device *dev, drm_local_map_t *map);
|
||||||
extern int drm_rmmap_ioctl(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_rmmap_ioctl(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
|
extern int drm_addbufs(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv);
|
||||||
|
extern int drm_infobufs(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv);
|
||||||
|
extern int drm_markbufs(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv);
|
||||||
|
extern int drm_freebufs(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv);
|
||||||
|
extern int drm_mapbufs(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv);
|
||||||
extern int drm_order(unsigned long size);
|
extern int drm_order(unsigned long size);
|
||||||
extern int drm_addbufs(struct inode *inode, struct drm_file *file_priv,
|
|
||||||
unsigned int cmd, unsigned long arg);
|
|
||||||
extern int drm_infobufs(struct inode *inode, struct drm_file *file_priv,
|
|
||||||
unsigned int cmd, unsigned long arg);
|
|
||||||
extern int drm_markbufs(struct inode *inode, struct drm_file *file_priv,
|
|
||||||
unsigned int cmd, unsigned long arg);
|
|
||||||
extern int drm_freebufs(struct inode *inode, struct drm_file *file_priv,
|
|
||||||
unsigned int cmd, unsigned long arg);
|
|
||||||
extern int drm_mapbufs(struct inode *inode, struct drm_file *file_priv,
|
|
||||||
unsigned int cmd, unsigned long arg);
|
|
||||||
extern unsigned long drm_get_resource_start(struct drm_device *dev,
|
extern unsigned long drm_get_resource_start(struct drm_device *dev,
|
||||||
unsigned int resource);
|
unsigned int resource);
|
||||||
extern unsigned long drm_get_resource_len(struct drm_device *dev,
|
extern unsigned long drm_get_resource_len(struct drm_device *dev,
|
||||||
|
@ -967,16 +976,16 @@ extern void drm_core_reclaim_buffers(struct drm_device *dev,
|
||||||
struct drm_file *filp);
|
struct drm_file *filp);
|
||||||
|
|
||||||
/* IRQ support (drm_irq.h) */
|
/* IRQ support (drm_irq.h) */
|
||||||
extern int drm_control(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_control(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern irqreturn_t drm_irq_handler(DRM_IRQ_ARGS);
|
extern irqreturn_t drm_irq_handler(DRM_IRQ_ARGS);
|
||||||
extern int drm_irq_uninstall(struct drm_device *dev);
|
extern int drm_irq_uninstall(struct drm_device *dev);
|
||||||
extern void drm_driver_irq_preinstall(struct drm_device *dev);
|
extern void drm_driver_irq_preinstall(struct drm_device *dev);
|
||||||
extern void drm_driver_irq_postinstall(struct drm_device *dev);
|
extern void drm_driver_irq_postinstall(struct drm_device *dev);
|
||||||
extern void drm_driver_irq_uninstall(struct drm_device *dev);
|
extern void drm_driver_irq_uninstall(struct drm_device *dev);
|
||||||
|
|
||||||
extern int drm_wait_vblank(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_wait_vblank(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq);
|
extern int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq);
|
||||||
extern void drm_vbl_send_signals(struct drm_device *dev);
|
extern void drm_vbl_send_signals(struct drm_device *dev);
|
||||||
extern void drm_locked_tasklet(struct drm_device *dev, void(*func)(struct drm_device*));
|
extern void drm_locked_tasklet(struct drm_device *dev, void(*func)(struct drm_device*));
|
||||||
|
@ -984,31 +993,30 @@ extern void drm_locked_tasklet(struct drm_device *dev, void(*func)(struct drm_de
|
||||||
/* AGP/GART support (drm_agpsupport.h) */
|
/* AGP/GART support (drm_agpsupport.h) */
|
||||||
extern struct drm_agp_head *drm_agp_init(struct drm_device *dev);
|
extern struct drm_agp_head *drm_agp_init(struct drm_device *dev);
|
||||||
extern int drm_agp_acquire(struct drm_device *dev);
|
extern int drm_agp_acquire(struct drm_device *dev);
|
||||||
extern int drm_agp_acquire_ioctl(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_agp_release(struct drm_device *dev);
|
extern int drm_agp_release(struct drm_device *dev);
|
||||||
extern int drm_agp_release_ioctl(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_agp_release_ioctl(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode);
|
extern int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode);
|
||||||
extern int drm_agp_enable_ioctl(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_agp_enable_ioctl(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_agp_info(struct drm_device *dev, struct drm_agp_info * info);
|
extern int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info);
|
||||||
extern int drm_agp_info_ioctl(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_agp_info_ioctl(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request);
|
extern int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request);
|
||||||
extern int drm_agp_alloc_ioctl(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_agp_alloc_ioctl(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request);
|
extern int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request);
|
||||||
extern int drm_agp_free_ioctl(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_agp_free_ioctl(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request);
|
extern int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request);
|
||||||
extern int drm_agp_unbind_ioctl(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request);
|
extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request);
|
||||||
extern int drm_agp_bind_ioctl(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
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);
|
|
||||||
extern int drm_agp_free_memory(DRM_AGP_MEM * handle);
|
extern int drm_agp_free_memory(DRM_AGP_MEM * handle);
|
||||||
extern int drm_agp_bind_memory(DRM_AGP_MEM * handle, off_t start);
|
extern int drm_agp_bind_memory(DRM_AGP_MEM * handle, off_t start);
|
||||||
extern int drm_agp_unbind_memory(DRM_AGP_MEM * handle);
|
extern int drm_agp_unbind_memory(DRM_AGP_MEM * handle);
|
||||||
|
@ -1037,10 +1045,11 @@ extern int drm_proc_cleanup(int minor,
|
||||||
|
|
||||||
/* Scatter Gather Support (drm_scatter.h) */
|
/* Scatter Gather Support (drm_scatter.h) */
|
||||||
extern void drm_sg_cleanup(struct drm_sg_mem * entry);
|
extern void drm_sg_cleanup(struct drm_sg_mem * entry);
|
||||||
extern int drm_sg_alloc(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_sg_alloc_ioctl(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int drm_sg_free(struct inode *inode, struct drm_file *file_priv,
|
extern int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request);
|
||||||
unsigned int cmd, unsigned long arg);
|
extern int drm_sg_free(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv);
|
||||||
|
|
||||||
/* ATI PCIGART support (ati_pcigart.h) */
|
/* ATI PCIGART support (ati_pcigart.h) */
|
||||||
extern int drm_ati_pcigart_init(struct drm_device *dev,
|
extern int drm_ati_pcigart_init(struct drm_device *dev,
|
||||||
|
|
|
@ -71,19 +71,16 @@ int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info)
|
||||||
|
|
||||||
EXPORT_SYMBOL(drm_agp_info);
|
EXPORT_SYMBOL(drm_agp_info);
|
||||||
|
|
||||||
int drm_agp_info_ioctl(struct inode *inode, struct drm_file *file_priv,
|
int drm_agp_info_ioctl(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_agp_info *info = data;
|
||||||
struct drm_agp_info info;
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = drm_agp_info(dev, &info);
|
err = drm_agp_info(dev, info);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (copy_to_user((struct drm_agp_info __user *) arg, &info, sizeof(info)))
|
|
||||||
return -EFAULT;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,8 +119,8 @@ EXPORT_SYMBOL(drm_agp_acquire);
|
||||||
* Verifies the AGP device hasn't been acquired before and calls
|
* Verifies the AGP device hasn't been acquired before and calls
|
||||||
* \c agp_backend_acquire.
|
* \c agp_backend_acquire.
|
||||||
*/
|
*/
|
||||||
int drm_agp_acquire_ioctl(struct inode *inode, struct drm_file *file_priv,
|
int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
return drm_agp_acquire((struct drm_device *) file_priv->head->dev);
|
return drm_agp_acquire((struct drm_device *) file_priv->head->dev);
|
||||||
}
|
}
|
||||||
|
@ -146,11 +143,9 @@ int drm_agp_release(struct drm_device * dev)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(drm_agp_release);
|
EXPORT_SYMBOL(drm_agp_release);
|
||||||
|
|
||||||
int drm_agp_release_ioctl(struct inode *inode, struct drm_file *file_priv,
|
int drm_agp_release_ioctl(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
|
|
||||||
return drm_agp_release(dev);
|
return drm_agp_release(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,16 +173,12 @@ int drm_agp_enable(struct drm_device * dev, struct drm_agp_mode mode)
|
||||||
|
|
||||||
EXPORT_SYMBOL(drm_agp_enable);
|
EXPORT_SYMBOL(drm_agp_enable);
|
||||||
|
|
||||||
int drm_agp_enable_ioctl(struct inode *inode, struct drm_file *file_priv,
|
int drm_agp_enable_ioctl(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_agp_mode *mode = data;
|
||||||
struct drm_agp_mode mode;
|
|
||||||
|
|
||||||
if (copy_from_user(&mode, (struct drm_agp_mode __user *) arg, sizeof(mode)))
|
return drm_agp_enable(dev, *mode);
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
return drm_agp_enable(dev, mode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -236,34 +227,13 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(drm_agp_alloc);
|
EXPORT_SYMBOL(drm_agp_alloc);
|
||||||
|
|
||||||
int drm_agp_alloc_ioctl(struct inode *inode, struct drm_file *file_priv,
|
|
||||||
unsigned int cmd, unsigned long arg)
|
int drm_agp_alloc_ioctl(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_agp_buffer *request = data;
|
||||||
struct drm_agp_buffer request;
|
|
||||||
struct drm_agp_buffer __user *argp = (void __user *)arg;
|
|
||||||
int err;
|
|
||||||
|
|
||||||
if (copy_from_user(&request, argp, sizeof(request)))
|
return drm_agp_alloc(dev, request);
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
err = drm_agp_alloc(dev, &request);
|
|
||||||
if (err)
|
|
||||||
return err;
|
|
||||||
|
|
||||||
if (copy_to_user(argp, &request, sizeof(request))) {
|
|
||||||
struct drm_agp_mem *entry;
|
|
||||||
list_for_each_entry(entry, &dev->agp->memory, head) {
|
|
||||||
if (entry->handle == request.handle)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
list_del(&entry->head);
|
|
||||||
drm_free_agp(entry->memory, entry->pages);
|
|
||||||
drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -317,17 +287,13 @@ int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(drm_agp_unbind);
|
EXPORT_SYMBOL(drm_agp_unbind);
|
||||||
|
|
||||||
int drm_agp_unbind_ioctl(struct inode *inode, struct drm_file *file_priv,
|
|
||||||
unsigned int cmd, unsigned long arg)
|
int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_agp_binding *request = data;
|
||||||
struct drm_agp_binding request;
|
|
||||||
|
|
||||||
if (copy_from_user
|
return drm_agp_unbind(dev, request);
|
||||||
(&request, (struct drm_agp_binding __user *) arg, sizeof(request)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
return drm_agp_unbind(dev, &request);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -365,17 +331,13 @@ int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(drm_agp_bind);
|
EXPORT_SYMBOL(drm_agp_bind);
|
||||||
|
|
||||||
int drm_agp_bind_ioctl(struct inode *inode, struct drm_file *file_priv,
|
|
||||||
unsigned int cmd, unsigned long arg)
|
int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_agp_binding *request = data;
|
||||||
struct drm_agp_binding request;
|
|
||||||
|
|
||||||
if (copy_from_user
|
return drm_agp_bind(dev, request);
|
||||||
(&request, (struct drm_agp_binding __user *) arg, sizeof(request)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
return drm_agp_bind(dev, &request);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -411,17 +373,14 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(drm_agp_free);
|
EXPORT_SYMBOL(drm_agp_free);
|
||||||
|
|
||||||
int drm_agp_free_ioctl(struct inode *inode, struct drm_file *file_priv,
|
|
||||||
unsigned int cmd, unsigned long arg)
|
|
||||||
|
int drm_agp_free_ioctl(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_agp_buffer *request = data;
|
||||||
struct drm_agp_buffer request;
|
|
||||||
|
|
||||||
if (copy_from_user
|
return drm_agp_free(dev, request);
|
||||||
(&request, (struct drm_agp_buffer __user *) arg, sizeof(request)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
return drm_agp_free(dev, &request);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -137,32 +137,29 @@ static int drm_remove_magic(struct drm_device * dev, drm_magic_t magic)
|
||||||
* searches an unique non-zero magic number and add it associating it with \p
|
* searches an unique non-zero magic number and add it associating it with \p
|
||||||
* file_priv.
|
* file_priv.
|
||||||
*/
|
*/
|
||||||
int drm_getmagic(struct inode *inode, struct drm_file *file_priv,
|
int drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
unsigned int cmd, unsigned long arg)
|
|
||||||
{
|
{
|
||||||
static drm_magic_t sequence = 0;
|
static drm_magic_t sequence = 0;
|
||||||
static DEFINE_SPINLOCK(lock);
|
static DEFINE_SPINLOCK(lock);
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_auth *auth = data;
|
||||||
struct drm_auth auth;
|
|
||||||
|
|
||||||
/* Find unique magic */
|
/* Find unique magic */
|
||||||
if (file_priv->magic) {
|
if (file_priv->magic) {
|
||||||
auth.magic = file_priv->magic;
|
auth->magic = file_priv->magic;
|
||||||
} else {
|
} else {
|
||||||
do {
|
do {
|
||||||
spin_lock(&lock);
|
spin_lock(&lock);
|
||||||
if (!sequence)
|
if (!sequence)
|
||||||
++sequence; /* reserve 0 */
|
++sequence; /* reserve 0 */
|
||||||
auth.magic = sequence++;
|
auth->magic = sequence++;
|
||||||
spin_unlock(&lock);
|
spin_unlock(&lock);
|
||||||
} while (drm_find_file(dev, auth.magic));
|
} while (drm_find_file(dev, auth->magic));
|
||||||
file_priv->magic = auth.magic;
|
file_priv->magic = auth->magic;
|
||||||
drm_add_magic(dev, file_priv, auth.magic);
|
drm_add_magic(dev, file_priv, auth->magic);
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_DEBUG("%u\n", auth.magic);
|
DRM_DEBUG("%u\n", auth->magic);
|
||||||
if (copy_to_user((struct drm_auth __user *) arg, &auth, sizeof(auth)))
|
|
||||||
return -EFAULT;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,19 +174,16 @@ int drm_getmagic(struct inode *inode, struct drm_file *file_priv,
|
||||||
*
|
*
|
||||||
* Checks if \p file_priv is associated with the magic number passed in \arg.
|
* Checks if \p file_priv is associated with the magic number passed in \arg.
|
||||||
*/
|
*/
|
||||||
int drm_authmagic(struct inode *inode, struct drm_file *file_priv,
|
int drm_authmagic(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_auth *auth = data;
|
||||||
struct drm_auth auth;
|
|
||||||
struct drm_file *file;
|
struct drm_file *file;
|
||||||
|
|
||||||
if (copy_from_user(&auth, (struct drm_auth __user *) arg, sizeof(auth)))
|
DRM_DEBUG("%u\n", auth->magic);
|
||||||
return -EFAULT;
|
if ((file = drm_find_file(dev, auth->magic))) {
|
||||||
DRM_DEBUG("%u\n", auth.magic);
|
|
||||||
if ((file = drm_find_file(dev, auth.magic))) {
|
|
||||||
file->authenticated = 1;
|
file->authenticated = 1;
|
||||||
drm_remove_magic(dev, auth.magic);
|
drm_remove_magic(dev, auth->magic);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
|
@ -332,34 +332,24 @@ int drm_addmap(struct drm_device * dev, unsigned int offset,
|
||||||
|
|
||||||
EXPORT_SYMBOL(drm_addmap);
|
EXPORT_SYMBOL(drm_addmap);
|
||||||
|
|
||||||
int drm_addmap_ioctl(struct inode *inode, struct drm_file *file_priv,
|
int drm_addmap_ioctl(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_map *map = data;
|
||||||
struct drm_map map;
|
|
||||||
struct drm_map_list *maplist;
|
struct drm_map_list *maplist;
|
||||||
struct drm_map __user *argp = (void __user *)arg;
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (copy_from_user(&map, argp, sizeof(map))) {
|
if (!(capable(CAP_SYS_ADMIN) || map->type == _DRM_AGP))
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(capable(CAP_SYS_ADMIN) || map.type == _DRM_AGP))
|
|
||||||
return -EPERM;
|
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,
|
||||||
&maplist);
|
map->flags, &maplist);
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (copy_to_user(argp, maplist->map, sizeof(struct drm_map)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
/* avoid a warning on 64-bit, this casting isn't very nice, but the API is set so too late */
|
/* avoid a warning on 64-bit, this casting isn't very nice, but the API is set so too late */
|
||||||
if (put_user((void *)(unsigned long)maplist->user_token, &argp->handle))
|
map->handle = (void *)(unsigned long)maplist->user_token;
|
||||||
return -EFAULT;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,23 +439,18 @@ int drm_rmmap(struct drm_device *dev, drm_local_map_t *map)
|
||||||
* gets used by drivers that the server doesn't need to care about. This seems
|
* gets used by drivers that the server doesn't need to care about. This seems
|
||||||
* unlikely.
|
* unlikely.
|
||||||
*/
|
*/
|
||||||
int drm_rmmap_ioctl(struct inode *inode, struct drm_file *file_priv,
|
int drm_rmmap_ioctl(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_map *request = data;
|
||||||
struct drm_map request;
|
|
||||||
drm_local_map_t *map = NULL;
|
drm_local_map_t *map = NULL;
|
||||||
struct drm_map_list *r_list;
|
struct drm_map_list *r_list;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (copy_from_user(&request, (struct drm_map __user *) arg, sizeof(request))) {
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
mutex_lock(&dev->struct_mutex);
|
mutex_lock(&dev->struct_mutex);
|
||||||
list_for_each_entry(r_list, &dev->maplist, head) {
|
list_for_each_entry(r_list, &dev->maplist, head) {
|
||||||
if (r_list->map &&
|
if (r_list->map &&
|
||||||
r_list->user_token == (unsigned long)request.handle &&
|
r_list->user_token == (unsigned long)request->handle &&
|
||||||
r_list->map->flags & _DRM_REMOVABLE) {
|
r_list->map->flags & _DRM_REMOVABLE) {
|
||||||
map = r_list->map;
|
map = r_list->map;
|
||||||
break;
|
break;
|
||||||
|
@ -1280,37 +1265,27 @@ static int drm_addbufs_fb(struct drm_device * dev, struct drm_buf_desc * request
|
||||||
* addbufs_sg() or addbufs_pci() for AGP, scatter-gather or consistent
|
* addbufs_sg() or addbufs_pci() for AGP, scatter-gather or consistent
|
||||||
* PCI memory respectively.
|
* PCI memory respectively.
|
||||||
*/
|
*/
|
||||||
int drm_addbufs(struct inode *inode, struct drm_file *file_priv,
|
int drm_addbufs(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_buf_desc request;
|
struct drm_buf_desc *request = data;
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
|
if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (copy_from_user(&request, (struct drm_buf_desc __user *) arg,
|
|
||||||
sizeof(request)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
#if __OS_HAS_AGP
|
#if __OS_HAS_AGP
|
||||||
if (request.flags & _DRM_AGP_BUFFER)
|
if (request->flags & _DRM_AGP_BUFFER)
|
||||||
ret = drm_addbufs_agp(dev, &request);
|
ret = drm_addbufs_agp(dev, request);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (request.flags & _DRM_SG_BUFFER)
|
if (request->flags & _DRM_SG_BUFFER)
|
||||||
ret = drm_addbufs_sg(dev, &request);
|
ret = drm_addbufs_sg(dev, request);
|
||||||
else if (request.flags & _DRM_FB_BUFFER)
|
else if (request->flags & _DRM_FB_BUFFER)
|
||||||
ret = drm_addbufs_fb(dev, &request);
|
ret = drm_addbufs_fb(dev, request);
|
||||||
else
|
else
|
||||||
ret = drm_addbufs_pci(dev, &request);
|
ret = drm_addbufs_pci(dev, request);
|
||||||
|
|
||||||
if (ret == 0) {
|
|
||||||
if (copy_to_user((void __user *)arg, &request, sizeof(request))) {
|
|
||||||
ret = -EFAULT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1331,13 +1306,11 @@ int drm_addbufs(struct inode *inode, struct drm_file *file_priv,
|
||||||
* lock, preventing of allocating more buffers after this call. Information
|
* lock, preventing of allocating more buffers after this call. Information
|
||||||
* about each requested buffer is then copied into user space.
|
* about each requested buffer is then copied into user space.
|
||||||
*/
|
*/
|
||||||
int drm_infobufs(struct inode *inode, struct drm_file *file_priv,
|
int drm_infobufs(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
struct drm_buf_info request;
|
struct drm_buf_info *request = data;
|
||||||
struct drm_buf_info __user *argp = (void __user *)arg;
|
|
||||||
int i;
|
int i;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
|
@ -1355,9 +1328,6 @@ int drm_infobufs(struct inode *inode, struct drm_file *file_priv,
|
||||||
++dev->buf_use; /* Can't allocate more after this call */
|
++dev->buf_use; /* Can't allocate more after this call */
|
||||||
spin_unlock(&dev->count_lock);
|
spin_unlock(&dev->count_lock);
|
||||||
|
|
||||||
if (copy_from_user(&request, argp, sizeof(request)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
for (i = 0, count = 0; i < DRM_MAX_ORDER + 1; i++) {
|
for (i = 0, count = 0; i < DRM_MAX_ORDER + 1; i++) {
|
||||||
if (dma->bufs[i].buf_count)
|
if (dma->bufs[i].buf_count)
|
||||||
++count;
|
++count;
|
||||||
|
@ -1365,11 +1335,11 @@ int drm_infobufs(struct inode *inode, struct drm_file *file_priv,
|
||||||
|
|
||||||
DRM_DEBUG("count = %d\n", count);
|
DRM_DEBUG("count = %d\n", count);
|
||||||
|
|
||||||
if (request.count >= count) {
|
if (request->count >= count) {
|
||||||
for (i = 0, count = 0; i < DRM_MAX_ORDER + 1; i++) {
|
for (i = 0, count = 0; i < DRM_MAX_ORDER + 1; i++) {
|
||||||
if (dma->bufs[i].buf_count) {
|
if (dma->bufs[i].buf_count) {
|
||||||
struct drm_buf_desc __user *to =
|
struct drm_buf_desc __user *to =
|
||||||
&request.list[count];
|
&request->list[count];
|
||||||
struct drm_buf_entry *from = &dma->bufs[i];
|
struct drm_buf_entry *from = &dma->bufs[i];
|
||||||
struct drm_freelist *list = &dma->bufs[i].freelist;
|
struct drm_freelist *list = &dma->bufs[i].freelist;
|
||||||
if (copy_to_user(&to->count,
|
if (copy_to_user(&to->count,
|
||||||
|
@ -1396,10 +1366,7 @@ int drm_infobufs(struct inode *inode, struct drm_file *file_priv,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
request.count = count;
|
request->count = count;
|
||||||
|
|
||||||
if (copy_to_user(argp, &request, sizeof(request)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1418,12 +1385,11 @@ int drm_infobufs(struct inode *inode, struct drm_file *file_priv,
|
||||||
*
|
*
|
||||||
* \note This ioctl is deprecated and mostly never used.
|
* \note This ioctl is deprecated and mostly never used.
|
||||||
*/
|
*/
|
||||||
int drm_markbufs(struct inode *inode, struct drm_file *file_priv,
|
int drm_markbufs(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
struct drm_buf_desc request;
|
struct drm_buf_desc *request = data;
|
||||||
int order;
|
int order;
|
||||||
struct drm_buf_entry *entry;
|
struct drm_buf_entry *entry;
|
||||||
|
|
||||||
|
@ -1433,24 +1399,20 @@ int drm_markbufs(struct inode *inode, struct drm_file *file_priv,
|
||||||
if (!dma)
|
if (!dma)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (copy_from_user(&request,
|
|
||||||
(struct drm_buf_desc __user *) arg, sizeof(request)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
DRM_DEBUG("%d, %d, %d\n",
|
DRM_DEBUG("%d, %d, %d\n",
|
||||||
request.size, request.low_mark, request.high_mark);
|
request->size, request->low_mark, request->high_mark);
|
||||||
order = drm_order(request.size);
|
order = drm_order(request->size);
|
||||||
if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
|
if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
entry = &dma->bufs[order];
|
entry = &dma->bufs[order];
|
||||||
|
|
||||||
if (request.low_mark < 0 || request.low_mark > entry->buf_count)
|
if (request->low_mark < 0 || request->low_mark > entry->buf_count)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (request.high_mark < 0 || request.high_mark > entry->buf_count)
|
if (request->high_mark < 0 || request->high_mark > entry->buf_count)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
entry->freelist.low_mark = request.low_mark;
|
entry->freelist.low_mark = request->low_mark;
|
||||||
entry->freelist.high_mark = request.high_mark;
|
entry->freelist.high_mark = request->high_mark;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1467,12 +1429,11 @@ int drm_markbufs(struct inode *inode, struct drm_file *file_priv,
|
||||||
* Calls free_buffer() for each used buffer.
|
* Calls free_buffer() for each used buffer.
|
||||||
* This function is primarily used for debugging.
|
* This function is primarily used for debugging.
|
||||||
*/
|
*/
|
||||||
int drm_freebufs(struct inode *inode, struct drm_file *file_priv,
|
int drm_freebufs(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
struct drm_buf_free request;
|
struct drm_buf_free *request = data;
|
||||||
int i;
|
int i;
|
||||||
int idx;
|
int idx;
|
||||||
struct drm_buf *buf;
|
struct drm_buf *buf;
|
||||||
|
@ -1483,13 +1444,9 @@ int drm_freebufs(struct inode *inode, struct drm_file *file_priv,
|
||||||
if (!dma)
|
if (!dma)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (copy_from_user(&request,
|
DRM_DEBUG("%d\n", request->count);
|
||||||
(struct drm_buf_free __user *) arg, sizeof(request)))
|
for (i = 0; i < request->count; i++) {
|
||||||
return -EFAULT;
|
if (copy_from_user(&idx, &request->list[i], sizeof(idx)))
|
||||||
|
|
||||||
DRM_DEBUG("%d\n", request.count);
|
|
||||||
for (i = 0; i < request.count; i++) {
|
|
||||||
if (copy_from_user(&idx, &request.list[i], sizeof(idx)))
|
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
if (idx < 0 || idx >= dma->buf_count) {
|
if (idx < 0 || idx >= dma->buf_count) {
|
||||||
DRM_ERROR("Index %d (of %d max)\n",
|
DRM_ERROR("Index %d (of %d max)\n",
|
||||||
|
@ -1522,17 +1479,15 @@ int drm_freebufs(struct inode *inode, struct drm_file *file_priv,
|
||||||
* offset equal to 0, which drm_mmap() interpretes as PCI buffers and calls
|
* offset equal to 0, which drm_mmap() interpretes as PCI buffers and calls
|
||||||
* drm_mmap_dma().
|
* drm_mmap_dma().
|
||||||
*/
|
*/
|
||||||
int drm_mapbufs(struct inode *inode, struct drm_file *file_priv,
|
int drm_mapbufs(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
struct drm_buf_map __user *argp = (void __user *)arg;
|
|
||||||
int retcode = 0;
|
int retcode = 0;
|
||||||
const int zero = 0;
|
const int zero = 0;
|
||||||
unsigned long virtual;
|
unsigned long virtual;
|
||||||
unsigned long address;
|
unsigned long address;
|
||||||
struct drm_buf_map request;
|
struct drm_buf_map *request = data;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
|
if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
|
||||||
|
@ -1549,10 +1504,7 @@ int drm_mapbufs(struct inode *inode, struct drm_file *file_priv,
|
||||||
dev->buf_use++; /* Can't allocate more after this call */
|
dev->buf_use++; /* Can't allocate more after this call */
|
||||||
spin_unlock(&dev->count_lock);
|
spin_unlock(&dev->count_lock);
|
||||||
|
|
||||||
if (copy_from_user(&request, argp, sizeof(request)))
|
if (request->count >= dma->buf_count) {
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
if (request.count >= dma->buf_count) {
|
|
||||||
if ((drm_core_has_AGP(dev) && (dma->flags & _DRM_DMA_USE_AGP))
|
if ((drm_core_has_AGP(dev) && (dma->flags & _DRM_DMA_USE_AGP))
|
||||||
|| (drm_core_check_feature(dev, DRIVER_SG)
|
|| (drm_core_check_feature(dev, DRIVER_SG)
|
||||||
&& (dma->flags & _DRM_DMA_USE_SG))
|
&& (dma->flags & _DRM_DMA_USE_SG))
|
||||||
|
@ -1565,11 +1517,11 @@ int drm_mapbufs(struct inode *inode, struct drm_file *file_priv,
|
||||||
retcode = -EINVAL;
|
retcode = -EINVAL;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
down_write(¤t->mm->mmap_sem);
|
down_write(¤t->mm->mmap_sem);
|
||||||
virtual = do_mmap(file_priv->filp, 0, map->size,
|
virtual = do_mmap(file_priv->filp, 0, map->size,
|
||||||
PROT_READ | PROT_WRITE,
|
PROT_READ | PROT_WRITE,
|
||||||
MAP_SHARED, token);
|
MAP_SHARED,
|
||||||
|
token);
|
||||||
up_write(¤t->mm->mmap_sem);
|
up_write(¤t->mm->mmap_sem);
|
||||||
} else {
|
} else {
|
||||||
down_write(¤t->mm->mmap_sem);
|
down_write(¤t->mm->mmap_sem);
|
||||||
|
@ -1583,28 +1535,28 @@ int drm_mapbufs(struct inode *inode, struct drm_file *file_priv,
|
||||||
retcode = (signed long)virtual;
|
retcode = (signed long)virtual;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
request.virtual = (void __user *)virtual;
|
request->virtual = (void __user *)virtual;
|
||||||
|
|
||||||
for (i = 0; i < dma->buf_count; i++) {
|
for (i = 0; i < dma->buf_count; i++) {
|
||||||
if (copy_to_user(&request.list[i].idx,
|
if (copy_to_user(&request->list[i].idx,
|
||||||
&dma->buflist[i]->idx,
|
&dma->buflist[i]->idx,
|
||||||
sizeof(request.list[0].idx))) {
|
sizeof(request->list[0].idx))) {
|
||||||
retcode = -EFAULT;
|
retcode = -EFAULT;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (copy_to_user(&request.list[i].total,
|
if (copy_to_user(&request->list[i].total,
|
||||||
&dma->buflist[i]->total,
|
&dma->buflist[i]->total,
|
||||||
sizeof(request.list[0].total))) {
|
sizeof(request->list[0].total))) {
|
||||||
retcode = -EFAULT;
|
retcode = -EFAULT;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (copy_to_user(&request.list[i].used,
|
if (copy_to_user(&request->list[i].used,
|
||||||
&zero, sizeof(zero))) {
|
&zero, sizeof(zero))) {
|
||||||
retcode = -EFAULT;
|
retcode = -EFAULT;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
address = virtual + dma->buflist[i]->offset; /* *** */
|
address = virtual + dma->buflist[i]->offset; /* *** */
|
||||||
if (copy_to_user(&request.list[i].address,
|
if (copy_to_user(&request->list[i].address,
|
||||||
&address, sizeof(address))) {
|
&address, sizeof(address))) {
|
||||||
retcode = -EFAULT;
|
retcode = -EFAULT;
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -1612,11 +1564,8 @@ int drm_mapbufs(struct inode *inode, struct drm_file *file_priv,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
request.count = dma->buf_count;
|
request->count = dma->buf_count;
|
||||||
DRM_DEBUG("%d buffers, retcode = %d\n", request.count, retcode);
|
DRM_DEBUG("%d buffers, retcode = %d\n", request->count, retcode);
|
||||||
|
|
||||||
if (copy_to_user(argp, &request, sizeof(request)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
return retcode;
|
return retcode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,21 +139,16 @@ void drm_ctxbitmap_cleanup(struct drm_device * dev)
|
||||||
* Gets the map from drm_device::ctx_idr with the handle specified and
|
* Gets the map from drm_device::ctx_idr with the handle specified and
|
||||||
* returns its handle.
|
* returns its handle.
|
||||||
*/
|
*/
|
||||||
int drm_getsareactx(struct inode *inode, struct drm_file *file_priv,
|
int drm_getsareactx(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_ctx_priv_map *request = data;
|
||||||
struct drm_ctx_priv_map __user *argp = (void __user *)arg;
|
|
||||||
struct drm_ctx_priv_map request;
|
|
||||||
struct drm_map *map;
|
struct drm_map *map;
|
||||||
struct drm_map_list *_entry;
|
struct drm_map_list *_entry;
|
||||||
|
|
||||||
if (copy_from_user(&request, argp, sizeof(request)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
mutex_lock(&dev->struct_mutex);
|
mutex_lock(&dev->struct_mutex);
|
||||||
|
|
||||||
map = idr_find(&dev->ctx_idr, request.ctx_id);
|
map = idr_find(&dev->ctx_idr, request->ctx_id);
|
||||||
if (!map) {
|
if (!map) {
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -161,19 +156,17 @@ int drm_getsareactx(struct inode *inode, struct drm_file *file_priv,
|
||||||
|
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
|
|
||||||
request.handle = NULL;
|
request->handle = NULL;
|
||||||
list_for_each_entry(_entry, &dev->maplist, head) {
|
list_for_each_entry(_entry, &dev->maplist, head) {
|
||||||
if (_entry->map == map) {
|
if (_entry->map == map) {
|
||||||
request.handle =
|
request->handle =
|
||||||
(void *)(unsigned long)_entry->user_token;
|
(void *)(unsigned long)_entry->user_token;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (request.handle == NULL)
|
if (request->handle == NULL)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (copy_to_user(argp, &request, sizeof(request)))
|
|
||||||
return -EFAULT;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,23 +182,17 @@ int drm_getsareactx(struct inode *inode, struct drm_file *file_priv,
|
||||||
* Searches the mapping specified in \p arg and update the entry in
|
* Searches the mapping specified in \p arg and update the entry in
|
||||||
* drm_device::ctx_idr with it.
|
* drm_device::ctx_idr with it.
|
||||||
*/
|
*/
|
||||||
int drm_setsareactx(struct inode *inode, struct drm_file *file_priv,
|
int drm_setsareactx(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_ctx_priv_map *request = data;
|
||||||
struct drm_ctx_priv_map request;
|
|
||||||
struct drm_map *map = NULL;
|
struct drm_map *map = NULL;
|
||||||
struct drm_map_list *r_list = NULL;
|
struct drm_map_list *r_list = NULL;
|
||||||
|
|
||||||
if (copy_from_user(&request,
|
|
||||||
(struct drm_ctx_priv_map __user *) arg,
|
|
||||||
sizeof(request)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
mutex_lock(&dev->struct_mutex);
|
mutex_lock(&dev->struct_mutex);
|
||||||
list_for_each_entry(r_list, &dev->maplist, head) {
|
list_for_each_entry(r_list, &dev->maplist, head) {
|
||||||
if (r_list->map
|
if (r_list->map
|
||||||
&& r_list->user_token == (unsigned long)request.handle)
|
&& r_list->user_token == (unsigned long) request->handle)
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
bad:
|
bad:
|
||||||
|
@ -217,10 +204,11 @@ int drm_setsareactx(struct inode *inode, struct drm_file *file_priv,
|
||||||
if (!map)
|
if (!map)
|
||||||
goto bad;
|
goto bad;
|
||||||
|
|
||||||
if (IS_ERR(idr_replace(&dev->ctx_idr, map, request.ctx_id)))
|
if (IS_ERR(idr_replace(&dev->ctx_idr, map, request->ctx_id)))
|
||||||
goto bad;
|
goto bad;
|
||||||
|
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,29 +283,23 @@ static int drm_context_switch_complete(struct drm_device * dev, int new)
|
||||||
* \param arg user argument pointing to a drm_ctx_res structure.
|
* \param arg user argument pointing to a drm_ctx_res structure.
|
||||||
* \return zero on success or a negative number on failure.
|
* \return zero on success or a negative number on failure.
|
||||||
*/
|
*/
|
||||||
int drm_resctx(struct inode *inode, struct drm_file *file_priv,
|
int drm_resctx(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_ctx_res res;
|
struct drm_ctx_res *res = data;
|
||||||
struct drm_ctx_res __user *argp = (void __user *)arg;
|
|
||||||
struct drm_ctx ctx;
|
struct drm_ctx ctx;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (copy_from_user(&res, argp, sizeof(res)))
|
if (res->count >= DRM_RESERVED_CONTEXTS) {
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
if (res.count >= DRM_RESERVED_CONTEXTS) {
|
|
||||||
memset(&ctx, 0, sizeof(ctx));
|
memset(&ctx, 0, sizeof(ctx));
|
||||||
for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
|
for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
|
||||||
ctx.handle = i;
|
ctx.handle = i;
|
||||||
if (copy_to_user(&res.contexts[i], &ctx, sizeof(ctx)))
|
if (copy_to_user(&res->contexts[i], &ctx, sizeof(ctx)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res.count = DRM_RESERVED_CONTEXTS;
|
res->count = DRM_RESERVED_CONTEXTS;
|
||||||
|
|
||||||
if (copy_to_user(argp, &res, sizeof(res)))
|
|
||||||
return -EFAULT;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,32 +314,27 @@ int drm_resctx(struct inode *inode, struct drm_file *file_priv,
|
||||||
*
|
*
|
||||||
* Get a new handle for the context and copy to userspace.
|
* Get a new handle for the context and copy to userspace.
|
||||||
*/
|
*/
|
||||||
int drm_addctx(struct inode *inode, struct drm_file *file_priv,
|
int drm_addctx(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
struct drm_ctx_list *ctx_entry;
|
struct drm_ctx_list *ctx_entry;
|
||||||
struct drm_ctx __user *argp = (void __user *)arg;
|
struct drm_ctx *ctx = data;
|
||||||
struct drm_ctx ctx;
|
|
||||||
|
|
||||||
if (copy_from_user(&ctx, argp, sizeof(ctx)))
|
ctx->handle = drm_ctxbitmap_next(dev);
|
||||||
return -EFAULT;
|
if (ctx->handle == DRM_KERNEL_CONTEXT) {
|
||||||
|
|
||||||
ctx.handle = drm_ctxbitmap_next(dev);
|
|
||||||
if (ctx.handle == DRM_KERNEL_CONTEXT) {
|
|
||||||
/* Skip kernel's context and get a new one. */
|
/* Skip kernel's context and get a new one. */
|
||||||
ctx.handle = drm_ctxbitmap_next(dev);
|
ctx->handle = drm_ctxbitmap_next(dev);
|
||||||
}
|
}
|
||||||
DRM_DEBUG("%d\n", ctx.handle);
|
DRM_DEBUG("%d\n", ctx->handle);
|
||||||
if (ctx.handle == -1) {
|
if (ctx->handle == -1) {
|
||||||
DRM_DEBUG("Not enough free contexts.\n");
|
DRM_DEBUG("Not enough free contexts.\n");
|
||||||
/* Should this return -EBUSY instead? */
|
/* Should this return -EBUSY instead? */
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -370,7 +347,7 @@ int drm_addctx(struct inode *inode, struct drm_file *file_priv,
|
||||||
}
|
}
|
||||||
|
|
||||||
INIT_LIST_HEAD(&ctx_entry->head);
|
INIT_LIST_HEAD(&ctx_entry->head);
|
||||||
ctx_entry->handle = ctx.handle;
|
ctx_entry->handle = ctx->handle;
|
||||||
ctx_entry->tag = file_priv;
|
ctx_entry->tag = file_priv;
|
||||||
|
|
||||||
mutex_lock(&dev->ctxlist_mutex);
|
mutex_lock(&dev->ctxlist_mutex);
|
||||||
|
@ -378,13 +355,10 @@ int drm_addctx(struct inode *inode, struct drm_file *file_priv,
|
||||||
++dev->ctx_count;
|
++dev->ctx_count;
|
||||||
mutex_unlock(&dev->ctxlist_mutex);
|
mutex_unlock(&dev->ctxlist_mutex);
|
||||||
|
|
||||||
if (copy_to_user(argp, &ctx, sizeof(ctx)))
|
|
||||||
return -EFAULT;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int drm_modctx(struct inode *inode, struct drm_file *file_priv,
|
int drm_modctx(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
unsigned int cmd, unsigned long arg)
|
|
||||||
{
|
{
|
||||||
/* This does nothing */
|
/* This does nothing */
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -399,20 +373,13 @@ int drm_modctx(struct inode *inode, struct drm_file *file_priv,
|
||||||
* \param arg user argument pointing to a drm_ctx structure.
|
* \param arg user argument pointing to a drm_ctx structure.
|
||||||
* \return zero on success or a negative number on failure.
|
* \return zero on success or a negative number on failure.
|
||||||
*/
|
*/
|
||||||
int drm_getctx(struct inode *inode, struct drm_file *file_priv,
|
int drm_getctx(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
unsigned int cmd, unsigned long arg)
|
|
||||||
{
|
{
|
||||||
struct drm_ctx __user *argp = (void __user *)arg;
|
struct drm_ctx *ctx = data;
|
||||||
struct drm_ctx ctx;
|
|
||||||
|
|
||||||
if (copy_from_user(&ctx, argp, sizeof(ctx)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
/* This is 0, because we don't handle any context flags */
|
/* This is 0, because we don't handle any context flags */
|
||||||
ctx.flags = 0;
|
ctx->flags = 0;
|
||||||
|
|
||||||
if (copy_to_user(argp, &ctx, sizeof(ctx)))
|
|
||||||
return -EFAULT;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,17 +394,13 @@ int drm_getctx(struct inode *inode, struct drm_file *file_priv,
|
||||||
*
|
*
|
||||||
* Calls context_switch().
|
* Calls context_switch().
|
||||||
*/
|
*/
|
||||||
int drm_switchctx(struct inode *inode, struct drm_file *file_priv,
|
int drm_switchctx(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_ctx *ctx = data;
|
||||||
struct drm_ctx ctx;
|
|
||||||
|
|
||||||
if (copy_from_user(&ctx, (struct drm_ctx __user *) arg, sizeof(ctx)))
|
DRM_DEBUG("%d\n", ctx->handle);
|
||||||
return -EFAULT;
|
return drm_context_switch(dev, dev->last_context, ctx->handle);
|
||||||
|
|
||||||
DRM_DEBUG("%d\n", ctx.handle);
|
|
||||||
return drm_context_switch(dev, dev->last_context, ctx.handle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -451,17 +414,13 @@ int drm_switchctx(struct inode *inode, struct drm_file *file_priv,
|
||||||
*
|
*
|
||||||
* Calls context_switch_complete().
|
* Calls context_switch_complete().
|
||||||
*/
|
*/
|
||||||
int drm_newctx(struct inode *inode, struct drm_file *file_priv,
|
int drm_newctx(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_ctx *ctx = data;
|
||||||
struct drm_ctx ctx;
|
|
||||||
|
|
||||||
if (copy_from_user(&ctx, (struct drm_ctx __user *) arg, sizeof(ctx)))
|
DRM_DEBUG("%d\n", ctx->handle);
|
||||||
return -EFAULT;
|
drm_context_switch_complete(dev, ctx->handle);
|
||||||
|
|
||||||
DRM_DEBUG("%d\n", ctx.handle);
|
|
||||||
drm_context_switch_complete(dev, ctx.handle);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -477,23 +436,19 @@ int drm_newctx(struct inode *inode, struct drm_file *file_priv,
|
||||||
*
|
*
|
||||||
* If not the special kernel context, calls ctxbitmap_free() to free the specified context.
|
* If not the special kernel context, calls ctxbitmap_free() to free the specified context.
|
||||||
*/
|
*/
|
||||||
int drm_rmctx(struct inode *inode, struct drm_file *file_priv,
|
int drm_rmctx(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_ctx *ctx = data;
|
||||||
struct drm_ctx ctx;
|
|
||||||
|
|
||||||
if (copy_from_user(&ctx, (struct drm_ctx __user *) arg, sizeof(ctx)))
|
DRM_DEBUG("%d\n", ctx->handle);
|
||||||
return -EFAULT;
|
if (ctx->handle == DRM_KERNEL_CONTEXT + 1) {
|
||||||
|
|
||||||
DRM_DEBUG("%d\n", ctx.handle);
|
|
||||||
if (ctx.handle == DRM_KERNEL_CONTEXT + 1) {
|
|
||||||
file_priv->remove_auth_on_close = 1;
|
file_priv->remove_auth_on_close = 1;
|
||||||
}
|
}
|
||||||
if (ctx.handle != DRM_KERNEL_CONTEXT) {
|
if (ctx->handle != DRM_KERNEL_CONTEXT) {
|
||||||
if (dev->driver->context_dtor)
|
if (dev->driver->context_dtor)
|
||||||
dev->driver->context_dtor(dev, ctx.handle);
|
dev->driver->context_dtor(dev, ctx->handle);
|
||||||
drm_ctxbitmap_free(dev, ctx.handle);
|
drm_ctxbitmap_free(dev, ctx->handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_lock(&dev->ctxlist_mutex);
|
mutex_lock(&dev->ctxlist_mutex);
|
||||||
|
@ -501,7 +456,7 @@ int drm_rmctx(struct inode *inode, struct drm_file *file_priv,
|
||||||
struct drm_ctx_list *pos, *n;
|
struct drm_ctx_list *pos, *n;
|
||||||
|
|
||||||
list_for_each_entry_safe(pos, n, &dev->ctxlist, head) {
|
list_for_each_entry_safe(pos, n, &dev->ctxlist, head) {
|
||||||
if (pos->handle == ctx.handle) {
|
if (pos->handle == ctx->handle) {
|
||||||
list_del(&pos->head);
|
list_del(&pos->head);
|
||||||
drm_free(pos, sizeof(*pos), DRM_MEM_CTXLIST);
|
drm_free(pos, sizeof(*pos), DRM_MEM_CTXLIST);
|
||||||
--dev->ctx_count;
|
--dev->ctx_count;
|
||||||
|
|
|
@ -40,11 +40,10 @@
|
||||||
/**
|
/**
|
||||||
* Allocate drawable ID and memory to store information about it.
|
* Allocate drawable ID and memory to store information about it.
|
||||||
*/
|
*/
|
||||||
int drm_adddraw(DRM_IOCTL_ARGS)
|
int drm_adddraw(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
unsigned long irqflags;
|
unsigned long irqflags;
|
||||||
struct drm_draw draw;
|
struct drm_draw *draw = data;
|
||||||
int new_id = 0;
|
int new_id = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -63,11 +62,9 @@ again:
|
||||||
|
|
||||||
spin_unlock_irqrestore(&dev->drw_lock, irqflags);
|
spin_unlock_irqrestore(&dev->drw_lock, irqflags);
|
||||||
|
|
||||||
draw.handle = new_id;
|
draw->handle = new_id;
|
||||||
|
|
||||||
DRM_DEBUG("%d\n", draw.handle);
|
DRM_DEBUG("%d\n", draw->handle);
|
||||||
|
|
||||||
DRM_COPY_TO_USER_IOCTL((struct drm_draw __user *)data, draw, sizeof(draw));
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -75,69 +72,61 @@ again:
|
||||||
/**
|
/**
|
||||||
* Free drawable ID and memory to store information about it.
|
* Free drawable ID and memory to store information about it.
|
||||||
*/
|
*/
|
||||||
int drm_rmdraw(DRM_IOCTL_ARGS)
|
int drm_rmdraw(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
struct drm_draw *draw = data;
|
||||||
struct drm_draw draw;
|
|
||||||
unsigned long irqflags;
|
unsigned long irqflags;
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(draw, (struct drm_draw __user *) data,
|
|
||||||
sizeof(draw));
|
|
||||||
|
|
||||||
spin_lock_irqsave(&dev->drw_lock, irqflags);
|
spin_lock_irqsave(&dev->drw_lock, irqflags);
|
||||||
|
|
||||||
drm_free(drm_get_drawable_info(dev, draw.handle),
|
drm_free(drm_get_drawable_info(dev, draw->handle),
|
||||||
sizeof(struct drm_drawable_info), DRM_MEM_BUFS);
|
sizeof(struct drm_drawable_info), DRM_MEM_BUFS);
|
||||||
|
|
||||||
idr_remove(&dev->drw_idr, draw.handle);
|
idr_remove(&dev->drw_idr, draw->handle);
|
||||||
|
|
||||||
spin_unlock_irqrestore(&dev->drw_lock, irqflags);
|
spin_unlock_irqrestore(&dev->drw_lock, irqflags);
|
||||||
DRM_DEBUG("%d\n", draw.handle);
|
DRM_DEBUG("%d\n", draw->handle);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int drm_update_drawable_info(DRM_IOCTL_ARGS)
|
int drm_update_drawable_info(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
struct drm_update_draw *update = data;
|
||||||
struct drm_update_draw update;
|
|
||||||
unsigned long irqflags;
|
unsigned long irqflags;
|
||||||
struct drm_clip_rect *rects;
|
struct drm_clip_rect *rects;
|
||||||
struct drm_drawable_info *info;
|
struct drm_drawable_info *info;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(update, (struct drm_update_draw __user *) data,
|
info = idr_find(&dev->drw_idr, update->handle);
|
||||||
sizeof(update));
|
|
||||||
|
|
||||||
info = idr_find(&dev->drw_idr, update.handle);
|
|
||||||
if (!info) {
|
if (!info) {
|
||||||
info = drm_calloc(1, sizeof(*info), DRM_MEM_BUFS);
|
info = drm_calloc(1, sizeof(*info), DRM_MEM_BUFS);
|
||||||
if (!info)
|
if (!info)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
if (IS_ERR(idr_replace(&dev->drw_idr, info, update.handle))) {
|
if (IS_ERR(idr_replace(&dev->drw_idr, info, update->handle))) {
|
||||||
DRM_ERROR("No such drawable %d\n", update.handle);
|
DRM_ERROR("No such drawable %d\n", update->handle);
|
||||||
drm_free(info, sizeof(*info), DRM_MEM_BUFS);
|
drm_free(info, sizeof(*info), DRM_MEM_BUFS);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (update.type) {
|
switch (update->type) {
|
||||||
case DRM_DRAWABLE_CLIPRECTS:
|
case DRM_DRAWABLE_CLIPRECTS:
|
||||||
if (update.num != info->num_rects) {
|
if (update->num != info->num_rects) {
|
||||||
rects = drm_alloc(update.num * sizeof(struct drm_clip_rect),
|
rects = drm_alloc(update->num * sizeof(struct drm_clip_rect),
|
||||||
DRM_MEM_BUFS);
|
DRM_MEM_BUFS);
|
||||||
} else
|
} else
|
||||||
rects = info->rects;
|
rects = info->rects;
|
||||||
|
|
||||||
if (update.num && !rects) {
|
if (update->num && !rects) {
|
||||||
DRM_ERROR("Failed to allocate cliprect memory\n");
|
DRM_ERROR("Failed to allocate cliprect memory\n");
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (update.num && DRM_COPY_FROM_USER(rects,
|
if (update->num && DRM_COPY_FROM_USER(rects,
|
||||||
(struct drm_clip_rect __user *)
|
(struct drm_clip_rect __user *)
|
||||||
(unsigned long)update.data,
|
(unsigned long)update->data,
|
||||||
update.num *
|
update->num *
|
||||||
sizeof(*rects))) {
|
sizeof(*rects))) {
|
||||||
DRM_ERROR("Failed to copy cliprects from userspace\n");
|
DRM_ERROR("Failed to copy cliprects from userspace\n");
|
||||||
err = -EFAULT;
|
err = -EFAULT;
|
||||||
|
@ -152,15 +141,15 @@ int drm_update_drawable_info(DRM_IOCTL_ARGS)
|
||||||
}
|
}
|
||||||
|
|
||||||
info->rects = rects;
|
info->rects = rects;
|
||||||
info->num_rects = update.num;
|
info->num_rects = update->num;
|
||||||
|
|
||||||
spin_unlock_irqrestore(&dev->drw_lock, irqflags);
|
spin_unlock_irqrestore(&dev->drw_lock, irqflags);
|
||||||
|
|
||||||
DRM_DEBUG("Updated %d cliprects for drawable %d\n",
|
DRM_DEBUG("Updated %d cliprects for drawable %d\n",
|
||||||
info->num_rects, update.handle);
|
info->num_rects, update->handle);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DRM_ERROR("Invalid update type %d\n", update.type);
|
DRM_ERROR("Invalid update type %d\n", update->type);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +157,7 @@ int drm_update_drawable_info(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (rects != info->rects)
|
if (rects != info->rects)
|
||||||
drm_free(rects, update.num * sizeof(struct drm_clip_rect),
|
drm_free(rects, update->num * sizeof(struct drm_clip_rect),
|
||||||
DRM_MEM_BUFS);
|
DRM_MEM_BUFS);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
|
|
@ -49,73 +49,74 @@
|
||||||
#include "drmP.h"
|
#include "drmP.h"
|
||||||
#include "drm_core.h"
|
#include "drm_core.h"
|
||||||
|
|
||||||
static int drm_version(struct inode *inode, struct drm_file *file_priv,
|
static int drm_version(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
|
|
||||||
/** Ioctl table */
|
/** Ioctl table */
|
||||||
static drm_ioctl_desc_t drm_ioctls[] = {
|
static struct drm_ioctl_desc drm_ioctls[] = {
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = {drm_version, 0},
|
DRM_IOCTL_DEF(DRM_IOCTL_VERSION, drm_version, 0),
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = {drm_getunique, 0},
|
DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0),
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = {drm_getmagic, 0},
|
DRM_IOCTL_DEF(DRM_IOCTL_GET_MAGIC, drm_getmagic, 0),
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = {drm_irq_by_busid, DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_IOCTL_IRQ_BUSID, drm_irq_by_busid, DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_GET_MAP)] = {drm_getmap, 0},
|
DRM_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_getmap, 0),
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = {drm_getclient, 0},
|
DRM_IOCTL_DEF(DRM_IOCTL_GET_CLIENT, drm_getclient, 0),
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = {drm_getstats, 0},
|
DRM_IOCTL_DEF(DRM_IOCTL_GET_STATS, drm_getstats, 0),
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_SET_VERSION)] = {drm_setversion, DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(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_BLOCK)] = {drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = {drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = {drm_authmagic, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
|
||||||
|
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = {drm_addmap_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_IOCTL_SET_UNIQUE, drm_setunique, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_RM_MAP)] = {drm_rmmap_ioctl, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_IOCTL_BLOCK, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
|
DRM_IOCTL_DEF(DRM_IOCTL_UNBLOCK, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
|
DRM_IOCTL_DEF(DRM_IOCTL_AUTH_MAGIC, drm_authmagic, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
|
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)] = {drm_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_IOCTL_ADD_MAP, drm_addmap_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)] = {drm_getsareactx, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_IOCTL_RM_MAP, drm_rmmap_ioctl, DRM_AUTH),
|
||||||
|
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = {drm_addctx, DRM_AUTH|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_IOCTL_SET_SAREA_CTX, drm_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = {drm_rmctx, DRM_AUTH|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_IOCTL_GET_SAREA_CTX, drm_getsareactx, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = {drm_modctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = {drm_getctx, DRM_AUTH},
|
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = {drm_switchctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = {drm_newctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = {drm_resctx, DRM_AUTH},
|
|
||||||
|
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = {drm_adddraw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_IOCTL_ADD_CTX, drm_addctx, DRM_AUTH|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = {drm_rmdraw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_IOCTL_RM_CTX, drm_rmctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
|
DRM_IOCTL_DEF(DRM_IOCTL_MOD_CTX, drm_modctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
|
DRM_IOCTL_DEF(DRM_IOCTL_GET_CTX, drm_getctx, DRM_AUTH),
|
||||||
|
DRM_IOCTL_DEF(DRM_IOCTL_SWITCH_CTX, drm_switchctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
|
DRM_IOCTL_DEF(DRM_IOCTL_NEW_CTX, drm_newctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
|
DRM_IOCTL_DEF(DRM_IOCTL_RES_CTX, drm_resctx, DRM_AUTH),
|
||||||
|
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = {drm_lock, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_IOCTL_ADD_DRAW, drm_adddraw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = {drm_unlock, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_IOCTL_RM_DRAW, drm_rmdraw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
|
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = {drm_noop, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_IOCTL_LOCK, drm_lock, DRM_AUTH),
|
||||||
|
DRM_IOCTL_DEF(DRM_IOCTL_UNLOCK, drm_unlock, DRM_AUTH),
|
||||||
|
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = {drm_addbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_IOCTL_FINISH, drm_noop, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = {drm_markbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = {drm_infobufs, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_IOCTL_ADD_BUFS, drm_addbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = {drm_mapbufs, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_IOCTL_MARK_BUFS, drm_markbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = {drm_freebufs, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_IOCTL_INFO_BUFS, drm_infobufs, DRM_AUTH),
|
||||||
|
DRM_IOCTL_DEF(DRM_IOCTL_MAP_BUFS, drm_mapbufs, DRM_AUTH),
|
||||||
|
DRM_IOCTL_DEF(DRM_IOCTL_FREE_BUFS, drm_freebufs, DRM_AUTH),
|
||||||
/* 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_DEF(DRM_IOCTL_DMA, NULL, DRM_AUTH),
|
||||||
|
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = {drm_control, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(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, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(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, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(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, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(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, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_IOCTL_AGP_INFO, drm_agp_info_ioctl, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = {drm_agp_alloc_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(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_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(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_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(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_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(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, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_IOCTL_SG_ALLOC, drm_sg_alloc_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = {drm_sg_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(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},
|
DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank, 0),
|
||||||
|
|
||||||
[DRM_IOCTL_NR(DRM_IOCTL_UPDATE_DRAW)] = {drm_update_drawable_info, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_update_drawable_info, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls )
|
#define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls )
|
||||||
|
@ -418,26 +419,19 @@ module_exit(drm_core_exit);
|
||||||
*
|
*
|
||||||
* Fills in the version information in \p arg.
|
* Fills in the version information in \p arg.
|
||||||
*/
|
*/
|
||||||
static int drm_version(struct inode *inode, struct drm_file *file_priv,
|
static int drm_version(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_version *version = data;
|
||||||
struct drm_version __user *argp = (void __user *)arg;
|
|
||||||
struct drm_version version;
|
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (copy_from_user(&version, argp, sizeof(version)))
|
version->version_major = dev->driver->major;
|
||||||
return -EFAULT;
|
version->version_minor = dev->driver->minor;
|
||||||
|
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);
|
||||||
|
|
||||||
version.version_major = dev->driver->major;
|
|
||||||
version.version_minor = dev->driver->minor;
|
|
||||||
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)))
|
|
||||||
return -EFAULT;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,10 +452,11 @@ int drm_ioctl(struct inode *inode, struct file *filp,
|
||||||
{
|
{
|
||||||
struct drm_file *file_priv = filp->private_data;
|
struct drm_file *file_priv = filp->private_data;
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_device *dev = file_priv->head->dev;
|
||||||
drm_ioctl_desc_t *ioctl;
|
struct drm_ioctl_desc *ioctl;
|
||||||
drm_ioctl_t *func;
|
drm_ioctl_t *func;
|
||||||
unsigned int nr = DRM_IOCTL_NR(cmd);
|
unsigned int nr = DRM_IOCTL_NR(cmd);
|
||||||
int retcode = -EINVAL;
|
int retcode = -EINVAL;
|
||||||
|
char *kdata = NULL;
|
||||||
|
|
||||||
atomic_inc(&dev->ioctl_count);
|
atomic_inc(&dev->ioctl_count);
|
||||||
atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
|
atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
|
||||||
|
@ -488,6 +483,7 @@ int drm_ioctl(struct inode *inode, struct file *filp,
|
||||||
if ((nr == DRM_IOCTL_NR(DRM_IOCTL_DMA)) && dev->driver->dma_ioctl)
|
if ((nr == DRM_IOCTL_NR(DRM_IOCTL_DMA)) && dev->driver->dma_ioctl)
|
||||||
func = dev->driver->dma_ioctl;
|
func = dev->driver->dma_ioctl;
|
||||||
|
|
||||||
|
|
||||||
if (!func) {
|
if (!func) {
|
||||||
DRM_DEBUG("no function\n");
|
DRM_DEBUG("no function\n");
|
||||||
retcode = -EINVAL;
|
retcode = -EINVAL;
|
||||||
|
@ -496,10 +492,31 @@ int drm_ioctl(struct inode *inode, struct file *filp,
|
||||||
((ioctl->flags & DRM_MASTER) && !file_priv->master)) {
|
((ioctl->flags & DRM_MASTER) && !file_priv->master)) {
|
||||||
retcode = -EACCES;
|
retcode = -EACCES;
|
||||||
} else {
|
} else {
|
||||||
retcode = func(inode, file_priv, cmd, arg);
|
if (cmd & (IOC_IN | IOC_OUT)) {
|
||||||
|
kdata = kmalloc(_IOC_SIZE(cmd), GFP_KERNEL);
|
||||||
|
if (!kdata)
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmd & IOC_IN) {
|
||||||
|
if (copy_from_user(kdata, (void __user *)arg,
|
||||||
|
_IOC_SIZE(cmd)) != 0) {
|
||||||
|
retcode = -EACCES;
|
||||||
|
goto err_i1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
retcode = func(dev, kdata, file_priv);
|
||||||
|
|
||||||
|
if (cmd & IOC_OUT) {
|
||||||
|
if (copy_to_user((void __user *)arg, kdata,
|
||||||
|
_IOC_SIZE(cmd)) != 0)
|
||||||
|
retcode = -EACCES;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err_i1:
|
err_i1:
|
||||||
|
if (kdata)
|
||||||
|
kfree(kdata);
|
||||||
atomic_dec(&dev->ioctl_count);
|
atomic_dec(&dev->ioctl_count);
|
||||||
if (retcode)
|
if (retcode)
|
||||||
DRM_DEBUG("ret = %x\n", retcode);
|
DRM_DEBUG("ret = %x\n", retcode);
|
||||||
|
|
|
@ -343,7 +343,7 @@ int drm_release(struct inode *inode, struct file *filp)
|
||||||
dev->open_count);
|
dev->open_count);
|
||||||
|
|
||||||
if (dev->driver->reclaim_buffers_locked && dev->lock.hw_lock) {
|
if (dev->driver->reclaim_buffers_locked && dev->lock.hw_lock) {
|
||||||
if (drm_i_have_hw_lock(file_priv)) {
|
if (drm_i_have_hw_lock(dev, file_priv)) {
|
||||||
dev->driver->reclaim_buffers_locked(dev, file_priv);
|
dev->driver->reclaim_buffers_locked(dev, file_priv);
|
||||||
} else {
|
} else {
|
||||||
unsigned long _end=jiffies + 3*DRM_HZ;
|
unsigned long _end=jiffies + 3*DRM_HZ;
|
||||||
|
@ -383,7 +383,7 @@ int drm_release(struct inode *inode, struct file *filp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drm_i_have_hw_lock(file_priv)) {
|
if (drm_i_have_hw_lock(dev, file_priv)) {
|
||||||
DRM_DEBUG("File %p released, freeing lock for context %d\n",
|
DRM_DEBUG("File %p released, freeing lock for context %d\n",
|
||||||
filp, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
|
filp, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
|
||||||
|
|
||||||
|
|
|
@ -49,22 +49,17 @@
|
||||||
*
|
*
|
||||||
* Copies the bus id from drm_device::unique into user space.
|
* Copies the bus id from drm_device::unique into user space.
|
||||||
*/
|
*/
|
||||||
int drm_getunique(struct inode *inode, struct drm_file *file_priv,
|
int drm_getunique(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_unique *u = data;
|
||||||
struct drm_unique __user *argp = (void __user *)arg;
|
|
||||||
struct drm_unique u;
|
|
||||||
|
|
||||||
if (copy_from_user(&u, argp, sizeof(u)))
|
if (u->unique_len >= dev->unique_len) {
|
||||||
return -EFAULT;
|
if (copy_to_user(u->unique, dev->unique, dev->unique_len))
|
||||||
if (u.unique_len >= dev->unique_len) {
|
|
||||||
if (copy_to_user(u.unique, dev->unique, dev->unique_len))
|
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
u.unique_len = dev->unique_len;
|
u->unique_len = dev->unique_len;
|
||||||
if (copy_to_user(argp, &u, sizeof(u)))
|
|
||||||
return -EFAULT;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,27 +77,23 @@ int drm_getunique(struct inode *inode, struct drm_file *file_priv,
|
||||||
* in interface version 1.1 and will return EBUSY when setversion has requested
|
* in interface version 1.1 and will return EBUSY when setversion has requested
|
||||||
* version 1.1 or greater.
|
* version 1.1 or greater.
|
||||||
*/
|
*/
|
||||||
int drm_setunique(struct inode *inode, struct drm_file *file_priv,
|
int drm_setunique(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_unique *u = data;
|
||||||
struct drm_unique u;
|
|
||||||
int domain, bus, slot, func, ret;
|
int domain, bus, slot, func, ret;
|
||||||
|
|
||||||
if (dev->unique_len || dev->unique)
|
if (dev->unique_len || dev->unique)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
if (copy_from_user(&u, (struct drm_unique __user *) arg, sizeof(u)))
|
if (!u->unique_len || u->unique_len > 1024)
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
if (!u.unique_len || u.unique_len > 1024)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
dev->unique_len = u.unique_len;
|
dev->unique_len = u->unique_len;
|
||||||
dev->unique = drm_alloc(u.unique_len + 1, DRM_MEM_DRIVER);
|
dev->unique = drm_alloc(u->unique_len + 1, DRM_MEM_DRIVER);
|
||||||
if (!dev->unique)
|
if (!dev->unique)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
if (copy_from_user(dev->unique, u.unique, dev->unique_len))
|
if (copy_from_user(dev->unique, u->unique, dev->unique_len))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
dev->unique[dev->unique_len] = '\0';
|
dev->unique[dev->unique_len] = '\0';
|
||||||
|
@ -179,20 +170,16 @@ static int drm_set_busid(struct drm_device * dev)
|
||||||
* Searches for the mapping with the specified offset and copies its information
|
* Searches for the mapping with the specified offset and copies its information
|
||||||
* into userspace
|
* into userspace
|
||||||
*/
|
*/
|
||||||
int drm_getmap(struct inode *inode, struct drm_file *file_priv,
|
int drm_getmap(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_map *map = data;
|
||||||
struct drm_map __user *argp = (void __user *)arg;
|
|
||||||
struct drm_map map;
|
|
||||||
struct drm_map_list *r_list = NULL;
|
struct drm_map_list *r_list = NULL;
|
||||||
struct list_head *list;
|
struct list_head *list;
|
||||||
int idx;
|
int idx;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (copy_from_user(&map, argp, sizeof(map)))
|
idx = map->offset;
|
||||||
return -EFAULT;
|
|
||||||
idx = map.offset;
|
|
||||||
|
|
||||||
mutex_lock(&dev->struct_mutex);
|
mutex_lock(&dev->struct_mutex);
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
|
@ -213,16 +200,14 @@ int drm_getmap(struct inode *inode, struct drm_file *file_priv,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
map.offset = r_list->map->offset;
|
map->offset = r_list->map->offset;
|
||||||
map.size = r_list->map->size;
|
map->size = r_list->map->size;
|
||||||
map.type = r_list->map->type;
|
map->type = r_list->map->type;
|
||||||
map.flags = r_list->map->flags;
|
map->flags = r_list->map->flags;
|
||||||
map.handle = (void *)(unsigned long)r_list->user_token;
|
map->handle = (void *)(unsigned long) r_list->user_token;
|
||||||
map.mtrr = r_list->map->mtrr;
|
map->mtrr = r_list->map->mtrr;
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
|
|
||||||
if (copy_to_user(argp, &map, sizeof(map)))
|
|
||||||
return -EFAULT;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,19 +224,15 @@ int drm_getmap(struct inode *inode, struct drm_file *file_priv,
|
||||||
* Searches for the client with the specified index and copies its information
|
* Searches for the client with the specified index and copies its information
|
||||||
* into userspace
|
* into userspace
|
||||||
*/
|
*/
|
||||||
int drm_getclient(struct inode *inode, struct drm_file *file_priv,
|
int drm_getclient(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_client *client = data;
|
||||||
struct drm_client __user *argp = (struct drm_client __user *)arg;
|
|
||||||
struct drm_client client;
|
|
||||||
struct drm_file *pt;
|
struct drm_file *pt;
|
||||||
int idx;
|
int idx;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (copy_from_user(&client, argp, sizeof(client)))
|
idx = client->idx;
|
||||||
return -EFAULT;
|
|
||||||
idx = client.idx;
|
|
||||||
mutex_lock(&dev->struct_mutex);
|
mutex_lock(&dev->struct_mutex);
|
||||||
|
|
||||||
if (list_empty(&dev->filelist)) {
|
if (list_empty(&dev->filelist)) {
|
||||||
|
@ -265,15 +246,13 @@ int drm_getclient(struct inode *inode, struct drm_file *file_priv,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
client.auth = pt->authenticated;
|
client->auth = pt->authenticated;
|
||||||
client.pid = pt->pid;
|
client->pid = pt->pid;
|
||||||
client.uid = pt->uid;
|
client->uid = pt->uid;
|
||||||
client.magic = pt->magic;
|
client->magic = pt->magic;
|
||||||
client.iocs = pt->ioctl_count;
|
client->iocs = pt->ioctl_count;
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
|
|
||||||
if (copy_to_user(argp, &client, sizeof(client)))
|
|
||||||
return -EFAULT;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,32 +266,29 @@ int drm_getclient(struct inode *inode, struct drm_file *file_priv,
|
||||||
*
|
*
|
||||||
* \return zero on success or a negative number on failure.
|
* \return zero on success or a negative number on failure.
|
||||||
*/
|
*/
|
||||||
int drm_getstats(struct inode *inode, struct drm_file *file_priv,
|
int drm_getstats(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_stats *stats = data;
|
||||||
struct drm_stats stats;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
memset(&stats, 0, sizeof(stats));
|
memset(stats, 0, sizeof(stats));
|
||||||
|
|
||||||
mutex_lock(&dev->struct_mutex);
|
mutex_lock(&dev->struct_mutex);
|
||||||
|
|
||||||
for (i = 0; i < dev->counters; i++) {
|
for (i = 0; i < dev->counters; i++) {
|
||||||
if (dev->types[i] == _DRM_STAT_LOCK)
|
if (dev->types[i] == _DRM_STAT_LOCK)
|
||||||
stats.data[i].value
|
stats->data[i].value =
|
||||||
= (dev->lock.hw_lock ? dev->lock.hw_lock->lock : 0);
|
(dev->lock.hw_lock ? dev->lock.hw_lock->lock : 0);
|
||||||
else
|
else
|
||||||
stats.data[i].value = atomic_read(&dev->counts[i]);
|
stats->data[i].value = atomic_read(&dev->counts[i]);
|
||||||
stats.data[i].type = dev->types[i];
|
stats->data[i].type = dev->types[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
stats.count = dev->counters;
|
stats->count = dev->counters;
|
||||||
|
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
|
|
||||||
if (copy_to_user((struct drm_stats __user *) arg, &stats, sizeof(stats)))
|
|
||||||
return -EFAULT;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,57 +303,52 @@ int drm_getstats(struct inode *inode, struct drm_file *file_priv,
|
||||||
*
|
*
|
||||||
* Sets the requested interface version
|
* Sets the requested interface version
|
||||||
*/
|
*/
|
||||||
int drm_setversion(DRM_IOCTL_ARGS)
|
int drm_setversion(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
struct drm_set_version *sv = data;
|
||||||
struct drm_set_version sv;
|
int if_version, retcode = 0;
|
||||||
struct drm_set_version retv;
|
|
||||||
int if_version;
|
|
||||||
struct drm_set_version __user *argp = (void __user *)data;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (copy_from_user(&sv, argp, sizeof(sv)))
|
if (sv->drm_di_major != -1) {
|
||||||
return -EFAULT;
|
if (sv->drm_di_major != DRM_IF_MAJOR ||
|
||||||
|
sv->drm_di_minor < 0 || sv->drm_di_minor > DRM_IF_MINOR) {
|
||||||
retv.drm_di_major = DRM_IF_MAJOR;
|
retcode = -EINVAL;
|
||||||
retv.drm_di_minor = DRM_IF_MINOR;
|
goto done;
|
||||||
retv.drm_dd_major = dev->driver->major;
|
}
|
||||||
retv.drm_dd_minor = dev->driver->minor;
|
if_version = DRM_IF_VERSION(sv->drm_di_major,
|
||||||
|
sv->drm_di_minor);
|
||||||
if (copy_to_user(argp, &retv, sizeof(retv)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
if (sv.drm_di_major != -1) {
|
|
||||||
if (sv.drm_di_major != DRM_IF_MAJOR ||
|
|
||||||
sv.drm_di_minor < 0 || sv.drm_di_minor > DRM_IF_MINOR)
|
|
||||||
return -EINVAL;
|
|
||||||
if_version = DRM_IF_VERSION(sv.drm_di_major, sv.drm_di_minor);
|
|
||||||
dev->if_version = max(if_version, dev->if_version);
|
dev->if_version = max(if_version, dev->if_version);
|
||||||
if (sv.drm_di_minor >= 1) {
|
if (sv->drm_di_minor >= 1) {
|
||||||
/*
|
/*
|
||||||
* Version 1.1 includes tying of DRM to specific device
|
* Version 1.1 includes tying of DRM to specific device
|
||||||
*/
|
*/
|
||||||
ret = drm_set_busid(dev);
|
drm_set_busid(dev);
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sv.drm_dd_major != -1) {
|
if (sv->drm_dd_major != -1) {
|
||||||
if (sv.drm_dd_major != dev->driver->major ||
|
if (sv->drm_dd_major != dev->driver->major ||
|
||||||
sv.drm_dd_minor < 0
|
sv->drm_dd_minor < 0 || sv->drm_dd_minor >
|
||||||
|| sv.drm_dd_minor > dev->driver->minor)
|
dev->driver->minor) {
|
||||||
return -EINVAL;
|
retcode = -EINVAL;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
if (dev->driver->set_version)
|
if (dev->driver->set_version)
|
||||||
dev->driver->set_version(dev, &sv);
|
dev->driver->set_version(dev, sv);
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
|
done:
|
||||||
|
sv->drm_di_major = DRM_IF_MAJOR;
|
||||||
|
sv->drm_di_minor = DRM_IF_MINOR;
|
||||||
|
sv->drm_dd_major = dev->driver->major;
|
||||||
|
sv->drm_dd_minor = dev->driver->minor;
|
||||||
|
|
||||||
|
return retcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** No-op ioctl. */
|
/** No-op ioctl. */
|
||||||
int drm_noop(struct inode *inode, struct drm_file *file_priv, unsigned int cmd,
|
int drm_noop(struct drm_device *dev, void *data,
|
||||||
unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEBUG("\n");
|
DRM_DEBUG("\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -50,29 +50,24 @@
|
||||||
* This IOCTL is deprecated, and will now return EINVAL for any busid not equal
|
* This IOCTL is deprecated, and will now return EINVAL for any busid not equal
|
||||||
* to that of the device that this DRM instance attached to.
|
* to that of the device that this DRM instance attached to.
|
||||||
*/
|
*/
|
||||||
int drm_irq_by_busid(struct inode *inode, struct drm_file *file_priv,
|
int drm_irq_by_busid(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_irq_busid *p = data;
|
||||||
struct drm_irq_busid __user *argp = (void __user *)arg;
|
|
||||||
struct drm_irq_busid p;
|
|
||||||
|
|
||||||
if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
|
if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (copy_from_user(&p, argp, sizeof(p)))
|
if ((p->busnum >> 8) != drm_get_pci_domain(dev) ||
|
||||||
return -EFAULT;
|
(p->busnum & 0xff) != dev->pdev->bus->number ||
|
||||||
|
p->devnum != PCI_SLOT(dev->pdev->devfn) || p->funcnum != PCI_FUNC(dev->pdev->devfn))
|
||||||
if ((p.busnum >> 8) != drm_get_pci_domain(dev) ||
|
|
||||||
(p.busnum & 0xff) != dev->pdev->bus->number ||
|
|
||||||
p.devnum != PCI_SLOT(dev->pdev->devfn) || p.funcnum != PCI_FUNC(dev->pdev->devfn))
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
p.irq = dev->irq;
|
p->irq = dev->irq;
|
||||||
|
|
||||||
|
DRM_DEBUG("%d:%d:%d => IRQ %d\n", p->busnum, p->devnum, p->funcnum,
|
||||||
|
p->irq);
|
||||||
|
|
||||||
DRM_DEBUG("%d:%d:%d => IRQ %d\n", p.busnum, p.devnum, p.funcnum, p.irq);
|
|
||||||
if (copy_to_user(argp, &p, sizeof(p)))
|
|
||||||
return -EFAULT;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,23 +188,20 @@ EXPORT_SYMBOL(drm_irq_uninstall);
|
||||||
*
|
*
|
||||||
* Calls irq_install() or irq_uninstall() according to \p arg.
|
* Calls irq_install() or irq_uninstall() according to \p arg.
|
||||||
*/
|
*/
|
||||||
int drm_control(struct inode *inode, struct drm_file *file_priv,
|
int drm_control(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_control *ctl = data;
|
||||||
struct drm_control ctl;
|
|
||||||
|
|
||||||
/* if we haven't irq we fallback for compatibility reasons - this used to be a separate function in drm_dma.h */
|
/* if we haven't irq we fallback for compatibility reasons - this used to be a separate function in drm_dma.h */
|
||||||
|
|
||||||
if (copy_from_user(&ctl, (struct drm_control __user *) arg, sizeof(ctl)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
switch (ctl.func) {
|
switch (ctl->func) {
|
||||||
case DRM_INST_HANDLER:
|
case DRM_INST_HANDLER:
|
||||||
if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
|
if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
|
||||||
return 0;
|
return 0;
|
||||||
if (dev->if_version < DRM_IF_VERSION(1, 2) &&
|
if (dev->if_version < DRM_IF_VERSION(1, 2) &&
|
||||||
ctl.irq != dev->irq)
|
ctl->irq != dev->irq)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
return drm_irq_install(dev);
|
return drm_irq_install(dev);
|
||||||
case DRM_UNINST_HANDLER:
|
case DRM_UNINST_HANDLER:
|
||||||
|
@ -240,30 +232,25 @@ int drm_control(struct inode *inode, struct drm_file *file_priv,
|
||||||
*
|
*
|
||||||
* If a signal is not requested, then calls vblank_wait().
|
* If a signal is not requested, then calls vblank_wait().
|
||||||
*/
|
*/
|
||||||
int drm_wait_vblank(DRM_IOCTL_ARGS)
|
int drm_wait_vblank(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
union drm_wait_vblank *vblwait = data;
|
||||||
union drm_wait_vblank __user *argp = (void __user *)data;
|
|
||||||
union drm_wait_vblank vblwait;
|
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
unsigned int flags, seq;
|
unsigned int flags, seq;
|
||||||
|
|
||||||
if (!dev->irq)
|
if ((!dev->irq) || (!dev->irq_enabled))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (copy_from_user(&vblwait, argp, sizeof(vblwait)))
|
if (vblwait->request.type &
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
if (vblwait.request.type &
|
|
||||||
~(_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK)) {
|
~(_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK)) {
|
||||||
DRM_ERROR("Unsupported type value 0x%x, supported mask 0x%x\n",
|
DRM_ERROR("Unsupported type value 0x%x, supported mask 0x%x\n",
|
||||||
vblwait.request.type,
|
vblwait->request.type,
|
||||||
(_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK));
|
(_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK));
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
flags = vblwait.request.type & _DRM_VBLANK_FLAGS_MASK;
|
flags = vblwait->request.type & _DRM_VBLANK_FLAGS_MASK;
|
||||||
|
|
||||||
if (!drm_core_check_feature(dev, (flags & _DRM_VBLANK_SECONDARY) ?
|
if (!drm_core_check_feature(dev, (flags & _DRM_VBLANK_SECONDARY) ?
|
||||||
DRIVER_IRQ_VBL2 : DRIVER_IRQ_VBL))
|
DRIVER_IRQ_VBL2 : DRIVER_IRQ_VBL))
|
||||||
|
@ -272,10 +259,10 @@ int drm_wait_vblank(DRM_IOCTL_ARGS)
|
||||||
seq = atomic_read((flags & _DRM_VBLANK_SECONDARY) ? &dev->vbl_received2
|
seq = atomic_read((flags & _DRM_VBLANK_SECONDARY) ? &dev->vbl_received2
|
||||||
: &dev->vbl_received);
|
: &dev->vbl_received);
|
||||||
|
|
||||||
switch (vblwait.request.type & _DRM_VBLANK_TYPES_MASK) {
|
switch (vblwait->request.type & _DRM_VBLANK_TYPES_MASK) {
|
||||||
case _DRM_VBLANK_RELATIVE:
|
case _DRM_VBLANK_RELATIVE:
|
||||||
vblwait.request.sequence += seq;
|
vblwait->request.sequence += seq;
|
||||||
vblwait.request.type &= ~_DRM_VBLANK_RELATIVE;
|
vblwait->request.type &= ~_DRM_VBLANK_RELATIVE;
|
||||||
case _DRM_VBLANK_ABSOLUTE:
|
case _DRM_VBLANK_ABSOLUTE:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -283,8 +270,8 @@ int drm_wait_vblank(DRM_IOCTL_ARGS)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & _DRM_VBLANK_NEXTONMISS) &&
|
if ((flags & _DRM_VBLANK_NEXTONMISS) &&
|
||||||
(seq - vblwait.request.sequence) <= (1<<23)) {
|
(seq - vblwait->request.sequence) <= (1<<23)) {
|
||||||
vblwait.request.sequence = seq + 1;
|
vblwait->request.sequence = seq + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & _DRM_VBLANK_SIGNAL) {
|
if (flags & _DRM_VBLANK_SIGNAL) {
|
||||||
|
@ -300,12 +287,13 @@ int drm_wait_vblank(DRM_IOCTL_ARGS)
|
||||||
* that case
|
* that case
|
||||||
*/
|
*/
|
||||||
list_for_each_entry(vbl_sig, vbl_sigs, head) {
|
list_for_each_entry(vbl_sig, vbl_sigs, head) {
|
||||||
if (vbl_sig->sequence == vblwait.request.sequence
|
if (vbl_sig->sequence == vblwait->request.sequence
|
||||||
&& vbl_sig->info.si_signo == vblwait.request.signal
|
&& vbl_sig->info.si_signo ==
|
||||||
|
vblwait->request.signal
|
||||||
&& vbl_sig->task == current) {
|
&& vbl_sig->task == current) {
|
||||||
spin_unlock_irqrestore(&dev->vbl_lock,
|
spin_unlock_irqrestore(&dev->vbl_lock,
|
||||||
irqflags);
|
irqflags);
|
||||||
vblwait.reply.sequence = seq;
|
vblwait->reply.sequence = seq;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -327,8 +315,8 @@ int drm_wait_vblank(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
memset((void *)vbl_sig, 0, sizeof(*vbl_sig));
|
memset((void *)vbl_sig, 0, sizeof(*vbl_sig));
|
||||||
|
|
||||||
vbl_sig->sequence = vblwait.request.sequence;
|
vbl_sig->sequence = vblwait->request.sequence;
|
||||||
vbl_sig->info.si_signo = vblwait.request.signal;
|
vbl_sig->info.si_signo = vblwait->request.signal;
|
||||||
vbl_sig->task = current;
|
vbl_sig->task = current;
|
||||||
|
|
||||||
spin_lock_irqsave(&dev->vbl_lock, irqflags);
|
spin_lock_irqsave(&dev->vbl_lock, irqflags);
|
||||||
|
@ -337,25 +325,22 @@ int drm_wait_vblank(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
|
spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
|
||||||
|
|
||||||
vblwait.reply.sequence = seq;
|
vblwait->reply.sequence = seq;
|
||||||
} else {
|
} else {
|
||||||
if (flags & _DRM_VBLANK_SECONDARY) {
|
if (flags & _DRM_VBLANK_SECONDARY) {
|
||||||
if (dev->driver->vblank_wait2)
|
if (dev->driver->vblank_wait2)
|
||||||
ret = dev->driver->vblank_wait2(dev, &vblwait.request.sequence);
|
ret = dev->driver->vblank_wait2(dev, &vblwait->request.sequence);
|
||||||
} else if (dev->driver->vblank_wait)
|
} else if (dev->driver->vblank_wait)
|
||||||
ret =
|
ret =
|
||||||
dev->driver->vblank_wait(dev,
|
dev->driver->vblank_wait(dev,
|
||||||
&vblwait.request.sequence);
|
&vblwait->request.sequence);
|
||||||
|
|
||||||
do_gettimeofday(&now);
|
do_gettimeofday(&now);
|
||||||
vblwait.reply.tval_sec = now.tv_sec;
|
vblwait->reply.tval_sec = now.tv_sec;
|
||||||
vblwait.reply.tval_usec = now.tv_usec;
|
vblwait->reply.tval_usec = now.tv_usec;
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (copy_to_user(argp, &vblwait, sizeof(vblwait)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,31 +48,26 @@ static int drm_notifier(void *priv);
|
||||||
*
|
*
|
||||||
* Add the current task to the lock wait queue, and attempt to take to lock.
|
* Add the current task to the lock wait queue, and attempt to take to lock.
|
||||||
*/
|
*/
|
||||||
int drm_lock(struct inode *inode, struct drm_file *file_priv,
|
int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
unsigned int cmd, unsigned long arg)
|
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
DECLARE_WAITQUEUE(entry, current);
|
DECLARE_WAITQUEUE(entry, current);
|
||||||
struct drm_lock lock;
|
struct drm_lock *lock = data;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
++file_priv->lock_count;
|
++file_priv->lock_count;
|
||||||
|
|
||||||
if (copy_from_user(&lock, (struct drm_lock __user *) arg, sizeof(lock)))
|
if (lock->context == DRM_KERNEL_CONTEXT) {
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
if (lock.context == DRM_KERNEL_CONTEXT) {
|
|
||||||
DRM_ERROR("Process %d using kernel context %d\n",
|
DRM_ERROR("Process %d using kernel context %d\n",
|
||||||
current->pid, lock.context);
|
current->pid, lock->context);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n",
|
DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n",
|
||||||
lock.context, current->pid,
|
lock->context, current->pid,
|
||||||
dev->lock.hw_lock->lock, lock.flags);
|
dev->lock.hw_lock->lock, lock->flags);
|
||||||
|
|
||||||
if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE))
|
if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE))
|
||||||
if (lock.context < 0)
|
if (lock->context < 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
add_wait_queue(&dev->lock.lock_queue, &entry);
|
add_wait_queue(&dev->lock.lock_queue, &entry);
|
||||||
|
@ -86,7 +81,7 @@ int drm_lock(struct inode *inode, struct drm_file *file_priv,
|
||||||
ret = -EINTR;
|
ret = -EINTR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (drm_lock_take(&dev->lock, lock.context)) {
|
if (drm_lock_take(&dev->lock, lock->context)) {
|
||||||
dev->lock.file_priv = file_priv;
|
dev->lock.file_priv = file_priv;
|
||||||
dev->lock.lock_time = jiffies;
|
dev->lock.lock_time = jiffies;
|
||||||
atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
|
atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
|
||||||
|
@ -106,7 +101,8 @@ int drm_lock(struct inode *inode, struct drm_file *file_priv,
|
||||||
__set_current_state(TASK_RUNNING);
|
__set_current_state(TASK_RUNNING);
|
||||||
remove_wait_queue(&dev->lock.lock_queue, &entry);
|
remove_wait_queue(&dev->lock.lock_queue, &entry);
|
||||||
|
|
||||||
DRM_DEBUG( "%d %s\n", lock.context, ret ? "interrupted" : "has lock" );
|
DRM_DEBUG("%d %s\n", lock->context,
|
||||||
|
ret ? "interrupted" : "has lock");
|
||||||
if (ret) return ret;
|
if (ret) return ret;
|
||||||
|
|
||||||
sigemptyset(&dev->sigmask);
|
sigemptyset(&dev->sigmask);
|
||||||
|
@ -114,24 +110,26 @@ int drm_lock(struct inode *inode, struct drm_file *file_priv,
|
||||||
sigaddset(&dev->sigmask, SIGTSTP);
|
sigaddset(&dev->sigmask, SIGTSTP);
|
||||||
sigaddset(&dev->sigmask, SIGTTIN);
|
sigaddset(&dev->sigmask, SIGTTIN);
|
||||||
sigaddset(&dev->sigmask, SIGTTOU);
|
sigaddset(&dev->sigmask, SIGTTOU);
|
||||||
dev->sigdata.context = lock.context;
|
dev->sigdata.context = lock->context;
|
||||||
dev->sigdata.lock = dev->lock.hw_lock;
|
dev->sigdata.lock = dev->lock.hw_lock;
|
||||||
block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask);
|
block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask);
|
||||||
|
|
||||||
if (dev->driver->dma_ready && (lock.flags & _DRM_LOCK_READY))
|
if (dev->driver->dma_ready && (lock->flags & _DRM_LOCK_READY))
|
||||||
dev->driver->dma_ready(dev);
|
dev->driver->dma_ready(dev);
|
||||||
|
|
||||||
if (dev->driver->dma_quiescent && (lock.flags & _DRM_LOCK_QUIESCENT)) {
|
if (dev->driver->dma_quiescent && (lock->flags & _DRM_LOCK_QUIESCENT))
|
||||||
|
{
|
||||||
if (dev->driver->dma_quiescent(dev)) {
|
if (dev->driver->dma_quiescent(dev)) {
|
||||||
DRM_DEBUG("%d waiting for DMA quiescent\n", lock.context);
|
DRM_DEBUG("%d waiting for DMA quiescent\n",
|
||||||
|
lock->context);
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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,
|
||||||
lock.context);
|
lock->context);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -148,19 +146,14 @@ int drm_lock(struct inode *inode, struct drm_file *file_priv,
|
||||||
*
|
*
|
||||||
* Transfer and free the lock.
|
* Transfer and free the lock.
|
||||||
*/
|
*/
|
||||||
int drm_unlock(struct inode *inode, struct drm_file *file_priv,
|
int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
unsigned int cmd, unsigned long arg)
|
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_lock *lock = data;
|
||||||
struct drm_lock lock;
|
|
||||||
unsigned long irqflags;
|
unsigned long irqflags;
|
||||||
|
|
||||||
if (copy_from_user(&lock, (struct drm_lock __user *) arg, sizeof(lock)))
|
if (lock->context == DRM_KERNEL_CONTEXT) {
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
if (lock.context == DRM_KERNEL_CONTEXT) {
|
|
||||||
DRM_ERROR("Process %d using kernel context %d\n",
|
DRM_ERROR("Process %d using kernel context %d\n",
|
||||||
current->pid, lock.context);
|
current->pid, lock->context);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +175,7 @@ int drm_unlock(struct inode *inode, struct drm_file *file_priv,
|
||||||
if (dev->driver->kernel_context_switch_unlock)
|
if (dev->driver->kernel_context_switch_unlock)
|
||||||
dev->driver->kernel_context_switch_unlock(dev);
|
dev->driver->kernel_context_switch_unlock(dev);
|
||||||
else {
|
else {
|
||||||
if (drm_lock_free(&dev->lock,lock.context)) {
|
if (drm_lock_free(&dev->lock,lock->context)) {
|
||||||
/* FIXME: Should really bail out here. */
|
/* FIXME: Should really bail out here. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -388,10 +381,8 @@ void drm_idlelock_release(struct drm_lock_data *lock_data)
|
||||||
EXPORT_SYMBOL(drm_idlelock_release);
|
EXPORT_SYMBOL(drm_idlelock_release);
|
||||||
|
|
||||||
|
|
||||||
int drm_i_have_hw_lock(struct drm_file *file_priv)
|
int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
|
|
||||||
return (file_priv->lock_count && dev->lock.hw_lock &&
|
return (file_priv->lock_count && dev->lock.hw_lock &&
|
||||||
_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) &&
|
_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) &&
|
||||||
dev->lock.file_priv == file_priv);
|
dev->lock.file_priv == file_priv);
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
#include <linux/interrupt.h> /* For task queue support */
|
#include <linux/interrupt.h> /* For task queue support */
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
|
|
||||||
/** Ioctl arguments */
|
|
||||||
#define DRM_IOCTL_ARGS struct inode *inode, struct drm_file *file_priv, unsigned int cmd, unsigned long data
|
|
||||||
/** 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_SUSER(p) capable(CAP_SYS_ADMIN)
|
||||||
|
@ -30,8 +28,6 @@
|
||||||
#define DRM_WRITEMEMORYBARRIER() wmb()
|
#define DRM_WRITEMEMORYBARRIER() wmb()
|
||||||
/** Read/write memory barrier */
|
/** Read/write memory barrier */
|
||||||
#define DRM_MEMORYBARRIER() mb()
|
#define DRM_MEMORYBARRIER() mb()
|
||||||
/** DRM device local declaration */
|
|
||||||
#define DRM_DEVICE struct drm_device *dev = file_priv->head->dev
|
|
||||||
|
|
||||||
/** IRQ handler arguments and return type and values */
|
/** IRQ handler arguments and return type and values */
|
||||||
#define DRM_IRQ_ARGS int irq, void *arg
|
#define DRM_IRQ_ARGS int irq, void *arg
|
||||||
|
|
|
@ -62,12 +62,8 @@ void drm_sg_cleanup(struct drm_sg_mem * entry)
|
||||||
# define ScatterHandle(x) (unsigned int)(x)
|
# define ScatterHandle(x) (unsigned int)(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int drm_sg_alloc(struct inode *inode, struct drm_file *file_priv,
|
int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request)
|
||||||
unsigned int cmd, unsigned long arg)
|
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
struct drm_scatter_gather __user *argp = (void __user *)arg;
|
|
||||||
struct drm_scatter_gather request;
|
|
||||||
struct drm_sg_mem *entry;
|
struct drm_sg_mem *entry;
|
||||||
unsigned long pages, i, j;
|
unsigned long pages, i, j;
|
||||||
|
|
||||||
|
@ -79,17 +75,13 @@ int drm_sg_alloc(struct inode *inode, struct drm_file *file_priv,
|
||||||
if (dev->sg)
|
if (dev->sg)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (copy_from_user(&request, argp, sizeof(request)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
entry = drm_alloc(sizeof(*entry), DRM_MEM_SGLISTS);
|
entry = drm_alloc(sizeof(*entry), DRM_MEM_SGLISTS);
|
||||||
if (!entry)
|
if (!entry)
|
||||||
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;
|
DRM_DEBUG("sg size=%ld pages=%ld\n", request->size, pages);
|
||||||
DRM_DEBUG("sg size=%ld pages=%ld\n", request.size, pages);
|
|
||||||
|
|
||||||
entry->pages = pages;
|
entry->pages = pages;
|
||||||
entry->pagelist = drm_alloc(pages * sizeof(*entry->pagelist),
|
entry->pagelist = drm_alloc(pages * sizeof(*entry->pagelist),
|
||||||
|
@ -141,12 +133,7 @@ int drm_sg_alloc(struct inode *inode, struct drm_file *file_priv,
|
||||||
SetPageReserved(entry->pagelist[j]);
|
SetPageReserved(entry->pagelist[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
request.handle = entry->handle;
|
request->handle = entry->handle;
|
||||||
|
|
||||||
if (copy_to_user(argp, &request, sizeof(request))) {
|
|
||||||
drm_sg_cleanup(entry);
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev->sg = entry;
|
dev->sg = entry;
|
||||||
|
|
||||||
|
@ -196,26 +183,31 @@ int drm_sg_alloc(struct inode *inode, struct drm_file *file_priv,
|
||||||
drm_sg_cleanup(entry);
|
drm_sg_cleanup(entry);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL(drm_sg_alloc);
|
||||||
|
|
||||||
int drm_sg_free(struct inode *inode, struct drm_file *file_priv,
|
|
||||||
unsigned int cmd, unsigned long arg)
|
int drm_sg_alloc_ioctl(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
struct drm_scatter_gather *request = data;
|
||||||
struct drm_scatter_gather request;
|
|
||||||
|
return drm_sg_alloc(dev, request);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int drm_sg_free(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
|
{
|
||||||
|
struct drm_scatter_gather *request = data;
|
||||||
struct drm_sg_mem *entry;
|
struct drm_sg_mem *entry;
|
||||||
|
|
||||||
if (!drm_core_check_feature(dev, DRIVER_SG))
|
if (!drm_core_check_feature(dev, DRIVER_SG))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (copy_from_user(&request,
|
|
||||||
(struct drm_scatter_gather __user *) arg,
|
|
||||||
sizeof(request)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
entry = dev->sg;
|
entry = dev->sg;
|
||||||
dev->sg = NULL;
|
dev->sg = NULL;
|
||||||
|
|
||||||
if (!entry || entry->handle != request.handle)
|
if (!entry || entry->handle != request->handle)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
DRM_DEBUG("sg free virtual = %p\n", entry->virtual);
|
DRM_DEBUG("sg free virtual = %p\n", entry->virtual);
|
||||||
|
|
|
@ -429,98 +429,29 @@ static int i810_dma_initialize(struct drm_device * dev,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* i810 DRM version 1.1 used a smaller init structure with different
|
static int i810_dma_init(struct drm_device *dev, void *data,
|
||||||
* ordering of values than is currently used (drm >= 1.2). There is
|
struct drm_file *file_priv)
|
||||||
* no defined way to detect the XFree version to correct this problem,
|
|
||||||
* however by checking using this procedure we can detect the correct
|
|
||||||
* thing to do.
|
|
||||||
*
|
|
||||||
* #1 Read the Smaller init structure from user-space
|
|
||||||
* #2 Verify the overlay_physical is a valid physical address, or NULL
|
|
||||||
* If it isn't then we have a v1.1 client. Fix up params.
|
|
||||||
* If it is, then we have a 1.2 client... get the rest of the data.
|
|
||||||
*/
|
|
||||||
static int i810_dma_init_compat(drm_i810_init_t * init, unsigned long arg)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Get v1.1 init data */
|
|
||||||
if (copy_from_user(init, (drm_i810_pre12_init_t __user *) arg,
|
|
||||||
sizeof(drm_i810_pre12_init_t))) {
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((!init->overlay_physical) || (init->overlay_physical > 4096)) {
|
|
||||||
|
|
||||||
/* This is a v1.2 client, just get the v1.2 init data */
|
|
||||||
DRM_INFO("Using POST v1.2 init.\n");
|
|
||||||
if (copy_from_user(init, (drm_i810_init_t __user *) arg,
|
|
||||||
sizeof(drm_i810_init_t))) {
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* This is a v1.1 client, fix the params */
|
|
||||||
DRM_INFO("Using PRE v1.2 init.\n");
|
|
||||||
init->pitch_bits = init->h;
|
|
||||||
init->pitch = init->w;
|
|
||||||
init->h = init->overlay_physical;
|
|
||||||
init->w = init->overlay_offset;
|
|
||||||
init->overlay_physical = 0;
|
|
||||||
init->overlay_offset = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int i810_dma_init(struct inode *inode, struct drm_file *file_priv,
|
|
||||||
unsigned int cmd, unsigned long arg)
|
|
||||||
{
|
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
drm_i810_private_t *dev_priv;
|
drm_i810_private_t *dev_priv;
|
||||||
drm_i810_init_t init;
|
drm_i810_init_t *init = data;
|
||||||
int retcode = 0;
|
int retcode = 0;
|
||||||
|
|
||||||
/* Get only the init func */
|
switch (init->func) {
|
||||||
if (copy_from_user
|
|
||||||
(&init, (void __user *)arg, sizeof(drm_i810_init_func_t)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
switch (init.func) {
|
|
||||||
case I810_INIT_DMA:
|
|
||||||
/* This case is for backward compatibility. It
|
|
||||||
* handles XFree 4.1.0 and 4.2.0, and has to
|
|
||||||
* do some parameter checking as described below.
|
|
||||||
* It will someday go away.
|
|
||||||
*/
|
|
||||||
retcode = i810_dma_init_compat(&init, arg);
|
|
||||||
if (retcode)
|
|
||||||
return retcode;
|
|
||||||
|
|
||||||
dev_priv = drm_alloc(sizeof(drm_i810_private_t),
|
|
||||||
DRM_MEM_DRIVER);
|
|
||||||
if (dev_priv == NULL)
|
|
||||||
return -ENOMEM;
|
|
||||||
retcode = i810_dma_initialize(dev, dev_priv, &init);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
case I810_INIT_DMA_1_4:
|
case I810_INIT_DMA_1_4:
|
||||||
DRM_INFO("Using v1.4 init.\n");
|
DRM_INFO("Using v1.4 init.\n");
|
||||||
if (copy_from_user(&init, (drm_i810_init_t __user *) arg,
|
|
||||||
sizeof(drm_i810_init_t))) {
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
dev_priv = drm_alloc(sizeof(drm_i810_private_t),
|
dev_priv = drm_alloc(sizeof(drm_i810_private_t),
|
||||||
DRM_MEM_DRIVER);
|
DRM_MEM_DRIVER);
|
||||||
if (dev_priv == NULL)
|
if (dev_priv == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
retcode = i810_dma_initialize(dev, dev_priv, &init);
|
retcode = i810_dma_initialize(dev, dev_priv, init);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case I810_CLEANUP_DMA:
|
case I810_CLEANUP_DMA:
|
||||||
DRM_INFO("DMA Cleanup\n");
|
DRM_INFO("DMA Cleanup\n");
|
||||||
retcode = i810_dma_cleanup(dev);
|
retcode = i810_dma_cleanup(dev);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return retcode;
|
return retcode;
|
||||||
|
@ -997,45 +928,38 @@ static void i810_reclaim_buffers(struct drm_device * dev,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i810_flush_ioctl(struct inode *inode, struct drm_file *file_priv,
|
static int i810_flush_ioctl(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
i810_flush_queue(dev);
|
i810_flush_queue(dev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i810_dma_vertex(struct inode *inode, struct drm_file *file_priv,
|
static int i810_dma_vertex(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
|
drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
|
||||||
u32 *hw_status = dev_priv->hw_status_page;
|
u32 *hw_status = dev_priv->hw_status_page;
|
||||||
drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
|
drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
|
||||||
dev_priv->sarea_priv;
|
dev_priv->sarea_priv;
|
||||||
drm_i810_vertex_t vertex;
|
drm_i810_vertex_t *vertex = data;
|
||||||
|
|
||||||
if (copy_from_user
|
|
||||||
(&vertex, (drm_i810_vertex_t __user *) arg, sizeof(vertex)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_DEBUG("i810 dma vertex, idx %d used %d discard %d\n",
|
DRM_DEBUG("i810 dma vertex, idx %d used %d discard %d\n",
|
||||||
vertex.idx, vertex.used, vertex.discard);
|
vertex->idx, vertex->used, vertex->discard);
|
||||||
|
|
||||||
if (vertex.idx < 0 || vertex.idx > dma->buf_count)
|
if (vertex->idx < 0 || vertex->idx > dma->buf_count)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
i810_dma_dispatch_vertex(dev,
|
i810_dma_dispatch_vertex(dev,
|
||||||
dma->buflist[vertex.idx],
|
dma->buflist[vertex->idx],
|
||||||
vertex.discard, vertex.used);
|
vertex->discard, vertex->used);
|
||||||
|
|
||||||
atomic_add(vertex.used, &dev->counts[_DRM_STAT_SECONDARY]);
|
atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
|
||||||
atomic_inc(&dev->counts[_DRM_STAT_DMA]);
|
atomic_inc(&dev->counts[_DRM_STAT_DMA]);
|
||||||
sarea_priv->last_enqueue = dev_priv->counter - 1;
|
sarea_priv->last_enqueue = dev_priv->counter - 1;
|
||||||
sarea_priv->last_dispatch = (int)hw_status[5];
|
sarea_priv->last_dispatch = (int)hw_status[5];
|
||||||
|
@ -1043,15 +967,10 @@ static int i810_dma_vertex(struct inode *inode, struct drm_file *file_priv,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i810_clear_bufs(struct inode *inode, struct drm_file *file_priv,
|
static int i810_clear_bufs(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
drm_i810_clear_t *clear = data;
|
||||||
drm_i810_clear_t clear;
|
|
||||||
|
|
||||||
if (copy_from_user
|
|
||||||
(&clear, (drm_i810_clear_t __user *) arg, sizeof(clear)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
|
@ -1060,16 +979,14 @@ static int i810_clear_bufs(struct inode *inode, struct drm_file *file_priv,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
i810_dma_dispatch_clear(dev, clear.flags,
|
i810_dma_dispatch_clear(dev, clear->flags,
|
||||||
clear.clear_color, clear.clear_depth);
|
clear->clear_color, clear->clear_depth);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i810_swap_bufs(struct inode *inode, struct drm_file *file_priv,
|
static int i810_swap_bufs(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
|
|
||||||
DRM_DEBUG("i810_swap_bufs\n");
|
DRM_DEBUG("i810_swap_bufs\n");
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
@ -1078,11 +995,9 @@ static int i810_swap_bufs(struct inode *inode, struct drm_file *file_priv,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i810_getage(struct inode *inode, struct drm_file *file_priv,
|
static int i810_getage(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd,
|
struct drm_file *file_priv)
|
||||||
unsigned long arg)
|
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
|
drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
|
||||||
u32 *hw_status = dev_priv->hw_status_page;
|
u32 *hw_status = dev_priv->hw_status_page;
|
||||||
drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
|
drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
|
||||||
|
@ -1092,45 +1007,39 @@ static int i810_getage(struct inode *inode, struct drm_file *file_priv,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i810_getbuf(struct inode *inode, struct drm_file *file_priv,
|
static int i810_getbuf(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
int retcode = 0;
|
int retcode = 0;
|
||||||
drm_i810_dma_t d;
|
drm_i810_dma_t *d = data;
|
||||||
drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
|
drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
|
||||||
u32 *hw_status = dev_priv->hw_status_page;
|
u32 *hw_status = dev_priv->hw_status_page;
|
||||||
drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
|
drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
|
||||||
dev_priv->sarea_priv;
|
dev_priv->sarea_priv;
|
||||||
|
|
||||||
if (copy_from_user(&d, (drm_i810_dma_t __user *) arg, sizeof(d)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
d.granted = 0;
|
d->granted = 0;
|
||||||
|
|
||||||
retcode = i810_dma_get_buffer(dev, &d, file_priv);
|
retcode = i810_dma_get_buffer(dev, d, file_priv);
|
||||||
|
|
||||||
DRM_DEBUG("i810_dma: %d returning %d, granted = %d\n",
|
DRM_DEBUG("i810_dma: %d returning %d, granted = %d\n",
|
||||||
current->pid, retcode, d.granted);
|
current->pid, retcode, d->granted);
|
||||||
|
|
||||||
if (copy_to_user((void __user *) arg, &d, sizeof(d)))
|
|
||||||
return -EFAULT;
|
|
||||||
sarea_priv->last_dispatch = (int)hw_status[5];
|
sarea_priv->last_dispatch = (int)hw_status[5];
|
||||||
|
|
||||||
return retcode;
|
return retcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i810_copybuf(struct inode *inode, struct drm_file *file_priv,
|
static int i810_copybuf(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
/* Never copy - 2.4.x doesn't need it */
|
/* Never copy - 2.4.x doesn't need it */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i810_docopy(struct inode *inode, struct drm_file *file_priv,
|
static int i810_docopy(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
/* Never copy - 2.4.x doesn't need it */
|
/* Never copy - 2.4.x doesn't need it */
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1196,29 +1105,25 @@ static void i810_dma_dispatch_mc(struct drm_device * dev, struct drm_buf * buf,
|
||||||
ADVANCE_LP_RING();
|
ADVANCE_LP_RING();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i810_dma_mc(struct inode *inode, struct drm_file *file_priv,
|
static int i810_dma_mc(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
|
drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
|
||||||
u32 *hw_status = dev_priv->hw_status_page;
|
u32 *hw_status = dev_priv->hw_status_page;
|
||||||
drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
|
drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
|
||||||
dev_priv->sarea_priv;
|
dev_priv->sarea_priv;
|
||||||
drm_i810_mc_t mc;
|
drm_i810_mc_t *mc = data;
|
||||||
|
|
||||||
if (copy_from_user(&mc, (drm_i810_mc_t __user *) arg, sizeof(mc)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
if (mc.idx >= dma->buf_count || mc.idx < 0)
|
if (mc->idx >= dma->buf_count || mc->idx < 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
i810_dma_dispatch_mc(dev, dma->buflist[mc.idx], mc.used,
|
i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
|
||||||
mc.last_render);
|
mc->last_render);
|
||||||
|
|
||||||
atomic_add(mc.used, &dev->counts[_DRM_STAT_SECONDARY]);
|
atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
|
||||||
atomic_inc(&dev->counts[_DRM_STAT_DMA]);
|
atomic_inc(&dev->counts[_DRM_STAT_DMA]);
|
||||||
sarea_priv->last_enqueue = dev_priv->counter - 1;
|
sarea_priv->last_enqueue = dev_priv->counter - 1;
|
||||||
sarea_priv->last_dispatch = (int)hw_status[5];
|
sarea_priv->last_dispatch = (int)hw_status[5];
|
||||||
|
@ -1226,45 +1131,38 @@ static int i810_dma_mc(struct inode *inode, struct drm_file *file_priv,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i810_rstatus(struct inode *inode, struct drm_file *file_priv,
|
static int i810_rstatus(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
|
drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
|
||||||
|
|
||||||
return (int)(((u32 *) (dev_priv->hw_status_page))[4]);
|
return (int)(((u32 *) (dev_priv->hw_status_page))[4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i810_ov0_info(struct inode *inode, struct drm_file *file_priv,
|
static int i810_ov0_info(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
|
drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
|
||||||
drm_i810_overlay_t data;
|
drm_i810_overlay_t *ov = data;
|
||||||
|
|
||||||
|
ov->offset = dev_priv->overlay_offset;
|
||||||
|
ov->physical = dev_priv->overlay_physical;
|
||||||
|
|
||||||
data.offset = dev_priv->overlay_offset;
|
|
||||||
data.physical = dev_priv->overlay_physical;
|
|
||||||
if (copy_to_user
|
|
||||||
((drm_i810_overlay_t __user *) arg, &data, sizeof(data)))
|
|
||||||
return -EFAULT;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i810_fstatus(struct inode *inode, struct drm_file *file_priv,
|
static int i810_fstatus(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
|
drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
return I810_READ(0x30008);
|
return I810_READ(0x30008);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i810_ov0_flip(struct inode *inode, struct drm_file *file_priv,
|
static int i810_ov0_flip(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
|
drm_i810_private_t *dev_priv = (drm_i810_private_t *) dev->dev_private;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
@ -1299,10 +1197,9 @@ static int i810_do_cleanup_pageflip(struct drm_device * dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i810_flip_bufs(struct inode *inode, struct drm_file *file_priv,
|
static int i810_flip_bufs(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
drm_i810_private_t *dev_priv = dev->dev_private;
|
drm_i810_private_t *dev_priv = dev->dev_private;
|
||||||
|
|
||||||
DRM_DEBUG("%s\n", __FUNCTION__);
|
DRM_DEBUG("%s\n", __FUNCTION__);
|
||||||
|
@ -1355,22 +1252,22 @@ int i810_driver_dma_quiescent(struct drm_device * dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
drm_ioctl_desc_t i810_ioctls[] = {
|
struct drm_ioctl_desc i810_ioctls[] = {
|
||||||
[DRM_IOCTL_NR(DRM_I810_INIT)] = {i810_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_I810_INIT, i810_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_I810_VERTEX)] = {i810_dma_vertex, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I810_VERTEX, i810_dma_vertex, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I810_CLEAR)] = {i810_clear_bufs, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I810_CLEAR, i810_clear_bufs, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I810_FLUSH)] = {i810_flush_ioctl, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I810_FLUSH, i810_flush_ioctl, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I810_GETAGE)] = {i810_getage, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I810_GETAGE, i810_getage, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I810_GETBUF)] = {i810_getbuf, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I810_GETBUF, i810_getbuf, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I810_SWAP)] = {i810_swap_bufs, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I810_SWAP, i810_swap_bufs, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I810_COPY)] = {i810_copybuf, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I810_COPY, i810_copybuf, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I810_DOCOPY)] = {i810_docopy, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I810_DOCOPY, i810_docopy, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I810_OV0INFO)] = {i810_ov0_info, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I810_OV0INFO, i810_ov0_info, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I810_FSTATUS)] = {i810_fstatus, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I810_FSTATUS, i810_fstatus, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I810_OV0FLIP)] = {i810_ov0_flip, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I810_OV0FLIP, i810_ov0_flip, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I810_MC)] = {i810_dma_mc, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_I810_MC, i810_dma_mc, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_I810_RSTATUS)] = {i810_rstatus, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I810_RSTATUS, i810_rstatus, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I810_FLIP)] = {i810_flip_bufs, DRM_AUTH}
|
DRM_IOCTL_DEF(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);
|
||||||
|
|
|
@ -126,7 +126,7 @@ extern void i810_driver_reclaim_buffers_locked(struct drm_device * dev,
|
||||||
struct drm_file *file_priv);
|
struct drm_file *file_priv);
|
||||||
extern int i810_driver_device_is_agp(struct drm_device * dev);
|
extern int i810_driver_device_is_agp(struct drm_device * dev);
|
||||||
|
|
||||||
extern drm_ioctl_desc_t i810_ioctls[];
|
extern struct drm_ioctl_desc i810_ioctls[];
|
||||||
extern int i810_max_ioctl;
|
extern int i810_max_ioctl;
|
||||||
|
|
||||||
#define I810_BASE(reg) ((unsigned long) \
|
#define I810_BASE(reg) ((unsigned long) \
|
||||||
|
|
|
@ -450,24 +450,20 @@ static int i830_dma_initialize(struct drm_device * dev,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i830_dma_init(struct inode *inode, struct drm_file *file_priv,
|
static int i830_dma_init(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
drm_i830_private_t *dev_priv;
|
drm_i830_private_t *dev_priv;
|
||||||
drm_i830_init_t init;
|
drm_i830_init_t *init = data;
|
||||||
int retcode = 0;
|
int retcode = 0;
|
||||||
|
|
||||||
if (copy_from_user(&init, (void *__user)arg, sizeof(init)))
|
switch (init->func) {
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
switch (init.func) {
|
|
||||||
case I830_INIT_DMA:
|
case I830_INIT_DMA:
|
||||||
dev_priv = drm_alloc(sizeof(drm_i830_private_t),
|
dev_priv = drm_alloc(sizeof(drm_i830_private_t),
|
||||||
DRM_MEM_DRIVER);
|
DRM_MEM_DRIVER);
|
||||||
if (dev_priv == NULL)
|
if (dev_priv == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
retcode = i830_dma_initialize(dev, dev_priv, &init);
|
retcode = i830_dma_initialize(dev, dev_priv, init);
|
||||||
break;
|
break;
|
||||||
case I830_CLEANUP_DMA:
|
case I830_CLEANUP_DMA:
|
||||||
retcode = i830_dma_cleanup(dev);
|
retcode = i830_dma_cleanup(dev);
|
||||||
|
@ -1276,43 +1272,36 @@ static void i830_reclaim_buffers(struct drm_device * dev, struct drm_file *file_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i830_flush_ioctl(struct inode *inode, struct drm_file *file_priv,
|
static int i830_flush_ioctl(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
i830_flush_queue(dev);
|
i830_flush_queue(dev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i830_dma_vertex(struct inode *inode, struct drm_file *file_priv,
|
static int i830_dma_vertex(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private;
|
drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private;
|
||||||
u32 *hw_status = dev_priv->hw_status_page;
|
u32 *hw_status = dev_priv->hw_status_page;
|
||||||
drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *)
|
drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *)
|
||||||
dev_priv->sarea_priv;
|
dev_priv->sarea_priv;
|
||||||
drm_i830_vertex_t vertex;
|
drm_i830_vertex_t *vertex = data;
|
||||||
|
|
||||||
if (copy_from_user
|
|
||||||
(&vertex, (drm_i830_vertex_t __user *) arg, sizeof(vertex)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_DEBUG("i830 dma vertex, idx %d used %d discard %d\n",
|
DRM_DEBUG("i830 dma vertex, idx %d used %d discard %d\n",
|
||||||
vertex.idx, vertex.used, vertex.discard);
|
vertex->idx, vertex->used, vertex->discard);
|
||||||
|
|
||||||
if (vertex.idx < 0 || vertex.idx > dma->buf_count)
|
if (vertex->idx < 0 || vertex->idx > dma->buf_count)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
i830_dma_dispatch_vertex(dev,
|
i830_dma_dispatch_vertex(dev,
|
||||||
dma->buflist[vertex.idx],
|
dma->buflist[vertex->idx],
|
||||||
vertex.discard, vertex.used);
|
vertex->discard, vertex->used);
|
||||||
|
|
||||||
sarea_priv->last_enqueue = dev_priv->counter - 1;
|
sarea_priv->last_enqueue = dev_priv->counter - 1;
|
||||||
sarea_priv->last_dispatch = (int)hw_status[5];
|
sarea_priv->last_dispatch = (int)hw_status[5];
|
||||||
|
@ -1320,15 +1309,10 @@ static int i830_dma_vertex(struct inode *inode, struct drm_file *file_priv,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i830_clear_bufs(struct inode *inode, struct drm_file *file_priv,
|
static int i830_clear_bufs(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
drm_i830_clear_t *clear = data;
|
||||||
drm_i830_clear_t clear;
|
|
||||||
|
|
||||||
if (copy_from_user
|
|
||||||
(&clear, (drm_i830_clear_t __user *) arg, sizeof(clear)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
|
@ -1337,17 +1321,15 @@ static int i830_clear_bufs(struct inode *inode, struct drm_file *file_priv,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
i830_dma_dispatch_clear(dev, clear.flags,
|
i830_dma_dispatch_clear(dev, clear->flags,
|
||||||
clear.clear_color,
|
clear->clear_color,
|
||||||
clear.clear_depth, clear.clear_depthmask);
|
clear->clear_depth, clear->clear_depthmask);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i830_swap_bufs(struct inode *inode, struct drm_file *file_priv,
|
static int i830_swap_bufs(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
|
|
||||||
DRM_DEBUG("i830_swap_bufs\n");
|
DRM_DEBUG("i830_swap_bufs\n");
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
@ -1380,10 +1362,9 @@ static int i830_do_cleanup_pageflip(struct drm_device * dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i830_flip_bufs(struct inode *inode, struct drm_file *file_priv,
|
static int i830_flip_bufs(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
drm_i830_private_t *dev_priv = dev->dev_private;
|
drm_i830_private_t *dev_priv = dev->dev_private;
|
||||||
|
|
||||||
DRM_DEBUG("%s\n", __FUNCTION__);
|
DRM_DEBUG("%s\n", __FUNCTION__);
|
||||||
|
@ -1397,10 +1378,9 @@ static int i830_flip_bufs(struct inode *inode, struct drm_file *file_priv,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i830_getage(struct inode *inode, struct drm_file *file_priv, unsigned int cmd,
|
static int i830_getage(struct drm_device *dev, void *data,
|
||||||
unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private;
|
drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private;
|
||||||
u32 *hw_status = dev_priv->hw_status_page;
|
u32 *hw_status = dev_priv->hw_status_page;
|
||||||
drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *)
|
drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *)
|
||||||
|
@ -1410,56 +1390,50 @@ static int i830_getage(struct inode *inode, struct drm_file *file_priv, unsigned
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i830_getbuf(struct inode *inode, struct drm_file *file_priv,
|
static int i830_getbuf(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
int retcode = 0;
|
int retcode = 0;
|
||||||
drm_i830_dma_t d;
|
drm_i830_dma_t *d = data;
|
||||||
drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private;
|
drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private;
|
||||||
u32 *hw_status = dev_priv->hw_status_page;
|
u32 *hw_status = dev_priv->hw_status_page;
|
||||||
drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *)
|
drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *)
|
||||||
dev_priv->sarea_priv;
|
dev_priv->sarea_priv;
|
||||||
|
|
||||||
DRM_DEBUG("getbuf\n");
|
DRM_DEBUG("getbuf\n");
|
||||||
if (copy_from_user(&d, (drm_i830_dma_t __user *) arg, sizeof(d)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
d.granted = 0;
|
d->granted = 0;
|
||||||
|
|
||||||
retcode = i830_dma_get_buffer(dev, &d, file_priv);
|
retcode = i830_dma_get_buffer(dev, d, file_priv);
|
||||||
|
|
||||||
DRM_DEBUG("i830_dma: %d returning %d, granted = %d\n",
|
DRM_DEBUG("i830_dma: %d returning %d, granted = %d\n",
|
||||||
current->pid, retcode, d.granted);
|
current->pid, retcode, d->granted);
|
||||||
|
|
||||||
if (copy_to_user((void __user *) arg, &d, sizeof(d)))
|
|
||||||
return -EFAULT;
|
|
||||||
sarea_priv->last_dispatch = (int)hw_status[5];
|
sarea_priv->last_dispatch = (int)hw_status[5];
|
||||||
|
|
||||||
return retcode;
|
return retcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i830_copybuf(struct inode *inode,
|
static int i830_copybuf(struct drm_device *dev, void *data,
|
||||||
struct drm_file *file_priv, unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
/* Never copy - 2.4.x doesn't need it */
|
/* Never copy - 2.4.x doesn't need it */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i830_docopy(struct inode *inode, struct drm_file *file_priv, unsigned int cmd,
|
static int i830_docopy(struct drm_device *dev, void *data,
|
||||||
unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i830_getparam(struct inode *inode, struct drm_file *file_priv,
|
static int i830_getparam(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
drm_i830_private_t *dev_priv = dev->dev_private;
|
drm_i830_private_t *dev_priv = dev->dev_private;
|
||||||
drm_i830_getparam_t param;
|
drm_i830_getparam_t *param = data;
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
if (!dev_priv) {
|
if (!dev_priv) {
|
||||||
|
@ -1467,11 +1441,7 @@ static int i830_getparam(struct inode *inode, struct drm_file *file_priv,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (copy_from_user
|
switch (param->param) {
|
||||||
(¶m, (drm_i830_getparam_t __user *) arg, sizeof(param)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
switch (param.param) {
|
|
||||||
case I830_PARAM_IRQ_ACTIVE:
|
case I830_PARAM_IRQ_ACTIVE:
|
||||||
value = dev->irq_enabled;
|
value = dev->irq_enabled;
|
||||||
break;
|
break;
|
||||||
|
@ -1479,7 +1449,7 @@ static int i830_getparam(struct inode *inode, struct drm_file *file_priv,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (copy_to_user(param.value, &value, sizeof(int))) {
|
if (copy_to_user(param->value, &value, sizeof(int))) {
|
||||||
DRM_ERROR("copy_to_user\n");
|
DRM_ERROR("copy_to_user\n");
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
@ -1487,25 +1457,20 @@ static int i830_getparam(struct inode *inode, struct drm_file *file_priv,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i830_setparam(struct inode *inode, struct drm_file *file_priv,
|
static int i830_setparam(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
drm_i830_private_t *dev_priv = dev->dev_private;
|
drm_i830_private_t *dev_priv = dev->dev_private;
|
||||||
drm_i830_setparam_t param;
|
drm_i830_setparam_t *param = data;
|
||||||
|
|
||||||
if (!dev_priv) {
|
if (!dev_priv) {
|
||||||
DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
|
DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (copy_from_user
|
switch (param->param) {
|
||||||
(¶m, (drm_i830_setparam_t __user *) arg, sizeof(param)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
switch (param.param) {
|
|
||||||
case I830_SETPARAM_USE_MI_BATCHBUFFER_START:
|
case I830_SETPARAM_USE_MI_BATCHBUFFER_START:
|
||||||
dev_priv->use_mi_batchbuffer_start = param.value;
|
dev_priv->use_mi_batchbuffer_start = param->value;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -1552,21 +1517,21 @@ int i830_driver_dma_quiescent(struct drm_device * dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
drm_ioctl_desc_t i830_ioctls[] = {
|
struct drm_ioctl_desc i830_ioctls[] = {
|
||||||
[DRM_IOCTL_NR(DRM_I830_INIT)] = {i830_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_I830_INIT, i830_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_I830_VERTEX)] = {i830_dma_vertex, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I830_VERTEX, i830_dma_vertex, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I830_CLEAR)] = {i830_clear_bufs, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I830_CLEAR, i830_clear_bufs, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I830_FLUSH)] = {i830_flush_ioctl, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I830_FLUSH, i830_flush_ioctl, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I830_GETAGE)] = {i830_getage, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I830_GETAGE, i830_getage, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I830_GETBUF)] = {i830_getbuf, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I830_GETBUF, i830_getbuf, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I830_SWAP)] = {i830_swap_bufs, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I830_SWAP, i830_swap_bufs, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I830_COPY)] = {i830_copybuf, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I830_COPY, i830_copybuf, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I830_DOCOPY)] = {i830_docopy, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I830_DOCOPY, i830_docopy, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I830_FLIP)] = {i830_flip_bufs, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I830_FLIP, i830_flip_bufs, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I830_IRQ_EMIT)] = {i830_irq_emit, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I830_IRQ_EMIT, i830_irq_emit, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I830_IRQ_WAIT)] = {i830_irq_wait, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I830_IRQ_WAIT, i830_irq_wait, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I830_GETPARAM)] = {i830_getparam, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I830_GETPARAM, i830_getparam, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I830_SETPARAM)] = {i830_setparam, DRM_AUTH}
|
DRM_IOCTL_DEF(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);
|
||||||
|
|
|
@ -122,14 +122,14 @@ typedef struct drm_i830_private {
|
||||||
|
|
||||||
} drm_i830_private_t;
|
} drm_i830_private_t;
|
||||||
|
|
||||||
extern drm_ioctl_desc_t i830_ioctls[];
|
extern struct drm_ioctl_desc i830_ioctls[];
|
||||||
extern int i830_max_ioctl;
|
extern int i830_max_ioctl;
|
||||||
|
|
||||||
/* i830_irq.c */
|
/* i830_irq.c */
|
||||||
extern int i830_irq_emit(struct inode *inode, struct drm_file *file_priv,
|
extern int i830_irq_emit(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
extern int i830_irq_wait(struct inode *inode, struct drm_file *file_priv,
|
extern int i830_irq_wait(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg);
|
struct drm_file *file_priv);
|
||||||
|
|
||||||
extern irqreturn_t i830_driver_irq_handler(DRM_IRQ_ARGS);
|
extern irqreturn_t i830_driver_irq_handler(DRM_IRQ_ARGS);
|
||||||
extern void i830_driver_irq_preinstall(struct drm_device * dev);
|
extern void i830_driver_irq_preinstall(struct drm_device * dev);
|
||||||
|
|
|
@ -114,12 +114,11 @@ static int i830_wait_irq(struct drm_device * dev, int irq_nr)
|
||||||
|
|
||||||
/* Needs the lock as it touches the ring.
|
/* Needs the lock as it touches the ring.
|
||||||
*/
|
*/
|
||||||
int i830_irq_emit(struct inode *inode, struct drm_file *file_priv,
|
int i830_irq_emit(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
drm_i830_private_t *dev_priv = dev->dev_private;
|
drm_i830_private_t *dev_priv = dev->dev_private;
|
||||||
drm_i830_irq_emit_t emit;
|
drm_i830_irq_emit_t *emit = data;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
@ -129,13 +128,9 @@ int i830_irq_emit(struct inode *inode, struct drm_file *file_priv,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (copy_from_user
|
|
||||||
(&emit, (drm_i830_irq_emit_t __user *) arg, sizeof(emit)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
result = i830_emit_irq(dev);
|
result = i830_emit_irq(dev);
|
||||||
|
|
||||||
if (copy_to_user(emit.irq_seq, &result, sizeof(int))) {
|
if (copy_to_user(emit->irq_seq, &result, sizeof(int))) {
|
||||||
DRM_ERROR("copy_to_user\n");
|
DRM_ERROR("copy_to_user\n");
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
@ -145,23 +140,18 @@ int i830_irq_emit(struct inode *inode, struct drm_file *file_priv,
|
||||||
|
|
||||||
/* Doesn't need the hardware lock.
|
/* Doesn't need the hardware lock.
|
||||||
*/
|
*/
|
||||||
int i830_irq_wait(struct inode *inode, struct drm_file *file_priv,
|
int i830_irq_wait(struct drm_device *dev, void *data,
|
||||||
unsigned int cmd, unsigned long arg)
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
struct drm_device *dev = file_priv->head->dev;
|
|
||||||
drm_i830_private_t *dev_priv = dev->dev_private;
|
drm_i830_private_t *dev_priv = dev->dev_private;
|
||||||
drm_i830_irq_wait_t irqwait;
|
drm_i830_irq_wait_t *irqwait = data;
|
||||||
|
|
||||||
if (!dev_priv) {
|
if (!dev_priv) {
|
||||||
DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
|
DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (copy_from_user(&irqwait, (drm_i830_irq_wait_t __user *) arg,
|
return i830_wait_irq(dev, irqwait->irq_seq);
|
||||||
sizeof(irqwait)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
return i830_wait_irq(dev, irqwait.irq_seq);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* drm_dma.h hooks
|
/* drm_dma.h hooks
|
||||||
|
|
|
@ -251,23 +251,20 @@ static int i915_dma_resume(struct drm_device * dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i915_dma_init(DRM_IOCTL_ARGS)
|
static int i915_dma_init(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_i915_private_t *dev_priv;
|
drm_i915_private_t *dev_priv;
|
||||||
drm_i915_init_t init;
|
drm_i915_init_t *init = data;
|
||||||
int retcode = 0;
|
int retcode = 0;
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(init, (drm_i915_init_t __user *) data,
|
switch (init->func) {
|
||||||
sizeof(init));
|
|
||||||
|
|
||||||
switch (init.func) {
|
|
||||||
case I915_INIT_DMA:
|
case I915_INIT_DMA:
|
||||||
dev_priv = drm_alloc(sizeof(drm_i915_private_t),
|
dev_priv = drm_alloc(sizeof(drm_i915_private_t),
|
||||||
DRM_MEM_DRIVER);
|
DRM_MEM_DRIVER);
|
||||||
if (dev_priv == NULL)
|
if (dev_priv == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
retcode = i915_initialize(dev, dev_priv, &init);
|
retcode = i915_initialize(dev, dev_priv, init);
|
||||||
break;
|
break;
|
||||||
case I915_CLEANUP_DMA:
|
case I915_CLEANUP_DMA:
|
||||||
retcode = i915_dma_cleanup(dev);
|
retcode = i915_dma_cleanup(dev);
|
||||||
|
@ -598,23 +595,22 @@ static int i915_quiescent(struct drm_device * dev)
|
||||||
return i915_wait_ring(dev, dev_priv->ring.Size - 8, __FUNCTION__);
|
return i915_wait_ring(dev, dev_priv->ring.Size - 8, __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i915_flush_ioctl(DRM_IOCTL_ARGS)
|
static int i915_flush_ioctl(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
return i915_quiescent(dev);
|
return i915_quiescent(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i915_batchbuffer(DRM_IOCTL_ARGS)
|
static int i915_batchbuffer(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
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;
|
||||||
u32 *hw_status = dev_priv->hw_status_page;
|
u32 *hw_status = dev_priv->hw_status_page;
|
||||||
drm_i915_sarea_t *sarea_priv = (drm_i915_sarea_t *)
|
drm_i915_sarea_t *sarea_priv = (drm_i915_sarea_t *)
|
||||||
dev_priv->sarea_priv;
|
dev_priv->sarea_priv;
|
||||||
drm_i915_batchbuffer_t batch;
|
drm_i915_batchbuffer_t *batch = data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!dev_priv->allow_batchbuffer) {
|
if (!dev_priv->allow_batchbuffer) {
|
||||||
|
@ -622,52 +618,46 @@ static int i915_batchbuffer(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(batch, (drm_i915_batchbuffer_t __user *) data,
|
|
||||||
sizeof(batch));
|
|
||||||
|
|
||||||
DRM_DEBUG("i915 batchbuffer, start %x used %d cliprects %d\n",
|
DRM_DEBUG("i915 batchbuffer, start %x used %d cliprects %d\n",
|
||||||
batch.start, batch.used, batch.num_cliprects);
|
batch->start, batch->used, batch->num_cliprects);
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
if (batch.num_cliprects && DRM_VERIFYAREA_READ(batch.cliprects,
|
if (batch->num_cliprects && DRM_VERIFYAREA_READ(batch->cliprects,
|
||||||
batch.num_cliprects *
|
batch->num_cliprects *
|
||||||
sizeof(struct drm_clip_rect)))
|
sizeof(struct drm_clip_rect)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
ret = i915_dispatch_batchbuffer(dev, &batch);
|
ret = i915_dispatch_batchbuffer(dev, batch);
|
||||||
|
|
||||||
sarea_priv->last_dispatch = (int)hw_status[5];
|
sarea_priv->last_dispatch = (int)hw_status[5];
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i915_cmdbuffer(DRM_IOCTL_ARGS)
|
static int i915_cmdbuffer(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
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;
|
||||||
u32 *hw_status = dev_priv->hw_status_page;
|
u32 *hw_status = dev_priv->hw_status_page;
|
||||||
drm_i915_sarea_t *sarea_priv = (drm_i915_sarea_t *)
|
drm_i915_sarea_t *sarea_priv = (drm_i915_sarea_t *)
|
||||||
dev_priv->sarea_priv;
|
dev_priv->sarea_priv;
|
||||||
drm_i915_cmdbuffer_t cmdbuf;
|
drm_i915_cmdbuffer_t *cmdbuf = data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(cmdbuf, (drm_i915_cmdbuffer_t __user *) data,
|
|
||||||
sizeof(cmdbuf));
|
|
||||||
|
|
||||||
DRM_DEBUG("i915 cmdbuffer, buf %p sz %d cliprects %d\n",
|
DRM_DEBUG("i915 cmdbuffer, buf %p sz %d cliprects %d\n",
|
||||||
cmdbuf.buf, cmdbuf.sz, cmdbuf.num_cliprects);
|
cmdbuf->buf, cmdbuf->sz, cmdbuf->num_cliprects);
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
if (cmdbuf.num_cliprects &&
|
if (cmdbuf->num_cliprects &&
|
||||||
DRM_VERIFYAREA_READ(cmdbuf.cliprects,
|
DRM_VERIFYAREA_READ(cmdbuf->cliprects,
|
||||||
cmdbuf.num_cliprects *
|
cmdbuf->num_cliprects *
|
||||||
sizeof(struct drm_clip_rect))) {
|
sizeof(struct drm_clip_rect))) {
|
||||||
DRM_ERROR("Fault accessing cliprects\n");
|
DRM_ERROR("Fault accessing cliprects\n");
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = i915_dispatch_cmdbuffer(dev, &cmdbuf);
|
ret = i915_dispatch_cmdbuffer(dev, cmdbuf);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
DRM_ERROR("i915_dispatch_cmdbuffer failed\n");
|
DRM_ERROR("i915_dispatch_cmdbuffer failed\n");
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -677,10 +667,9 @@ static int i915_cmdbuffer(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i915_flip_bufs(DRM_IOCTL_ARGS)
|
static int i915_flip_bufs(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
|
|
||||||
DRM_DEBUG("%s\n", __FUNCTION__);
|
DRM_DEBUG("%s\n", __FUNCTION__);
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
@ -688,11 +677,11 @@ static int i915_flip_bufs(DRM_IOCTL_ARGS)
|
||||||
return i915_dispatch_flip(dev);
|
return i915_dispatch_flip(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i915_getparam(DRM_IOCTL_ARGS)
|
static int i915_getparam(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_i915_private_t *dev_priv = dev->dev_private;
|
drm_i915_private_t *dev_priv = dev->dev_private;
|
||||||
drm_i915_getparam_t param;
|
drm_i915_getparam_t *param = data;
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
if (!dev_priv) {
|
if (!dev_priv) {
|
||||||
|
@ -700,10 +689,7 @@ static int i915_getparam(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(param, (drm_i915_getparam_t __user *) data,
|
switch (param->param) {
|
||||||
sizeof(param));
|
|
||||||
|
|
||||||
switch (param.param) {
|
|
||||||
case I915_PARAM_IRQ_ACTIVE:
|
case I915_PARAM_IRQ_ACTIVE:
|
||||||
value = dev->irq ? 1 : 0;
|
value = dev->irq ? 1 : 0;
|
||||||
break;
|
break;
|
||||||
|
@ -714,11 +700,11 @@ static int i915_getparam(DRM_IOCTL_ARGS)
|
||||||
value = READ_BREADCRUMB(dev_priv);
|
value = READ_BREADCRUMB(dev_priv);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DRM_ERROR("Unknown parameter %d\n", param.param);
|
DRM_ERROR("Unknown parameter %d\n", param->param);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DRM_COPY_TO_USER(param.value, &value, sizeof(int))) {
|
if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) {
|
||||||
DRM_ERROR("DRM_COPY_TO_USER failed\n");
|
DRM_ERROR("DRM_COPY_TO_USER failed\n");
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
@ -726,56 +712,52 @@ static int i915_getparam(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i915_setparam(DRM_IOCTL_ARGS)
|
static int i915_setparam(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_i915_private_t *dev_priv = dev->dev_private;
|
drm_i915_private_t *dev_priv = dev->dev_private;
|
||||||
drm_i915_setparam_t param;
|
drm_i915_setparam_t *param = data;
|
||||||
|
|
||||||
if (!dev_priv) {
|
if (!dev_priv) {
|
||||||
DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
|
DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(param, (drm_i915_setparam_t __user *) data,
|
switch (param->param) {
|
||||||
sizeof(param));
|
|
||||||
|
|
||||||
switch (param.param) {
|
|
||||||
case I915_SETPARAM_USE_MI_BATCHBUFFER_START:
|
case I915_SETPARAM_USE_MI_BATCHBUFFER_START:
|
||||||
if (!IS_I965G(dev))
|
if (!IS_I965G(dev))
|
||||||
dev_priv->use_mi_batchbuffer_start = param.value;
|
dev_priv->use_mi_batchbuffer_start = param->value;
|
||||||
break;
|
break;
|
||||||
case I915_SETPARAM_TEX_LRU_LOG_GRANULARITY:
|
case I915_SETPARAM_TEX_LRU_LOG_GRANULARITY:
|
||||||
dev_priv->tex_lru_log_granularity = param.value;
|
dev_priv->tex_lru_log_granularity = param->value;
|
||||||
break;
|
break;
|
||||||
case I915_SETPARAM_ALLOW_BATCHBUFFER:
|
case I915_SETPARAM_ALLOW_BATCHBUFFER:
|
||||||
dev_priv->allow_batchbuffer = param.value;
|
dev_priv->allow_batchbuffer = param->value;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DRM_ERROR("unknown parameter %d\n", param.param);
|
DRM_ERROR("unknown parameter %d\n", param->param);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i915_set_status_page(DRM_IOCTL_ARGS)
|
static int i915_set_status_page(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_i915_private_t *dev_priv = dev->dev_private;
|
drm_i915_private_t *dev_priv = dev->dev_private;
|
||||||
drm_i915_hws_addr_t hws;
|
drm_i915_hws_addr_t *hws = data;
|
||||||
|
|
||||||
if (!dev_priv) {
|
if (!dev_priv) {
|
||||||
DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
|
DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
DRM_COPY_FROM_USER_IOCTL(hws, (drm_i915_hws_addr_t __user *) data,
|
|
||||||
sizeof(hws));
|
|
||||||
printk(KERN_DEBUG "set status page addr 0x%08x\n", (u32)hws.addr);
|
|
||||||
|
|
||||||
dev_priv->status_gfx_addr = hws.addr & (0x1ffff<<12);
|
printk(KERN_DEBUG "set status page addr 0x%08x\n", (u32)hws->addr);
|
||||||
|
|
||||||
dev_priv->hws_map.offset = dev->agp->agp_info.aper_base + hws.addr;
|
dev_priv->status_gfx_addr = hws->addr & (0x1ffff<<12);
|
||||||
|
|
||||||
|
dev_priv->hws_map.offset = dev->agp->agp_info.aper_base + hws->addr;
|
||||||
dev_priv->hws_map.size = 4*1024;
|
dev_priv->hws_map.size = 4*1024;
|
||||||
dev_priv->hws_map.type = 0;
|
dev_priv->hws_map.type = 0;
|
||||||
dev_priv->hws_map.flags = 0;
|
dev_priv->hws_map.flags = 0;
|
||||||
|
@ -829,24 +811,24 @@ void i915_driver_preclose(struct drm_device * dev, struct drm_file *file_priv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
drm_ioctl_desc_t i915_ioctls[] = {
|
struct drm_ioctl_desc i915_ioctls[] = {
|
||||||
[DRM_IOCTL_NR(DRM_I915_INIT)] = {i915_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_I915_INIT, i915_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_I915_FLUSH)] = {i915_flush_ioctl, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I915_FLUSH, i915_flush_ioctl, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I915_FLIP)] = {i915_flip_bufs, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I915_FLIP, i915_flip_bufs, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I915_BATCHBUFFER)] = {i915_batchbuffer, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I915_BATCHBUFFER, i915_batchbuffer, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I915_IRQ_EMIT)] = {i915_irq_emit, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I915_IRQ_EMIT, i915_irq_emit, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I915_IRQ_WAIT)] = {i915_irq_wait, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I915_IRQ_WAIT, i915_irq_wait, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I915_GETPARAM)] = {i915_getparam, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I915_GETPARAM, i915_getparam, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I915_SETPARAM)] = {i915_setparam, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_I915_SETPARAM, i915_setparam, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_I915_ALLOC)] = {i915_mem_alloc, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I915_ALLOC, i915_mem_alloc, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I915_FREE)] = {i915_mem_free, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I915_FREE, i915_mem_free, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = {i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_I915_INIT_HEAP, i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = {i915_cmdbuffer, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I915_CMDBUFFER, i915_cmdbuffer, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I915_DESTROY_HEAP)] = { i915_mem_destroy_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY },
|
DRM_IOCTL_DEF(DRM_I915_DESTROY_HEAP, i915_mem_destroy_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY ),
|
||||||
[DRM_IOCTL_NR(DRM_I915_SET_VBLANK_PIPE)] = { i915_vblank_pipe_set, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY },
|
DRM_IOCTL_DEF(DRM_I915_SET_VBLANK_PIPE, i915_vblank_pipe_set, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY ),
|
||||||
[DRM_IOCTL_NR(DRM_I915_GET_VBLANK_PIPE)] = { i915_vblank_pipe_get, DRM_AUTH },
|
DRM_IOCTL_DEF(DRM_I915_GET_VBLANK_PIPE, i915_vblank_pipe_get, DRM_AUTH ),
|
||||||
[DRM_IOCTL_NR(DRM_I915_VBLANK_SWAP)] = {i915_vblank_swap, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I915_VBLANK_SWAP, i915_vblank_swap, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_I915_HWS_ADDR)] = {i915_set_status_page, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_I915_HWS_ADDR, i915_set_status_page, DRM_AUTH),
|
||||||
};
|
};
|
||||||
|
|
||||||
int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
|
int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
|
||||||
|
|
|
@ -116,7 +116,7 @@ typedef struct drm_i915_private {
|
||||||
unsigned int swaps_pending;
|
unsigned int swaps_pending;
|
||||||
} drm_i915_private_t;
|
} drm_i915_private_t;
|
||||||
|
|
||||||
extern drm_ioctl_desc_t i915_ioctls[];
|
extern struct drm_ioctl_desc i915_ioctls[];
|
||||||
extern int i915_max_ioctl;
|
extern int i915_max_ioctl;
|
||||||
|
|
||||||
/* i915_dma.c */
|
/* i915_dma.c */
|
||||||
|
@ -130,8 +130,10 @@ extern long i915_compat_ioctl(struct file *filp, unsigned int cmd,
|
||||||
unsigned long arg);
|
unsigned long arg);
|
||||||
|
|
||||||
/* i915_irq.c */
|
/* i915_irq.c */
|
||||||
extern int i915_irq_emit(DRM_IOCTL_ARGS);
|
extern int i915_irq_emit(struct drm_device *dev, void *data,
|
||||||
extern int i915_irq_wait(DRM_IOCTL_ARGS);
|
struct drm_file *file_priv);
|
||||||
|
extern int i915_irq_wait(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv);
|
||||||
|
|
||||||
extern int i915_driver_vblank_wait(struct drm_device *dev, unsigned int *sequence);
|
extern int i915_driver_vblank_wait(struct drm_device *dev, unsigned int *sequence);
|
||||||
extern int i915_driver_vblank_wait2(struct drm_device *dev, unsigned int *sequence);
|
extern int i915_driver_vblank_wait2(struct drm_device *dev, unsigned int *sequence);
|
||||||
|
@ -139,15 +141,22 @@ extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS);
|
||||||
extern void i915_driver_irq_preinstall(struct drm_device * dev);
|
extern void i915_driver_irq_preinstall(struct drm_device * dev);
|
||||||
extern void i915_driver_irq_postinstall(struct drm_device * dev);
|
extern void i915_driver_irq_postinstall(struct drm_device * dev);
|
||||||
extern void i915_driver_irq_uninstall(struct drm_device * dev);
|
extern void i915_driver_irq_uninstall(struct drm_device * dev);
|
||||||
extern int i915_vblank_pipe_set(DRM_IOCTL_ARGS);
|
extern int i915_vblank_pipe_set(struct drm_device *dev, void *data,
|
||||||
extern int i915_vblank_pipe_get(DRM_IOCTL_ARGS);
|
struct drm_file *file_priv);
|
||||||
extern int i915_vblank_swap(DRM_IOCTL_ARGS);
|
extern int i915_vblank_pipe_get(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv);
|
||||||
|
extern int i915_vblank_swap(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv);
|
||||||
|
|
||||||
/* i915_mem.c */
|
/* i915_mem.c */
|
||||||
extern int i915_mem_alloc(DRM_IOCTL_ARGS);
|
extern int i915_mem_alloc(struct drm_device *dev, void *data,
|
||||||
extern int i915_mem_free(DRM_IOCTL_ARGS);
|
struct drm_file *file_priv);
|
||||||
extern int i915_mem_init_heap(DRM_IOCTL_ARGS);
|
extern int i915_mem_free(struct drm_device *dev, void *data,
|
||||||
extern int i915_mem_destroy_heap(DRM_IOCTL_ARGS);
|
struct drm_file *file_priv);
|
||||||
|
extern int i915_mem_init_heap(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv);
|
||||||
|
extern int i915_mem_destroy_heap(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv);
|
||||||
extern void i915_mem_takedown(struct mem_block **heap);
|
extern void i915_mem_takedown(struct mem_block **heap);
|
||||||
extern void i915_mem_release(struct drm_device * dev,
|
extern void i915_mem_release(struct drm_device * dev,
|
||||||
struct drm_file *file_priv, struct mem_block *heap);
|
struct drm_file *file_priv, struct mem_block *heap);
|
||||||
|
|
|
@ -355,11 +355,11 @@ int i915_driver_vblank_wait2(struct drm_device *dev, unsigned int *sequence)
|
||||||
|
|
||||||
/* 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(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_i915_private_t *dev_priv = dev->dev_private;
|
drm_i915_private_t *dev_priv = dev->dev_private;
|
||||||
drm_i915_irq_emit_t emit;
|
drm_i915_irq_emit_t *emit = data;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
@ -369,12 +369,9 @@ int i915_irq_emit(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(emit, (drm_i915_irq_emit_t __user *) data,
|
|
||||||
sizeof(emit));
|
|
||||||
|
|
||||||
result = i915_emit_irq(dev);
|
result = i915_emit_irq(dev);
|
||||||
|
|
||||||
if (DRM_COPY_TO_USER(emit.irq_seq, &result, sizeof(int))) {
|
if (DRM_COPY_TO_USER(emit->irq_seq, &result, sizeof(int))) {
|
||||||
DRM_ERROR("copy_to_user\n");
|
DRM_ERROR("copy_to_user\n");
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
@ -384,21 +381,18 @@ int i915_irq_emit(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
/* Doesn't need the hardware lock.
|
/* Doesn't need the hardware lock.
|
||||||
*/
|
*/
|
||||||
int i915_irq_wait(DRM_IOCTL_ARGS)
|
int i915_irq_wait(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_i915_private_t *dev_priv = dev->dev_private;
|
drm_i915_private_t *dev_priv = dev->dev_private;
|
||||||
drm_i915_irq_wait_t irqwait;
|
drm_i915_irq_wait_t *irqwait = data;
|
||||||
|
|
||||||
if (!dev_priv) {
|
if (!dev_priv) {
|
||||||
DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
|
DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(irqwait, (drm_i915_irq_wait_t __user *) data,
|
return i915_wait_irq(dev, irqwait->irq_seq);
|
||||||
sizeof(irqwait));
|
|
||||||
|
|
||||||
return i915_wait_irq(dev, irqwait.irq_seq);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void i915_enable_interrupt (struct drm_device *dev)
|
static void i915_enable_interrupt (struct drm_device *dev)
|
||||||
|
@ -417,38 +411,35 @@ static void i915_enable_interrupt (struct drm_device *dev)
|
||||||
|
|
||||||
/* Set the vblank monitor pipe
|
/* Set the vblank monitor pipe
|
||||||
*/
|
*/
|
||||||
int i915_vblank_pipe_set(DRM_IOCTL_ARGS)
|
int i915_vblank_pipe_set(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_i915_private_t *dev_priv = dev->dev_private;
|
drm_i915_private_t *dev_priv = dev->dev_private;
|
||||||
drm_i915_vblank_pipe_t pipe;
|
drm_i915_vblank_pipe_t *pipe = data;
|
||||||
|
|
||||||
if (!dev_priv) {
|
if (!dev_priv) {
|
||||||
DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
|
DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(pipe, (drm_i915_vblank_pipe_t __user *) data,
|
if (pipe->pipe & ~(DRM_I915_VBLANK_PIPE_A|DRM_I915_VBLANK_PIPE_B)) {
|
||||||
sizeof(pipe));
|
|
||||||
|
|
||||||
if (pipe.pipe & ~(DRM_I915_VBLANK_PIPE_A|DRM_I915_VBLANK_PIPE_B)) {
|
|
||||||
DRM_ERROR("%s called with invalid pipe 0x%x\n",
|
DRM_ERROR("%s called with invalid pipe 0x%x\n",
|
||||||
__FUNCTION__, pipe.pipe);
|
__FUNCTION__, pipe->pipe);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_priv->vblank_pipe = pipe.pipe;
|
dev_priv->vblank_pipe = pipe->pipe;
|
||||||
|
|
||||||
i915_enable_interrupt (dev);
|
i915_enable_interrupt (dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i915_vblank_pipe_get(DRM_IOCTL_ARGS)
|
int i915_vblank_pipe_get(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_i915_private_t *dev_priv = dev->dev_private;
|
drm_i915_private_t *dev_priv = dev->dev_private;
|
||||||
drm_i915_vblank_pipe_t pipe;
|
drm_i915_vblank_pipe_t *pipe = data;
|
||||||
u16 flag;
|
u16 flag;
|
||||||
|
|
||||||
if (!dev_priv) {
|
if (!dev_priv) {
|
||||||
|
@ -457,24 +448,23 @@ int i915_vblank_pipe_get(DRM_IOCTL_ARGS)
|
||||||
}
|
}
|
||||||
|
|
||||||
flag = I915_READ(I915REG_INT_ENABLE_R);
|
flag = I915_READ(I915REG_INT_ENABLE_R);
|
||||||
pipe.pipe = 0;
|
pipe->pipe = 0;
|
||||||
if (flag & VSYNC_PIPEA_FLAG)
|
if (flag & VSYNC_PIPEA_FLAG)
|
||||||
pipe.pipe |= DRM_I915_VBLANK_PIPE_A;
|
pipe->pipe |= DRM_I915_VBLANK_PIPE_A;
|
||||||
if (flag & VSYNC_PIPEB_FLAG)
|
if (flag & VSYNC_PIPEB_FLAG)
|
||||||
pipe.pipe |= DRM_I915_VBLANK_PIPE_B;
|
pipe->pipe |= DRM_I915_VBLANK_PIPE_B;
|
||||||
DRM_COPY_TO_USER_IOCTL((drm_i915_vblank_pipe_t __user *) data, pipe,
|
|
||||||
sizeof(pipe));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schedule buffer swap at given vertical blank.
|
* Schedule buffer swap at given vertical blank.
|
||||||
*/
|
*/
|
||||||
int i915_vblank_swap(DRM_IOCTL_ARGS)
|
int i915_vblank_swap(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_i915_private_t *dev_priv = dev->dev_private;
|
drm_i915_private_t *dev_priv = dev->dev_private;
|
||||||
drm_i915_vblank_swap_t swap;
|
drm_i915_vblank_swap_t *swap = data;
|
||||||
drm_i915_vbl_swap_t *vbl_swap;
|
drm_i915_vbl_swap_t *vbl_swap;
|
||||||
unsigned int pipe, seqtype, curseq;
|
unsigned int pipe, seqtype, curseq;
|
||||||
unsigned long irqflags;
|
unsigned long irqflags;
|
||||||
|
@ -490,18 +480,15 @@ int i915_vblank_swap(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(swap, (drm_i915_vblank_swap_t __user *) data,
|
if (swap->seqtype & ~(_DRM_VBLANK_RELATIVE | _DRM_VBLANK_ABSOLUTE |
|
||||||
sizeof(swap));
|
|
||||||
|
|
||||||
if (swap.seqtype & ~(_DRM_VBLANK_RELATIVE | _DRM_VBLANK_ABSOLUTE |
|
|
||||||
_DRM_VBLANK_SECONDARY | _DRM_VBLANK_NEXTONMISS)) {
|
_DRM_VBLANK_SECONDARY | _DRM_VBLANK_NEXTONMISS)) {
|
||||||
DRM_ERROR("Invalid sequence type 0x%x\n", swap.seqtype);
|
DRM_ERROR("Invalid sequence type 0x%x\n", swap->seqtype);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pipe = (swap.seqtype & _DRM_VBLANK_SECONDARY) ? 1 : 0;
|
pipe = (swap->seqtype & _DRM_VBLANK_SECONDARY) ? 1 : 0;
|
||||||
|
|
||||||
seqtype = swap.seqtype & (_DRM_VBLANK_RELATIVE | _DRM_VBLANK_ABSOLUTE);
|
seqtype = swap->seqtype & (_DRM_VBLANK_RELATIVE | _DRM_VBLANK_ABSOLUTE);
|
||||||
|
|
||||||
if (!(dev_priv->vblank_pipe & (1 << pipe))) {
|
if (!(dev_priv->vblank_pipe & (1 << pipe))) {
|
||||||
DRM_ERROR("Invalid pipe %d\n", pipe);
|
DRM_ERROR("Invalid pipe %d\n", pipe);
|
||||||
|
@ -510,9 +497,9 @@ int i915_vblank_swap(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
spin_lock_irqsave(&dev->drw_lock, irqflags);
|
spin_lock_irqsave(&dev->drw_lock, irqflags);
|
||||||
|
|
||||||
if (!drm_get_drawable_info(dev, swap.drawable)) {
|
if (!drm_get_drawable_info(dev, swap->drawable)) {
|
||||||
spin_unlock_irqrestore(&dev->drw_lock, irqflags);
|
spin_unlock_irqrestore(&dev->drw_lock, irqflags);
|
||||||
DRM_DEBUG("Invalid drawable ID %d\n", swap.drawable);
|
DRM_DEBUG("Invalid drawable ID %d\n", swap->drawable);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,11 +508,11 @@ int i915_vblank_swap(DRM_IOCTL_ARGS)
|
||||||
curseq = atomic_read(pipe ? &dev->vbl_received2 : &dev->vbl_received);
|
curseq = atomic_read(pipe ? &dev->vbl_received2 : &dev->vbl_received);
|
||||||
|
|
||||||
if (seqtype == _DRM_VBLANK_RELATIVE)
|
if (seqtype == _DRM_VBLANK_RELATIVE)
|
||||||
swap.sequence += curseq;
|
swap->sequence += curseq;
|
||||||
|
|
||||||
if ((curseq - swap.sequence) <= (1<<23)) {
|
if ((curseq - swap->sequence) <= (1<<23)) {
|
||||||
if (swap.seqtype & _DRM_VBLANK_NEXTONMISS) {
|
if (swap->seqtype & _DRM_VBLANK_NEXTONMISS) {
|
||||||
swap.sequence = curseq + 1;
|
swap->sequence = curseq + 1;
|
||||||
} else {
|
} else {
|
||||||
DRM_DEBUG("Missed target sequence\n");
|
DRM_DEBUG("Missed target sequence\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -537,9 +524,9 @@ int i915_vblank_swap(DRM_IOCTL_ARGS)
|
||||||
list_for_each(list, &dev_priv->vbl_swaps.head) {
|
list_for_each(list, &dev_priv->vbl_swaps.head) {
|
||||||
vbl_swap = list_entry(list, drm_i915_vbl_swap_t, head);
|
vbl_swap = list_entry(list, drm_i915_vbl_swap_t, head);
|
||||||
|
|
||||||
if (vbl_swap->drw_id == swap.drawable &&
|
if (vbl_swap->drw_id == swap->drawable &&
|
||||||
vbl_swap->pipe == pipe &&
|
vbl_swap->pipe == pipe &&
|
||||||
vbl_swap->sequence == swap.sequence) {
|
vbl_swap->sequence == swap->sequence) {
|
||||||
spin_unlock_irqrestore(&dev_priv->swaps_lock, irqflags);
|
spin_unlock_irqrestore(&dev_priv->swaps_lock, irqflags);
|
||||||
DRM_DEBUG("Already scheduled\n");
|
DRM_DEBUG("Already scheduled\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -562,9 +549,9 @@ int i915_vblank_swap(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
DRM_DEBUG("\n");
|
DRM_DEBUG("\n");
|
||||||
|
|
||||||
vbl_swap->drw_id = swap.drawable;
|
vbl_swap->drw_id = swap->drawable;
|
||||||
vbl_swap->pipe = pipe;
|
vbl_swap->pipe = pipe;
|
||||||
vbl_swap->sequence = swap.sequence;
|
vbl_swap->sequence = swap->sequence;
|
||||||
|
|
||||||
spin_lock_irqsave(&dev_priv->swaps_lock, irqflags);
|
spin_lock_irqsave(&dev_priv->swaps_lock, irqflags);
|
||||||
|
|
||||||
|
@ -573,9 +560,6 @@ int i915_vblank_swap(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
spin_unlock_irqrestore(&dev_priv->swaps_lock, irqflags);
|
spin_unlock_irqrestore(&dev_priv->swaps_lock, irqflags);
|
||||||
|
|
||||||
DRM_COPY_TO_USER_IOCTL((drm_i915_vblank_swap_t __user *) data, swap,
|
|
||||||
sizeof(swap));
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -268,11 +268,11 @@ static struct mem_block **get_heap(drm_i915_private_t * dev_priv, int region)
|
||||||
|
|
||||||
/* IOCTL HANDLERS */
|
/* IOCTL HANDLERS */
|
||||||
|
|
||||||
int i915_mem_alloc(DRM_IOCTL_ARGS)
|
int i915_mem_alloc(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_i915_private_t *dev_priv = dev->dev_private;
|
drm_i915_private_t *dev_priv = dev->dev_private;
|
||||||
drm_i915_mem_alloc_t alloc;
|
drm_i915_mem_alloc_t *alloc = data;
|
||||||
struct mem_block *block, **heap;
|
struct mem_block *block, **heap;
|
||||||
|
|
||||||
if (!dev_priv) {
|
if (!dev_priv) {
|
||||||
|
@ -280,27 +280,25 @@ int i915_mem_alloc(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(alloc, (drm_i915_mem_alloc_t __user *) data,
|
heap = get_heap(dev_priv, alloc->region);
|
||||||
sizeof(alloc));
|
|
||||||
|
|
||||||
heap = get_heap(dev_priv, alloc.region);
|
|
||||||
if (!heap || !*heap)
|
if (!heap || !*heap)
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
/* Make things easier on ourselves: all allocations at least
|
/* Make things easier on ourselves: all allocations at least
|
||||||
* 4k aligned.
|
* 4k aligned.
|
||||||
*/
|
*/
|
||||||
if (alloc.alignment < 12)
|
if (alloc->alignment < 12)
|
||||||
alloc.alignment = 12;
|
alloc->alignment = 12;
|
||||||
|
|
||||||
block = alloc_block(*heap, alloc.size, alloc.alignment, file_priv);
|
block = alloc_block(*heap, alloc->size, alloc->alignment, file_priv);
|
||||||
|
|
||||||
if (!block)
|
if (!block)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
mark_block(dev, block, 1);
|
mark_block(dev, block, 1);
|
||||||
|
|
||||||
if (DRM_COPY_TO_USER(alloc.region_offset, &block->start, sizeof(int))) {
|
if (DRM_COPY_TO_USER(alloc->region_offset, &block->start,
|
||||||
|
sizeof(int))) {
|
||||||
DRM_ERROR("copy_to_user\n");
|
DRM_ERROR("copy_to_user\n");
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
@ -308,11 +306,11 @@ int i915_mem_alloc(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i915_mem_free(DRM_IOCTL_ARGS)
|
int i915_mem_free(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_i915_private_t *dev_priv = dev->dev_private;
|
drm_i915_private_t *dev_priv = dev->dev_private;
|
||||||
drm_i915_mem_free_t memfree;
|
drm_i915_mem_free_t *memfree = data;
|
||||||
struct mem_block *block, **heap;
|
struct mem_block *block, **heap;
|
||||||
|
|
||||||
if (!dev_priv) {
|
if (!dev_priv) {
|
||||||
|
@ -320,14 +318,11 @@ int i915_mem_free(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(memfree, (drm_i915_mem_free_t __user *) data,
|
heap = get_heap(dev_priv, memfree->region);
|
||||||
sizeof(memfree));
|
|
||||||
|
|
||||||
heap = get_heap(dev_priv, memfree.region);
|
|
||||||
if (!heap || !*heap)
|
if (!heap || !*heap)
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
block = find_block(*heap, memfree.region_offset);
|
block = find_block(*heap, memfree->region_offset);
|
||||||
if (!block)
|
if (!block)
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
|
@ -339,11 +334,11 @@ int i915_mem_free(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i915_mem_init_heap(DRM_IOCTL_ARGS)
|
int i915_mem_init_heap(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_i915_private_t *dev_priv = dev->dev_private;
|
drm_i915_private_t *dev_priv = dev->dev_private;
|
||||||
drm_i915_mem_init_heap_t initheap;
|
drm_i915_mem_init_heap_t *initheap = data;
|
||||||
struct mem_block **heap;
|
struct mem_block **heap;
|
||||||
|
|
||||||
if (!dev_priv) {
|
if (!dev_priv) {
|
||||||
|
@ -351,11 +346,7 @@ int i915_mem_init_heap(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(initheap,
|
heap = get_heap(dev_priv, initheap->region);
|
||||||
(drm_i915_mem_init_heap_t __user *) data,
|
|
||||||
sizeof(initheap));
|
|
||||||
|
|
||||||
heap = get_heap(dev_priv, initheap.region);
|
|
||||||
if (!heap)
|
if (!heap)
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
|
@ -364,14 +355,14 @@ int i915_mem_init_heap(DRM_IOCTL_ARGS)
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return init_heap(heap, initheap.start, initheap.size);
|
return init_heap(heap, initheap->start, initheap->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
int i915_mem_destroy_heap( DRM_IOCTL_ARGS )
|
int i915_mem_destroy_heap( struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv )
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_i915_private_t *dev_priv = dev->dev_private;
|
drm_i915_private_t *dev_priv = dev->dev_private;
|
||||||
drm_i915_mem_destroy_heap_t destroyheap;
|
drm_i915_mem_destroy_heap_t *destroyheap = data;
|
||||||
struct mem_block **heap;
|
struct mem_block **heap;
|
||||||
|
|
||||||
if ( !dev_priv ) {
|
if ( !dev_priv ) {
|
||||||
|
@ -379,10 +370,7 @@ int i915_mem_destroy_heap( DRM_IOCTL_ARGS )
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL( destroyheap, (drm_i915_mem_destroy_heap_t *)data,
|
heap = get_heap( dev_priv, destroyheap->region );
|
||||||
sizeof(destroyheap) );
|
|
||||||
|
|
||||||
heap = get_heap( dev_priv, destroyheap.region );
|
|
||||||
if (!heap) {
|
if (!heap) {
|
||||||
DRM_ERROR("get_heap failed");
|
DRM_ERROR("get_heap failed");
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
|
@ -759,36 +759,30 @@ static int mga_do_dma_bootstrap(struct drm_device * dev,
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mga_dma_bootstrap(DRM_IOCTL_ARGS)
|
int mga_dma_bootstrap(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
drm_mga_dma_bootstrap_t *bootstrap = data;
|
||||||
drm_mga_dma_bootstrap_t bootstrap;
|
|
||||||
int err;
|
int err;
|
||||||
static const int modes[] = { 0, 1, 2, 2, 4, 4, 4, 4 };
|
static const int modes[] = { 0, 1, 2, 2, 4, 4, 4, 4 };
|
||||||
const drm_mga_private_t *const dev_priv =
|
const drm_mga_private_t *const dev_priv =
|
||||||
(drm_mga_private_t *) dev->dev_private;
|
(drm_mga_private_t *) dev->dev_private;
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(bootstrap,
|
err = mga_do_dma_bootstrap(dev, bootstrap);
|
||||||
(drm_mga_dma_bootstrap_t __user *) data,
|
|
||||||
sizeof(bootstrap));
|
|
||||||
|
|
||||||
err = mga_do_dma_bootstrap(dev, &bootstrap);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
mga_do_cleanup_dma(dev, FULL_CLEANUP);
|
mga_do_cleanup_dma(dev, FULL_CLEANUP);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev_priv->agp_textures != NULL) {
|
if (dev_priv->agp_textures != NULL) {
|
||||||
bootstrap.texture_handle = dev_priv->agp_textures->offset;
|
bootstrap->texture_handle = dev_priv->agp_textures->offset;
|
||||||
bootstrap.texture_size = dev_priv->agp_textures->size;
|
bootstrap->texture_size = dev_priv->agp_textures->size;
|
||||||
} else {
|
} else {
|
||||||
bootstrap.texture_handle = 0;
|
bootstrap->texture_handle = 0;
|
||||||
bootstrap.texture_size = 0;
|
bootstrap->texture_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bootstrap.agp_mode = modes[bootstrap.agp_mode & 0x07];
|
bootstrap->agp_mode = modes[bootstrap->agp_mode & 0x07];
|
||||||
DRM_COPY_TO_USER_IOCTL((drm_mga_dma_bootstrap_t __user *)data,
|
|
||||||
bootstrap, sizeof(bootstrap));
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -1007,20 +1001,17 @@ static int mga_do_cleanup_dma(struct drm_device *dev, int full_cleanup)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mga_dma_init(DRM_IOCTL_ARGS)
|
int mga_dma_init(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
drm_mga_init_t *init = data;
|
||||||
drm_mga_init_t init;
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(init, (drm_mga_init_t __user *) data,
|
switch (init->func) {
|
||||||
sizeof(init));
|
|
||||||
|
|
||||||
switch (init.func) {
|
|
||||||
case MGA_INIT_DMA:
|
case MGA_INIT_DMA:
|
||||||
err = mga_do_init_dma(dev, &init);
|
err = mga_do_init_dma(dev, init);
|
||||||
if (err) {
|
if (err) {
|
||||||
(void)mga_do_cleanup_dma(dev, FULL_CLEANUP);
|
(void)mga_do_cleanup_dma(dev, FULL_CLEANUP);
|
||||||
}
|
}
|
||||||
|
@ -1036,29 +1027,26 @@ int mga_dma_init(DRM_IOCTL_ARGS)
|
||||||
* Primary DMA stream management
|
* Primary DMA stream management
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int mga_dma_flush(DRM_IOCTL_ARGS)
|
int mga_dma_flush(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private;
|
drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private;
|
||||||
struct drm_lock lock;
|
struct drm_lock *lock = data;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(lock, (struct drm_lock __user *) data,
|
|
||||||
sizeof(lock));
|
|
||||||
|
|
||||||
DRM_DEBUG("%s%s%s\n",
|
DRM_DEBUG("%s%s%s\n",
|
||||||
(lock.flags & _DRM_LOCK_FLUSH) ? "flush, " : "",
|
(lock->flags & _DRM_LOCK_FLUSH) ? "flush, " : "",
|
||||||
(lock.flags & _DRM_LOCK_FLUSH_ALL) ? "flush all, " : "",
|
(lock->flags & _DRM_LOCK_FLUSH_ALL) ? "flush all, " : "",
|
||||||
(lock.flags & _DRM_LOCK_QUIESCENT) ? "idle, " : "");
|
(lock->flags & _DRM_LOCK_QUIESCENT) ? "idle, " : "");
|
||||||
|
|
||||||
WRAP_WAIT_WITH_RETURN(dev_priv);
|
WRAP_WAIT_WITH_RETURN(dev_priv);
|
||||||
|
|
||||||
if (lock.flags & (_DRM_LOCK_FLUSH | _DRM_LOCK_FLUSH_ALL)) {
|
if (lock->flags & (_DRM_LOCK_FLUSH | _DRM_LOCK_FLUSH_ALL)) {
|
||||||
mga_do_dma_flush(dev_priv);
|
mga_do_dma_flush(dev_priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lock.flags & _DRM_LOCK_QUIESCENT) {
|
if (lock->flags & _DRM_LOCK_QUIESCENT) {
|
||||||
#if MGA_DMA_DEBUG
|
#if MGA_DMA_DEBUG
|
||||||
int ret = mga_do_wait_for_idle(dev_priv);
|
int ret = mga_do_wait_for_idle(dev_priv);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -1072,9 +1060,9 @@ int mga_dma_flush(DRM_IOCTL_ARGS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int mga_dma_reset(DRM_IOCTL_ARGS)
|
int mga_dma_reset(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private;
|
drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
@ -1111,45 +1099,40 @@ static int mga_dma_get_buffers(struct drm_device * dev,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mga_dma_buffers(DRM_IOCTL_ARGS)
|
int mga_dma_buffers(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private;
|
drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private;
|
||||||
struct drm_dma __user *argp = (void __user *)data;
|
struct drm_dma *d = data;
|
||||||
struct drm_dma d;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(d, argp, sizeof(d));
|
|
||||||
|
|
||||||
/* Please don't send us buffers.
|
/* Please don't send us buffers.
|
||||||
*/
|
*/
|
||||||
if (d.send_count != 0) {
|
if (d->send_count != 0) {
|
||||||
DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n",
|
DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n",
|
||||||
DRM_CURRENTPID, d.send_count);
|
DRM_CURRENTPID, d->send_count);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We'll send you buffers.
|
/* We'll send you buffers.
|
||||||
*/
|
*/
|
||||||
if (d.request_count < 0 || d.request_count > dma->buf_count) {
|
if (d->request_count < 0 || d->request_count > dma->buf_count) {
|
||||||
DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n",
|
DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n",
|
||||||
DRM_CURRENTPID, d.request_count, dma->buf_count);
|
DRM_CURRENTPID, d->request_count, dma->buf_count);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
WRAP_TEST_WITH_RETURN(dev_priv);
|
WRAP_TEST_WITH_RETURN(dev_priv);
|
||||||
|
|
||||||
d.granted_count = 0;
|
d->granted_count = 0;
|
||||||
|
|
||||||
if (d.request_count) {
|
if (d->request_count) {
|
||||||
ret = mga_dma_get_buffers(dev, file_priv, &d);
|
ret = mga_dma_get_buffers(dev, file_priv, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_TO_USER_IOCTL(argp, d, sizeof(d));
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,15 +148,20 @@ typedef struct drm_mga_private {
|
||||||
unsigned int agp_size;
|
unsigned int agp_size;
|
||||||
} drm_mga_private_t;
|
} drm_mga_private_t;
|
||||||
|
|
||||||
extern drm_ioctl_desc_t mga_ioctls[];
|
extern struct drm_ioctl_desc mga_ioctls[];
|
||||||
extern int mga_max_ioctl;
|
extern int mga_max_ioctl;
|
||||||
|
|
||||||
/* mga_dma.c */
|
/* mga_dma.c */
|
||||||
extern int mga_dma_bootstrap(DRM_IOCTL_ARGS);
|
extern int mga_dma_bootstrap(struct drm_device *dev, void *data,
|
||||||
extern int mga_dma_init(DRM_IOCTL_ARGS);
|
struct drm_file *file_priv);
|
||||||
extern int mga_dma_flush(DRM_IOCTL_ARGS);
|
extern int mga_dma_init(struct drm_device *dev, void *data,
|
||||||
extern int mga_dma_reset(DRM_IOCTL_ARGS);
|
struct drm_file *file_priv);
|
||||||
extern int mga_dma_buffers(DRM_IOCTL_ARGS);
|
extern int mga_dma_flush(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv);
|
||||||
|
extern int mga_dma_reset(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv);
|
||||||
|
extern int mga_dma_buffers(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv);
|
||||||
extern int mga_driver_load(struct drm_device *dev, unsigned long flags);
|
extern int mga_driver_load(struct drm_device *dev, unsigned long flags);
|
||||||
extern int mga_driver_unload(struct drm_device * dev);
|
extern int mga_driver_unload(struct drm_device * dev);
|
||||||
extern void mga_driver_lastclose(struct drm_device * dev);
|
extern void mga_driver_lastclose(struct drm_device * dev);
|
||||||
|
|
|
@ -828,24 +828,20 @@ static void mga_dma_dispatch_blit(struct drm_device * dev, drm_mga_blit_t * blit
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int mga_dma_clear(DRM_IOCTL_ARGS)
|
static int mga_dma_clear(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_mga_private_t *dev_priv = dev->dev_private;
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
||||||
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
||||||
drm_mga_clear_t clear;
|
drm_mga_clear_t *clear = data;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(clear, (drm_mga_clear_t __user *) data,
|
|
||||||
sizeof(clear));
|
|
||||||
|
|
||||||
if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS)
|
if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS)
|
||||||
sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS;
|
sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS;
|
||||||
|
|
||||||
WRAP_TEST_WITH_RETURN(dev_priv);
|
WRAP_TEST_WITH_RETURN(dev_priv);
|
||||||
|
|
||||||
mga_dma_dispatch_clear(dev, &clear);
|
mga_dma_dispatch_clear(dev, clear);
|
||||||
|
|
||||||
/* Make sure we restore the 3D state next time.
|
/* Make sure we restore the 3D state next time.
|
||||||
*/
|
*/
|
||||||
|
@ -854,9 +850,8 @@ static int mga_dma_clear(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mga_dma_swap(DRM_IOCTL_ARGS)
|
static int mga_dma_swap(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_mga_private_t *dev_priv = dev->dev_private;
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
||||||
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
||||||
|
|
||||||
|
@ -876,31 +871,26 @@ static int mga_dma_swap(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mga_dma_vertex(DRM_IOCTL_ARGS)
|
static int mga_dma_vertex(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_mga_private_t *dev_priv = dev->dev_private;
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
struct drm_buf *buf;
|
struct drm_buf *buf;
|
||||||
drm_mga_buf_priv_t *buf_priv;
|
drm_mga_buf_priv_t *buf_priv;
|
||||||
drm_mga_vertex_t vertex;
|
drm_mga_vertex_t *vertex = data;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(vertex,
|
if (vertex->idx < 0 || vertex->idx > dma->buf_count)
|
||||||
(drm_mga_vertex_t __user *) data,
|
|
||||||
sizeof(vertex));
|
|
||||||
|
|
||||||
if (vertex.idx < 0 || vertex.idx > dma->buf_count)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
buf = dma->buflist[vertex.idx];
|
buf = dma->buflist[vertex->idx];
|
||||||
buf_priv = buf->dev_private;
|
buf_priv = buf->dev_private;
|
||||||
|
|
||||||
buf->used = vertex.used;
|
buf->used = vertex->used;
|
||||||
buf_priv->discard = vertex.discard;
|
buf_priv->discard = vertex->discard;
|
||||||
|
|
||||||
if (!mga_verify_state(dev_priv)) {
|
if (!mga_verify_state(dev_priv)) {
|
||||||
if (vertex.discard) {
|
if (vertex->discard) {
|
||||||
if (buf_priv->dispatched == 1)
|
if (buf_priv->dispatched == 1)
|
||||||
AGE_BUFFER(buf_priv);
|
AGE_BUFFER(buf_priv);
|
||||||
buf_priv->dispatched = 0;
|
buf_priv->dispatched = 0;
|
||||||
|
@ -916,31 +906,26 @@ static int mga_dma_vertex(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mga_dma_indices(DRM_IOCTL_ARGS)
|
static int mga_dma_indices(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_mga_private_t *dev_priv = dev->dev_private;
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
struct drm_buf *buf;
|
struct drm_buf *buf;
|
||||||
drm_mga_buf_priv_t *buf_priv;
|
drm_mga_buf_priv_t *buf_priv;
|
||||||
drm_mga_indices_t indices;
|
drm_mga_indices_t *indices = data;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(indices,
|
if (indices->idx < 0 || indices->idx > dma->buf_count)
|
||||||
(drm_mga_indices_t __user *) data,
|
|
||||||
sizeof(indices));
|
|
||||||
|
|
||||||
if (indices.idx < 0 || indices.idx > dma->buf_count)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
buf = dma->buflist[indices.idx];
|
buf = dma->buflist[indices->idx];
|
||||||
buf_priv = buf->dev_private;
|
buf_priv = buf->dev_private;
|
||||||
|
|
||||||
buf_priv->discard = indices.discard;
|
buf_priv->discard = indices->discard;
|
||||||
|
|
||||||
if (!mga_verify_state(dev_priv)) {
|
if (!mga_verify_state(dev_priv)) {
|
||||||
if (indices.discard) {
|
if (indices->discard) {
|
||||||
if (buf_priv->dispatched == 1)
|
if (buf_priv->dispatched == 1)
|
||||||
AGE_BUFFER(buf_priv);
|
AGE_BUFFER(buf_priv);
|
||||||
buf_priv->dispatched = 0;
|
buf_priv->dispatched = 0;
|
||||||
|
@ -951,26 +936,22 @@ static int mga_dma_indices(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
WRAP_TEST_WITH_RETURN(dev_priv);
|
WRAP_TEST_WITH_RETURN(dev_priv);
|
||||||
|
|
||||||
mga_dma_dispatch_indices(dev, buf, indices.start, indices.end);
|
mga_dma_dispatch_indices(dev, buf, indices->start, indices->end);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mga_dma_iload(DRM_IOCTL_ARGS)
|
static int mga_dma_iload(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
drm_mga_private_t *dev_priv = dev->dev_private;
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
||||||
struct drm_buf *buf;
|
struct drm_buf *buf;
|
||||||
drm_mga_buf_priv_t *buf_priv;
|
drm_mga_buf_priv_t *buf_priv;
|
||||||
drm_mga_iload_t iload;
|
drm_mga_iload_t *iload = data;
|
||||||
DRM_DEBUG("\n");
|
DRM_DEBUG("\n");
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(iload, (drm_mga_iload_t __user *) data,
|
|
||||||
sizeof(iload));
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (mga_do_wait_for_idle(dev_priv) < 0) {
|
if (mga_do_wait_for_idle(dev_priv) < 0) {
|
||||||
if (MGA_DMA_DEBUG)
|
if (MGA_DMA_DEBUG)
|
||||||
|
@ -978,20 +959,20 @@ static int mga_dma_iload(DRM_IOCTL_ARGS)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (iload.idx < 0 || iload.idx > dma->buf_count)
|
if (iload->idx < 0 || iload->idx > dma->buf_count)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
buf = dma->buflist[iload.idx];
|
buf = dma->buflist[iload->idx];
|
||||||
buf_priv = buf->dev_private;
|
buf_priv = buf->dev_private;
|
||||||
|
|
||||||
if (mga_verify_iload(dev_priv, iload.dstorg, iload.length)) {
|
if (mga_verify_iload(dev_priv, iload->dstorg, iload->length)) {
|
||||||
mga_freelist_put(dev, buf);
|
mga_freelist_put(dev, buf);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
WRAP_TEST_WITH_RETURN(dev_priv);
|
WRAP_TEST_WITH_RETURN(dev_priv);
|
||||||
|
|
||||||
mga_dma_dispatch_iload(dev, buf, iload.dstorg, iload.length);
|
mga_dma_dispatch_iload(dev, buf, iload->dstorg, iload->length);
|
||||||
|
|
||||||
/* Make sure we restore the 3D state next time.
|
/* Make sure we restore the 3D state next time.
|
||||||
*/
|
*/
|
||||||
|
@ -1000,28 +981,24 @@ static int mga_dma_iload(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mga_dma_blit(DRM_IOCTL_ARGS)
|
static int mga_dma_blit(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_mga_private_t *dev_priv = dev->dev_private;
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
||||||
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
||||||
drm_mga_blit_t blit;
|
drm_mga_blit_t *blit = data;
|
||||||
DRM_DEBUG("\n");
|
DRM_DEBUG("\n");
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(blit, (drm_mga_blit_t __user *) data,
|
|
||||||
sizeof(blit));
|
|
||||||
|
|
||||||
if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS)
|
if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS)
|
||||||
sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS;
|
sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS;
|
||||||
|
|
||||||
if (mga_verify_blit(dev_priv, blit.srcorg, blit.dstorg))
|
if (mga_verify_blit(dev_priv, blit->srcorg, blit->dstorg))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
WRAP_TEST_WITH_RETURN(dev_priv);
|
WRAP_TEST_WITH_RETURN(dev_priv);
|
||||||
|
|
||||||
mga_dma_dispatch_blit(dev, &blit);
|
mga_dma_dispatch_blit(dev, blit);
|
||||||
|
|
||||||
/* Make sure we restore the 3D state next time.
|
/* Make sure we restore the 3D state next time.
|
||||||
*/
|
*/
|
||||||
|
@ -1030,11 +1007,10 @@ static int mga_dma_blit(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mga_getparam(DRM_IOCTL_ARGS)
|
static int mga_getparam(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_mga_private_t *dev_priv = dev->dev_private;
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
||||||
drm_mga_getparam_t param;
|
drm_mga_getparam_t *param = data;
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
if (!dev_priv) {
|
if (!dev_priv) {
|
||||||
|
@ -1042,12 +1018,9 @@ static int mga_getparam(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(param, (drm_mga_getparam_t __user *) data,
|
|
||||||
sizeof(param));
|
|
||||||
|
|
||||||
DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
|
DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
|
||||||
|
|
||||||
switch (param.param) {
|
switch (param->param) {
|
||||||
case MGA_PARAM_IRQ_NR:
|
case MGA_PARAM_IRQ_NR:
|
||||||
value = dev->irq;
|
value = dev->irq;
|
||||||
break;
|
break;
|
||||||
|
@ -1058,7 +1031,7 @@ static int mga_getparam(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DRM_COPY_TO_USER(param.value, &value, sizeof(int))) {
|
if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) {
|
||||||
DRM_ERROR("copy_to_user\n");
|
DRM_ERROR("copy_to_user\n");
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
@ -1066,11 +1039,10 @@ static int mga_getparam(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mga_set_fence(DRM_IOCTL_ARGS)
|
static int mga_set_fence(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_mga_private_t *dev_priv = dev->dev_private;
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
||||||
u32 temp;
|
u32 *fence = data;
|
||||||
DMA_LOCALS;
|
DMA_LOCALS;
|
||||||
|
|
||||||
if (!dev_priv) {
|
if (!dev_priv) {
|
||||||
|
@ -1080,11 +1052,11 @@ static int mga_set_fence(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
|
DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
|
||||||
|
|
||||||
/* I would normal do this assignment in the declaration of temp,
|
/* I would normal do this assignment in the declaration of fence,
|
||||||
* but dev_priv may be NULL.
|
* but dev_priv may be NULL.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
temp = dev_priv->next_fence_to_post;
|
*fence = dev_priv->next_fence_to_post;
|
||||||
dev_priv->next_fence_to_post++;
|
dev_priv->next_fence_to_post++;
|
||||||
|
|
||||||
BEGIN_DMA(1);
|
BEGIN_DMA(1);
|
||||||
|
@ -1093,53 +1065,40 @@ static int mga_set_fence(DRM_IOCTL_ARGS)
|
||||||
MGA_DMAPAD, 0x00000000, MGA_SOFTRAP, 0x00000000);
|
MGA_DMAPAD, 0x00000000, MGA_SOFTRAP, 0x00000000);
|
||||||
ADVANCE_DMA();
|
ADVANCE_DMA();
|
||||||
|
|
||||||
if (DRM_COPY_TO_USER((u32 __user *) data, &temp, sizeof(u32))) {
|
|
||||||
DRM_ERROR("copy_to_user\n");
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mga_wait_fence(DRM_IOCTL_ARGS)
|
static int mga_wait_fence(struct drm_device *dev, void *data, struct drm_file *
|
||||||
|
file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_mga_private_t *dev_priv = dev->dev_private;
|
drm_mga_private_t *dev_priv = dev->dev_private;
|
||||||
u32 fence;
|
u32 *fence = data;
|
||||||
|
|
||||||
if (!dev_priv) {
|
if (!dev_priv) {
|
||||||
DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
|
DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(fence, (u32 __user *) data, sizeof(u32));
|
|
||||||
|
|
||||||
DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
|
DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
|
||||||
|
|
||||||
mga_driver_fence_wait(dev, &fence);
|
mga_driver_fence_wait(dev, fence);
|
||||||
|
|
||||||
if (DRM_COPY_TO_USER((u32 __user *) data, &fence, sizeof(u32))) {
|
|
||||||
DRM_ERROR("copy_to_user\n");
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
drm_ioctl_desc_t mga_ioctls[] = {
|
struct drm_ioctl_desc mga_ioctls[] = {
|
||||||
[DRM_IOCTL_NR(DRM_MGA_INIT)] = {mga_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_MGA_INIT, mga_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_MGA_FLUSH)] = {mga_dma_flush, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_MGA_FLUSH, mga_dma_flush, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_MGA_RESET)] = {mga_dma_reset, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_MGA_RESET, mga_dma_reset, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_MGA_SWAP)] = {mga_dma_swap, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_MGA_SWAP, mga_dma_swap, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_MGA_CLEAR)] = {mga_dma_clear, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_MGA_CLEAR, mga_dma_clear, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_MGA_VERTEX)] = {mga_dma_vertex, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_MGA_VERTEX, mga_dma_vertex, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_MGA_INDICES)] = {mga_dma_indices, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_MGA_INDICES, mga_dma_indices, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_MGA_ILOAD)] = {mga_dma_iload, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_MGA_ILOAD, mga_dma_iload, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_MGA_BLIT)] = {mga_dma_blit, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_MGA_BLIT, mga_dma_blit, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_MGA_GETPARAM)] = {mga_getparam, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_MGA_GETPARAM, mga_getparam, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_MGA_SET_FENCE)] = {mga_set_fence, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_MGA_SET_FENCE, mga_set_fence, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_MGA_WAIT_FENCE)] = {mga_wait_fence, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_MGA_WAIT_FENCE, mga_wait_fence, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_MGA_DMA_BOOTSTRAP)] = {mga_dma_bootstrap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(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);
|
||||||
|
|
|
@ -625,21 +625,17 @@ int r128_do_cleanup_cce(struct drm_device * dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int r128_cce_init(DRM_IOCTL_ARGS)
|
int r128_cce_init(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
drm_r128_init_t *init = data;
|
||||||
drm_r128_init_t init;
|
|
||||||
|
|
||||||
DRM_DEBUG("\n");
|
DRM_DEBUG("\n");
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(init, (drm_r128_init_t __user *) data,
|
switch (init->func) {
|
||||||
sizeof(init));
|
|
||||||
|
|
||||||
switch (init.func) {
|
|
||||||
case R128_INIT_CCE:
|
case R128_INIT_CCE:
|
||||||
return r128_do_init_cce(dev, &init);
|
return r128_do_init_cce(dev, init);
|
||||||
case R128_CLEANUP_CCE:
|
case R128_CLEANUP_CCE:
|
||||||
return r128_do_cleanup_cce(dev);
|
return r128_do_cleanup_cce(dev);
|
||||||
}
|
}
|
||||||
|
@ -647,9 +643,8 @@ int r128_cce_init(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int r128_cce_start(DRM_IOCTL_ARGS)
|
int r128_cce_start(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_r128_private_t *dev_priv = dev->dev_private;
|
drm_r128_private_t *dev_priv = dev->dev_private;
|
||||||
DRM_DEBUG("\n");
|
DRM_DEBUG("\n");
|
||||||
|
|
||||||
|
@ -668,30 +663,26 @@ int r128_cce_start(DRM_IOCTL_ARGS)
|
||||||
/* Stop the CCE. The engine must have been idled before calling this
|
/* Stop the CCE. The engine must have been idled before calling this
|
||||||
* routine.
|
* routine.
|
||||||
*/
|
*/
|
||||||
int r128_cce_stop(DRM_IOCTL_ARGS)
|
int r128_cce_stop(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_r128_private_t *dev_priv = dev->dev_private;
|
drm_r128_private_t *dev_priv = dev->dev_private;
|
||||||
drm_r128_cce_stop_t stop;
|
drm_r128_cce_stop_t *stop = data;
|
||||||
int ret;
|
int ret;
|
||||||
DRM_DEBUG("\n");
|
DRM_DEBUG("\n");
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(stop, (drm_r128_cce_stop_t __user *) data,
|
|
||||||
sizeof(stop));
|
|
||||||
|
|
||||||
/* Flush any pending CCE commands. This ensures any outstanding
|
/* Flush any pending CCE commands. This ensures any outstanding
|
||||||
* commands are exectuted by the engine before we turn it off.
|
* commands are exectuted by the engine before we turn it off.
|
||||||
*/
|
*/
|
||||||
if (stop.flush) {
|
if (stop->flush) {
|
||||||
r128_do_cce_flush(dev_priv);
|
r128_do_cce_flush(dev_priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we fail to make the engine go idle, we return an error
|
/* If we fail to make the engine go idle, we return an error
|
||||||
* code so that the DRM ioctl wrapper can try again.
|
* code so that the DRM ioctl wrapper can try again.
|
||||||
*/
|
*/
|
||||||
if (stop.idle) {
|
if (stop->idle) {
|
||||||
ret = r128_do_cce_idle(dev_priv);
|
ret = r128_do_cce_idle(dev_priv);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -711,9 +702,8 @@ int r128_cce_stop(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
/* Just reset the CCE ring. Called as part of an X Server engine reset.
|
/* Just reset the CCE ring. Called as part of an X Server engine reset.
|
||||||
*/
|
*/
|
||||||
int r128_cce_reset(DRM_IOCTL_ARGS)
|
int r128_cce_reset(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_r128_private_t *dev_priv = dev->dev_private;
|
drm_r128_private_t *dev_priv = dev->dev_private;
|
||||||
DRM_DEBUG("\n");
|
DRM_DEBUG("\n");
|
||||||
|
|
||||||
|
@ -732,9 +722,8 @@ int r128_cce_reset(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int r128_cce_idle(DRM_IOCTL_ARGS)
|
int r128_cce_idle(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_r128_private_t *dev_priv = dev->dev_private;
|
drm_r128_private_t *dev_priv = dev->dev_private;
|
||||||
DRM_DEBUG("\n");
|
DRM_DEBUG("\n");
|
||||||
|
|
||||||
|
@ -747,9 +736,8 @@ int r128_cce_idle(DRM_IOCTL_ARGS)
|
||||||
return r128_do_cce_idle(dev_priv);
|
return r128_do_cce_idle(dev_priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
int r128_engine_reset(DRM_IOCTL_ARGS)
|
int r128_engine_reset(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
DRM_DEBUG("\n");
|
DRM_DEBUG("\n");
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
@ -757,7 +745,7 @@ int r128_engine_reset(DRM_IOCTL_ARGS)
|
||||||
return r128_do_engine_reset(dev);
|
return r128_do_engine_reset(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
int r128_fullscreen(DRM_IOCTL_ARGS)
|
int r128_fullscreen(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -912,41 +900,35 @@ static int r128_cce_get_buffers(struct drm_device * dev,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int r128_cce_buffers(DRM_IOCTL_ARGS)
|
int r128_cce_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct drm_dma __user *argp = (void __user *)data;
|
struct drm_dma *d = data;
|
||||||
struct drm_dma d;
|
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(d, argp, sizeof(d));
|
|
||||||
|
|
||||||
/* Please don't send us buffers.
|
/* Please don't send us buffers.
|
||||||
*/
|
*/
|
||||||
if (d.send_count != 0) {
|
if (d->send_count != 0) {
|
||||||
DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n",
|
DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n",
|
||||||
DRM_CURRENTPID, d.send_count);
|
DRM_CURRENTPID, d->send_count);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We'll send you buffers.
|
/* We'll send you buffers.
|
||||||
*/
|
*/
|
||||||
if (d.request_count < 0 || d.request_count > dma->buf_count) {
|
if (d->request_count < 0 || d->request_count > dma->buf_count) {
|
||||||
DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n",
|
DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n",
|
||||||
DRM_CURRENTPID, d.request_count, dma->buf_count);
|
DRM_CURRENTPID, d->request_count, dma->buf_count);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
d.granted_count = 0;
|
d->granted_count = 0;
|
||||||
|
|
||||||
if (d.request_count) {
|
if (d->request_count) {
|
||||||
ret = r128_cce_get_buffers(dev, file_priv, &d);
|
ret = r128_cce_get_buffers(dev, file_priv, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_TO_USER_IOCTL(argp, d, sizeof(d));
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,18 +129,18 @@ typedef struct drm_r128_buf_priv {
|
||||||
drm_r128_freelist_t *list_entry;
|
drm_r128_freelist_t *list_entry;
|
||||||
} drm_r128_buf_priv_t;
|
} drm_r128_buf_priv_t;
|
||||||
|
|
||||||
extern drm_ioctl_desc_t r128_ioctls[];
|
extern struct drm_ioctl_desc r128_ioctls[];
|
||||||
extern int r128_max_ioctl;
|
extern int r128_max_ioctl;
|
||||||
|
|
||||||
/* r128_cce.c */
|
/* r128_cce.c */
|
||||||
extern int r128_cce_init(DRM_IOCTL_ARGS);
|
extern int r128_cce_init(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int r128_cce_start(DRM_IOCTL_ARGS);
|
extern int r128_cce_start(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int r128_cce_stop(DRM_IOCTL_ARGS);
|
extern int r128_cce_stop(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int r128_cce_reset(DRM_IOCTL_ARGS);
|
extern int r128_cce_reset(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int r128_cce_idle(DRM_IOCTL_ARGS);
|
extern int r128_cce_idle(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int r128_engine_reset(DRM_IOCTL_ARGS);
|
extern int r128_engine_reset(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int r128_fullscreen(DRM_IOCTL_ARGS);
|
extern int r128_fullscreen(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int r128_cce_buffers(DRM_IOCTL_ARGS);
|
extern int r128_cce_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
|
|
||||||
extern void r128_freelist_reset(struct drm_device * dev);
|
extern void r128_freelist_reset(struct drm_device * dev);
|
||||||
|
|
||||||
|
|
|
@ -1242,25 +1242,21 @@ static void r128_cce_dispatch_stipple(struct drm_device * dev, u32 * stipple)
|
||||||
* IOCTL functions
|
* IOCTL functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int r128_cce_clear(DRM_IOCTL_ARGS)
|
static int r128_cce_clear(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_r128_private_t *dev_priv = dev->dev_private;
|
drm_r128_private_t *dev_priv = dev->dev_private;
|
||||||
drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
||||||
drm_r128_clear_t clear;
|
drm_r128_clear_t *clear = data;
|
||||||
DRM_DEBUG("\n");
|
DRM_DEBUG("\n");
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(clear, (drm_r128_clear_t __user *) data,
|
|
||||||
sizeof(clear));
|
|
||||||
|
|
||||||
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
||||||
|
|
||||||
if (sarea_priv->nbox > R128_NR_SAREA_CLIPRECTS)
|
if (sarea_priv->nbox > R128_NR_SAREA_CLIPRECTS)
|
||||||
sarea_priv->nbox = R128_NR_SAREA_CLIPRECTS;
|
sarea_priv->nbox = R128_NR_SAREA_CLIPRECTS;
|
||||||
|
|
||||||
r128_cce_dispatch_clear(dev, &clear);
|
r128_cce_dispatch_clear(dev, clear);
|
||||||
COMMIT_RING();
|
COMMIT_RING();
|
||||||
|
|
||||||
/* Make sure we restore the 3D state next time.
|
/* Make sure we restore the 3D state next time.
|
||||||
|
@ -1310,9 +1306,8 @@ static int r128_do_cleanup_pageflip(struct drm_device * dev)
|
||||||
* They can & should be intermixed to support multiple 3d windows.
|
* They can & should be intermixed to support multiple 3d windows.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int r128_cce_flip(DRM_IOCTL_ARGS)
|
static int r128_cce_flip(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_r128_private_t *dev_priv = dev->dev_private;
|
drm_r128_private_t *dev_priv = dev->dev_private;
|
||||||
DRM_DEBUG("%s\n", __FUNCTION__);
|
DRM_DEBUG("%s\n", __FUNCTION__);
|
||||||
|
|
||||||
|
@ -1329,9 +1324,8 @@ static int r128_cce_flip(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int r128_cce_swap(DRM_IOCTL_ARGS)
|
static int r128_cce_swap(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_r128_private_t *dev_priv = dev->dev_private;
|
drm_r128_private_t *dev_priv = dev->dev_private;
|
||||||
drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
||||||
DRM_DEBUG("%s\n", __FUNCTION__);
|
DRM_DEBUG("%s\n", __FUNCTION__);
|
||||||
|
@ -1351,14 +1345,13 @@ static int r128_cce_swap(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int r128_cce_vertex(DRM_IOCTL_ARGS)
|
static int r128_cce_vertex(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_r128_private_t *dev_priv = dev->dev_private;
|
drm_r128_private_t *dev_priv = dev->dev_private;
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
struct drm_buf *buf;
|
struct drm_buf *buf;
|
||||||
drm_r128_buf_priv_t *buf_priv;
|
drm_r128_buf_priv_t *buf_priv;
|
||||||
drm_r128_vertex_t vertex;
|
drm_r128_vertex_t *vertex = data;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
|
@ -1367,27 +1360,24 @@ static int r128_cce_vertex(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(vertex, (drm_r128_vertex_t __user *) data,
|
|
||||||
sizeof(vertex));
|
|
||||||
|
|
||||||
DRM_DEBUG("pid=%d index=%d count=%d discard=%d\n",
|
DRM_DEBUG("pid=%d index=%d count=%d discard=%d\n",
|
||||||
DRM_CURRENTPID, vertex.idx, vertex.count, vertex.discard);
|
DRM_CURRENTPID, vertex->idx, vertex->count, vertex->discard);
|
||||||
|
|
||||||
if (vertex.idx < 0 || vertex.idx >= dma->buf_count) {
|
if (vertex->idx < 0 || vertex->idx >= dma->buf_count) {
|
||||||
DRM_ERROR("buffer index %d (of %d max)\n",
|
DRM_ERROR("buffer index %d (of %d max)\n",
|
||||||
vertex.idx, dma->buf_count - 1);
|
vertex->idx, dma->buf_count - 1);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (vertex.prim < 0 ||
|
if (vertex->prim < 0 ||
|
||||||
vertex.prim > R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2) {
|
vertex->prim > R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2) {
|
||||||
DRM_ERROR("buffer prim %d\n", vertex.prim);
|
DRM_ERROR("buffer prim %d\n", vertex->prim);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
||||||
VB_AGE_TEST_WITH_RETURN(dev_priv);
|
VB_AGE_TEST_WITH_RETURN(dev_priv);
|
||||||
|
|
||||||
buf = dma->buflist[vertex.idx];
|
buf = dma->buflist[vertex->idx];
|
||||||
buf_priv = buf->dev_private;
|
buf_priv = buf->dev_private;
|
||||||
|
|
||||||
if (buf->file_priv != file_priv) {
|
if (buf->file_priv != file_priv) {
|
||||||
|
@ -1396,13 +1386,13 @@ static int r128_cce_vertex(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (buf->pending) {
|
if (buf->pending) {
|
||||||
DRM_ERROR("sending pending buffer %d\n", vertex.idx);
|
DRM_ERROR("sending pending buffer %d\n", vertex->idx);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf->used = vertex.count;
|
buf->used = vertex->count;
|
||||||
buf_priv->prim = vertex.prim;
|
buf_priv->prim = vertex->prim;
|
||||||
buf_priv->discard = vertex.discard;
|
buf_priv->discard = vertex->discard;
|
||||||
|
|
||||||
r128_cce_dispatch_vertex(dev, buf);
|
r128_cce_dispatch_vertex(dev, buf);
|
||||||
|
|
||||||
|
@ -1410,14 +1400,13 @@ static int r128_cce_vertex(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int r128_cce_indices(DRM_IOCTL_ARGS)
|
static int r128_cce_indices(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_r128_private_t *dev_priv = dev->dev_private;
|
drm_r128_private_t *dev_priv = dev->dev_private;
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
struct drm_buf *buf;
|
struct drm_buf *buf;
|
||||||
drm_r128_buf_priv_t *buf_priv;
|
drm_r128_buf_priv_t *buf_priv;
|
||||||
drm_r128_indices_t elts;
|
drm_r128_indices_t *elts = data;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
@ -1427,26 +1416,24 @@ static int r128_cce_indices(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(elts, (drm_r128_indices_t __user *) data,
|
|
||||||
sizeof(elts));
|
|
||||||
|
|
||||||
DRM_DEBUG("pid=%d buf=%d s=%d e=%d d=%d\n", DRM_CURRENTPID,
|
DRM_DEBUG("pid=%d buf=%d s=%d e=%d d=%d\n", DRM_CURRENTPID,
|
||||||
elts.idx, elts.start, elts.end, elts.discard);
|
elts->idx, elts->start, elts->end, elts->discard);
|
||||||
|
|
||||||
if (elts.idx < 0 || elts.idx >= dma->buf_count) {
|
if (elts->idx < 0 || elts->idx >= dma->buf_count) {
|
||||||
DRM_ERROR("buffer index %d (of %d max)\n",
|
DRM_ERROR("buffer index %d (of %d max)\n",
|
||||||
elts.idx, dma->buf_count - 1);
|
elts->idx, dma->buf_count - 1);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (elts.prim < 0 || elts.prim > R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2) {
|
if (elts->prim < 0 ||
|
||||||
DRM_ERROR("buffer prim %d\n", elts.prim);
|
elts->prim > R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2) {
|
||||||
|
DRM_ERROR("buffer prim %d\n", elts->prim);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
||||||
VB_AGE_TEST_WITH_RETURN(dev_priv);
|
VB_AGE_TEST_WITH_RETURN(dev_priv);
|
||||||
|
|
||||||
buf = dma->buflist[elts.idx];
|
buf = dma->buflist[elts->idx];
|
||||||
buf_priv = buf->dev_private;
|
buf_priv = buf->dev_private;
|
||||||
|
|
||||||
if (buf->file_priv != file_priv) {
|
if (buf->file_priv != file_priv) {
|
||||||
|
@ -1455,89 +1442,81 @@ static int r128_cce_indices(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (buf->pending) {
|
if (buf->pending) {
|
||||||
DRM_ERROR("sending pending buffer %d\n", elts.idx);
|
DRM_ERROR("sending pending buffer %d\n", elts->idx);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
count = (elts.end - elts.start) / sizeof(u16);
|
count = (elts->end - elts->start) / sizeof(u16);
|
||||||
elts.start -= R128_INDEX_PRIM_OFFSET;
|
elts->start -= R128_INDEX_PRIM_OFFSET;
|
||||||
|
|
||||||
if (elts.start & 0x7) {
|
if (elts->start & 0x7) {
|
||||||
DRM_ERROR("misaligned buffer 0x%x\n", elts.start);
|
DRM_ERROR("misaligned buffer 0x%x\n", elts->start);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (elts.start < buf->used) {
|
if (elts->start < buf->used) {
|
||||||
DRM_ERROR("no header 0x%x - 0x%x\n", elts.start, buf->used);
|
DRM_ERROR("no header 0x%x - 0x%x\n", elts->start, buf->used);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf->used = elts.end;
|
buf->used = elts->end;
|
||||||
buf_priv->prim = elts.prim;
|
buf_priv->prim = elts->prim;
|
||||||
buf_priv->discard = elts.discard;
|
buf_priv->discard = elts->discard;
|
||||||
|
|
||||||
r128_cce_dispatch_indices(dev, buf, elts.start, elts.end, count);
|
r128_cce_dispatch_indices(dev, buf, elts->start, elts->end, count);
|
||||||
|
|
||||||
COMMIT_RING();
|
COMMIT_RING();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int r128_cce_blit(DRM_IOCTL_ARGS)
|
static int r128_cce_blit(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
drm_r128_private_t *dev_priv = dev->dev_private;
|
drm_r128_private_t *dev_priv = dev->dev_private;
|
||||||
drm_r128_blit_t blit;
|
drm_r128_blit_t *blit = data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(blit, (drm_r128_blit_t __user *) data,
|
DRM_DEBUG("pid=%d index=%d\n", DRM_CURRENTPID, blit->idx);
|
||||||
sizeof(blit));
|
|
||||||
|
|
||||||
DRM_DEBUG("pid=%d index=%d\n", DRM_CURRENTPID, blit.idx);
|
if (blit->idx < 0 || blit->idx >= dma->buf_count) {
|
||||||
|
|
||||||
if (blit.idx < 0 || blit.idx >= dma->buf_count) {
|
|
||||||
DRM_ERROR("buffer index %d (of %d max)\n",
|
DRM_ERROR("buffer index %d (of %d max)\n",
|
||||||
blit.idx, dma->buf_count - 1);
|
blit->idx, dma->buf_count - 1);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
||||||
VB_AGE_TEST_WITH_RETURN(dev_priv);
|
VB_AGE_TEST_WITH_RETURN(dev_priv);
|
||||||
|
|
||||||
ret = r128_cce_dispatch_blit(dev, file_priv, &blit);
|
ret = r128_cce_dispatch_blit(dev, file_priv, blit);
|
||||||
|
|
||||||
COMMIT_RING();
|
COMMIT_RING();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int r128_cce_depth(DRM_IOCTL_ARGS)
|
static int r128_cce_depth(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_r128_private_t *dev_priv = dev->dev_private;
|
drm_r128_private_t *dev_priv = dev->dev_private;
|
||||||
drm_r128_depth_t depth;
|
drm_r128_depth_t *depth = data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(depth, (drm_r128_depth_t __user *) data,
|
|
||||||
sizeof(depth));
|
|
||||||
|
|
||||||
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
||||||
|
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
switch (depth.func) {
|
switch (depth->func) {
|
||||||
case R128_WRITE_SPAN:
|
case R128_WRITE_SPAN:
|
||||||
ret = r128_cce_dispatch_write_span(dev, &depth);
|
ret = r128_cce_dispatch_write_span(dev, depth);
|
||||||
break;
|
break;
|
||||||
case R128_WRITE_PIXELS:
|
case R128_WRITE_PIXELS:
|
||||||
ret = r128_cce_dispatch_write_pixels(dev, &depth);
|
ret = r128_cce_dispatch_write_pixels(dev, depth);
|
||||||
break;
|
break;
|
||||||
case R128_READ_SPAN:
|
case R128_READ_SPAN:
|
||||||
ret = r128_cce_dispatch_read_span(dev, &depth);
|
ret = r128_cce_dispatch_read_span(dev, depth);
|
||||||
break;
|
break;
|
||||||
case R128_READ_PIXELS:
|
case R128_READ_PIXELS:
|
||||||
ret = r128_cce_dispatch_read_pixels(dev, &depth);
|
ret = r128_cce_dispatch_read_pixels(dev, depth);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1545,19 +1524,15 @@ static int r128_cce_depth(DRM_IOCTL_ARGS)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int r128_cce_stipple(DRM_IOCTL_ARGS)
|
static int r128_cce_stipple(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_r128_private_t *dev_priv = dev->dev_private;
|
drm_r128_private_t *dev_priv = dev->dev_private;
|
||||||
drm_r128_stipple_t stipple;
|
drm_r128_stipple_t *stipple = data;
|
||||||
u32 mask[32];
|
u32 mask[32];
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(stipple, (drm_r128_stipple_t __user *) data,
|
if (DRM_COPY_FROM_USER(&mask, stipple->mask, 32 * sizeof(u32)))
|
||||||
sizeof(stipple));
|
|
||||||
|
|
||||||
if (DRM_COPY_FROM_USER(&mask, stipple.mask, 32 * sizeof(u32)))
|
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
||||||
|
@ -1568,14 +1543,13 @@ static int r128_cce_stipple(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int r128_cce_indirect(DRM_IOCTL_ARGS)
|
static int r128_cce_indirect(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_r128_private_t *dev_priv = dev->dev_private;
|
drm_r128_private_t *dev_priv = dev->dev_private;
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
struct drm_buf *buf;
|
struct drm_buf *buf;
|
||||||
drm_r128_buf_priv_t *buf_priv;
|
drm_r128_buf_priv_t *buf_priv;
|
||||||
drm_r128_indirect_t indirect;
|
drm_r128_indirect_t *indirect = data;
|
||||||
#if 0
|
#if 0
|
||||||
RING_LOCALS;
|
RING_LOCALS;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1587,19 +1561,17 @@ static int r128_cce_indirect(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(indirect, (drm_r128_indirect_t __user *) data,
|
|
||||||
sizeof(indirect));
|
|
||||||
|
|
||||||
DRM_DEBUG("indirect: idx=%d s=%d e=%d d=%d\n",
|
DRM_DEBUG("indirect: idx=%d s=%d e=%d d=%d\n",
|
||||||
indirect.idx, indirect.start, indirect.end, indirect.discard);
|
indirect->idx, indirect->start, indirect->end,
|
||||||
|
indirect->discard);
|
||||||
|
|
||||||
if (indirect.idx < 0 || indirect.idx >= dma->buf_count) {
|
if (indirect->idx < 0 || indirect->idx >= dma->buf_count) {
|
||||||
DRM_ERROR("buffer index %d (of %d max)\n",
|
DRM_ERROR("buffer index %d (of %d max)\n",
|
||||||
indirect.idx, dma->buf_count - 1);
|
indirect->idx, dma->buf_count - 1);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = dma->buflist[indirect.idx];
|
buf = dma->buflist[indirect->idx];
|
||||||
buf_priv = buf->dev_private;
|
buf_priv = buf->dev_private;
|
||||||
|
|
||||||
if (buf->file_priv != file_priv) {
|
if (buf->file_priv != file_priv) {
|
||||||
|
@ -1608,21 +1580,21 @@ static int r128_cce_indirect(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (buf->pending) {
|
if (buf->pending) {
|
||||||
DRM_ERROR("sending pending buffer %d\n", indirect.idx);
|
DRM_ERROR("sending pending buffer %d\n", indirect->idx);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (indirect.start < buf->used) {
|
if (indirect->start < buf->used) {
|
||||||
DRM_ERROR("reusing indirect: start=0x%x actual=0x%x\n",
|
DRM_ERROR("reusing indirect: start=0x%x actual=0x%x\n",
|
||||||
indirect.start, buf->used);
|
indirect->start, buf->used);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
||||||
VB_AGE_TEST_WITH_RETURN(dev_priv);
|
VB_AGE_TEST_WITH_RETURN(dev_priv);
|
||||||
|
|
||||||
buf->used = indirect.end;
|
buf->used = indirect->end;
|
||||||
buf_priv->discard = indirect.discard;
|
buf_priv->discard = indirect->discard;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* Wait for the 3D stream to idle before the indirect buffer
|
/* Wait for the 3D stream to idle before the indirect buffer
|
||||||
|
@ -1637,17 +1609,16 @@ static int r128_cce_indirect(DRM_IOCTL_ARGS)
|
||||||
* X server. This is insecure and is thus only available to
|
* X server. This is insecure and is thus only available to
|
||||||
* privileged clients.
|
* privileged clients.
|
||||||
*/
|
*/
|
||||||
r128_cce_dispatch_indirect(dev, buf, indirect.start, indirect.end);
|
r128_cce_dispatch_indirect(dev, buf, indirect->start, indirect->end);
|
||||||
|
|
||||||
COMMIT_RING();
|
COMMIT_RING();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int r128_getparam(DRM_IOCTL_ARGS)
|
static int r128_getparam(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_r128_private_t *dev_priv = dev->dev_private;
|
drm_r128_private_t *dev_priv = dev->dev_private;
|
||||||
drm_r128_getparam_t param;
|
drm_r128_getparam_t *param = data;
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
if (!dev_priv) {
|
if (!dev_priv) {
|
||||||
|
@ -1655,12 +1626,9 @@ static int r128_getparam(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(param, (drm_r128_getparam_t __user *) data,
|
|
||||||
sizeof(param));
|
|
||||||
|
|
||||||
DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
|
DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
|
||||||
|
|
||||||
switch (param.param) {
|
switch (param->param) {
|
||||||
case R128_PARAM_IRQ_NR:
|
case R128_PARAM_IRQ_NR:
|
||||||
value = dev->irq;
|
value = dev->irq;
|
||||||
break;
|
break;
|
||||||
|
@ -1668,7 +1636,7 @@ static int r128_getparam(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DRM_COPY_TO_USER(param.value, &value, sizeof(int))) {
|
if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) {
|
||||||
DRM_ERROR("copy_to_user\n");
|
DRM_ERROR("copy_to_user\n");
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
@ -1691,24 +1659,24 @@ void r128_driver_lastclose(struct drm_device * dev)
|
||||||
r128_do_cleanup_cce(dev);
|
r128_do_cleanup_cce(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
drm_ioctl_desc_t r128_ioctls[] = {
|
struct drm_ioctl_desc r128_ioctls[] = {
|
||||||
[DRM_IOCTL_NR(DRM_R128_INIT)] = {r128_cce_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_R128_INIT, r128_cce_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_R128_CCE_START)] = {r128_cce_start, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_R128_CCE_START, r128_cce_start, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_R128_CCE_STOP)] = {r128_cce_stop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_R128_CCE_STOP, r128_cce_stop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_R128_CCE_RESET)] = {r128_cce_reset, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_R128_CCE_RESET, r128_cce_reset, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_R128_CCE_IDLE)] = {r128_cce_idle, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_R128_CCE_IDLE, r128_cce_idle, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_R128_RESET)] = {r128_engine_reset, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_R128_RESET, r128_engine_reset, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_R128_FULLSCREEN)] = {r128_fullscreen, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_R128_FULLSCREEN, r128_fullscreen, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_R128_SWAP)] = {r128_cce_swap, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_R128_SWAP, r128_cce_swap, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_R128_FLIP)] = {r128_cce_flip, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_R128_FLIP, r128_cce_flip, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_R128_CLEAR)] = {r128_cce_clear, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_R128_CLEAR, r128_cce_clear, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_R128_VERTEX)] = {r128_cce_vertex, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_R128_VERTEX, r128_cce_vertex, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_R128_INDICES)] = {r128_cce_indices, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_R128_INDICES, r128_cce_indices, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_R128_BLIT)] = {r128_cce_blit, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_R128_BLIT, r128_cce_blit, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_R128_DEPTH)] = {r128_cce_depth, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_R128_DEPTH, r128_cce_depth, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_R128_STIPPLE)] = {r128_cce_stipple, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_R128_STIPPLE, r128_cce_stipple, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_R128_INDIRECT)] = {r128_cce_indirect, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_R128_INDIRECT, r128_cce_indirect, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_R128_GETPARAM)] = {r128_getparam, DRM_AUTH},
|
DRM_IOCTL_DEF(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);
|
||||||
|
|
|
@ -1823,24 +1823,20 @@ static int radeon_do_resume_cp(struct drm_device * dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int radeon_cp_init(DRM_IOCTL_ARGS)
|
int radeon_cp_init(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
drm_radeon_init_t *init = data;
|
||||||
drm_radeon_init_t init;
|
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(init, (drm_radeon_init_t __user *) data,
|
if (init->func == RADEON_INIT_R300_CP)
|
||||||
sizeof(init));
|
|
||||||
|
|
||||||
if (init.func == RADEON_INIT_R300_CP)
|
|
||||||
r300_init_reg_flags();
|
r300_init_reg_flags();
|
||||||
|
|
||||||
switch (init.func) {
|
switch (init->func) {
|
||||||
case RADEON_INIT_CP:
|
case RADEON_INIT_CP:
|
||||||
case RADEON_INIT_R200_CP:
|
case RADEON_INIT_R200_CP:
|
||||||
case RADEON_INIT_R300_CP:
|
case RADEON_INIT_R300_CP:
|
||||||
return radeon_do_init_cp(dev, &init);
|
return radeon_do_init_cp(dev, init);
|
||||||
case RADEON_CLEANUP_CP:
|
case RADEON_CLEANUP_CP:
|
||||||
return radeon_do_cleanup_cp(dev);
|
return radeon_do_cleanup_cp(dev);
|
||||||
}
|
}
|
||||||
|
@ -1848,9 +1844,8 @@ int radeon_cp_init(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int radeon_cp_start(DRM_IOCTL_ARGS)
|
int radeon_cp_start(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
DRM_DEBUG("\n");
|
DRM_DEBUG("\n");
|
||||||
|
|
||||||
|
@ -1874,33 +1869,29 @@ int radeon_cp_start(DRM_IOCTL_ARGS)
|
||||||
/* Stop the CP. The engine must have been idled before calling this
|
/* Stop the CP. The engine must have been idled before calling this
|
||||||
* routine.
|
* routine.
|
||||||
*/
|
*/
|
||||||
int radeon_cp_stop(DRM_IOCTL_ARGS)
|
int radeon_cp_stop(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
drm_radeon_cp_stop_t stop;
|
drm_radeon_cp_stop_t *stop = data;
|
||||||
int ret;
|
int ret;
|
||||||
DRM_DEBUG("\n");
|
DRM_DEBUG("\n");
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(stop, (drm_radeon_cp_stop_t __user *) data,
|
|
||||||
sizeof(stop));
|
|
||||||
|
|
||||||
if (!dev_priv->cp_running)
|
if (!dev_priv->cp_running)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Flush any pending CP commands. This ensures any outstanding
|
/* Flush any pending CP commands. This ensures any outstanding
|
||||||
* commands are exectuted by the engine before we turn it off.
|
* commands are exectuted by the engine before we turn it off.
|
||||||
*/
|
*/
|
||||||
if (stop.flush) {
|
if (stop->flush) {
|
||||||
radeon_do_cp_flush(dev_priv);
|
radeon_do_cp_flush(dev_priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we fail to make the engine go idle, we return an error
|
/* If we fail to make the engine go idle, we return an error
|
||||||
* code so that the DRM ioctl wrapper can try again.
|
* code so that the DRM ioctl wrapper can try again.
|
||||||
*/
|
*/
|
||||||
if (stop.idle) {
|
if (stop->idle) {
|
||||||
ret = radeon_do_cp_idle(dev_priv);
|
ret = radeon_do_cp_idle(dev_priv);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1963,9 +1954,8 @@ void radeon_do_release(struct drm_device * dev)
|
||||||
|
|
||||||
/* Just reset the CP ring. Called as part of an X Server engine reset.
|
/* Just reset the CP ring. Called as part of an X Server engine reset.
|
||||||
*/
|
*/
|
||||||
int radeon_cp_reset(DRM_IOCTL_ARGS)
|
int radeon_cp_reset(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
DRM_DEBUG("\n");
|
DRM_DEBUG("\n");
|
||||||
|
|
||||||
|
@ -1984,9 +1974,8 @@ int radeon_cp_reset(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int radeon_cp_idle(DRM_IOCTL_ARGS)
|
int radeon_cp_idle(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
DRM_DEBUG("\n");
|
DRM_DEBUG("\n");
|
||||||
|
|
||||||
|
@ -1997,16 +1986,14 @@ int radeon_cp_idle(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
/* Added by Charl P. Botha to call radeon_do_resume_cp().
|
/* Added by Charl P. Botha to call radeon_do_resume_cp().
|
||||||
*/
|
*/
|
||||||
int radeon_cp_resume(DRM_IOCTL_ARGS)
|
int radeon_cp_resume(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
|
|
||||||
return radeon_do_resume_cp(dev);
|
return radeon_do_resume_cp(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
int radeon_engine_reset(DRM_IOCTL_ARGS)
|
int radeon_engine_reset(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
DRM_DEBUG("\n");
|
DRM_DEBUG("\n");
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
@ -2020,7 +2007,7 @@ int radeon_engine_reset(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
/* KW: Deprecated to say the least:
|
/* KW: Deprecated to say the least:
|
||||||
*/
|
*/
|
||||||
int radeon_fullscreen(DRM_IOCTL_ARGS)
|
int radeon_fullscreen(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2198,42 +2185,36 @@ static int radeon_cp_get_buffers(struct drm_device *dev,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int radeon_cp_buffers(DRM_IOCTL_ARGS)
|
int radeon_cp_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct drm_dma __user *argp = (void __user *)data;
|
struct drm_dma *d = data;
|
||||||
struct drm_dma d;
|
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(d, argp, sizeof(d));
|
|
||||||
|
|
||||||
/* Please don't send us buffers.
|
/* Please don't send us buffers.
|
||||||
*/
|
*/
|
||||||
if (d.send_count != 0) {
|
if (d->send_count != 0) {
|
||||||
DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n",
|
DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n",
|
||||||
DRM_CURRENTPID, d.send_count);
|
DRM_CURRENTPID, d->send_count);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We'll send you buffers.
|
/* We'll send you buffers.
|
||||||
*/
|
*/
|
||||||
if (d.request_count < 0 || d.request_count > dma->buf_count) {
|
if (d->request_count < 0 || d->request_count > dma->buf_count) {
|
||||||
DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n",
|
DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n",
|
||||||
DRM_CURRENTPID, d.request_count, dma->buf_count);
|
DRM_CURRENTPID, d->request_count, dma->buf_count);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
d.granted_count = 0;
|
d->granted_count = 0;
|
||||||
|
|
||||||
if (d.request_count) {
|
if (d->request_count) {
|
||||||
ret = radeon_cp_get_buffers(dev, file_priv, &d);
|
ret = radeon_cp_get_buffers(dev, file_priv, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_TO_USER_IOCTL(argp, d, sizeof(d));
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -307,7 +307,7 @@ typedef struct drm_radeon_kcmd_buffer {
|
||||||
} drm_radeon_kcmd_buffer_t;
|
} drm_radeon_kcmd_buffer_t;
|
||||||
|
|
||||||
extern int radeon_no_wb;
|
extern int radeon_no_wb;
|
||||||
extern drm_ioctl_desc_t radeon_ioctls[];
|
extern struct drm_ioctl_desc radeon_ioctls[];
|
||||||
extern int radeon_max_ioctl;
|
extern int radeon_max_ioctl;
|
||||||
|
|
||||||
/* Check whether the given hardware address is inside the framebuffer or the
|
/* Check whether the given hardware address is inside the framebuffer or the
|
||||||
|
@ -326,15 +326,15 @@ static __inline__ int radeon_check_offset(drm_radeon_private_t *dev_priv,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* radeon_cp.c */
|
/* radeon_cp.c */
|
||||||
extern int radeon_cp_init(DRM_IOCTL_ARGS);
|
extern int radeon_cp_init(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int radeon_cp_start(DRM_IOCTL_ARGS);
|
extern int radeon_cp_start(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int radeon_cp_stop(DRM_IOCTL_ARGS);
|
extern int radeon_cp_stop(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int radeon_cp_reset(DRM_IOCTL_ARGS);
|
extern int radeon_cp_reset(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int radeon_cp_idle(DRM_IOCTL_ARGS);
|
extern int radeon_cp_idle(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int radeon_cp_resume(DRM_IOCTL_ARGS);
|
extern int radeon_cp_resume(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int radeon_engine_reset(DRM_IOCTL_ARGS);
|
extern int radeon_engine_reset(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int radeon_fullscreen(DRM_IOCTL_ARGS);
|
extern int radeon_fullscreen(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int radeon_cp_buffers(DRM_IOCTL_ARGS);
|
extern int radeon_cp_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
|
|
||||||
extern void radeon_freelist_reset(struct drm_device * dev);
|
extern void radeon_freelist_reset(struct drm_device * dev);
|
||||||
extern struct drm_buf *radeon_freelist_get(struct drm_device * dev);
|
extern struct drm_buf *radeon_freelist_get(struct drm_device * dev);
|
||||||
|
@ -347,16 +347,16 @@ extern int radeon_driver_preinit(struct drm_device *dev, unsigned long flags);
|
||||||
extern int radeon_presetup(struct drm_device *dev);
|
extern int radeon_presetup(struct drm_device *dev);
|
||||||
extern int radeon_driver_postcleanup(struct drm_device *dev);
|
extern int radeon_driver_postcleanup(struct drm_device *dev);
|
||||||
|
|
||||||
extern int radeon_mem_alloc(DRM_IOCTL_ARGS);
|
extern int radeon_mem_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int radeon_mem_free(DRM_IOCTL_ARGS);
|
extern int radeon_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int radeon_mem_init_heap(DRM_IOCTL_ARGS);
|
extern int radeon_mem_init_heap(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern void radeon_mem_takedown(struct mem_block **heap);
|
extern void radeon_mem_takedown(struct mem_block **heap);
|
||||||
extern void radeon_mem_release(struct drm_file *file_priv,
|
extern void radeon_mem_release(struct drm_file *file_priv,
|
||||||
struct mem_block *heap);
|
struct mem_block *heap);
|
||||||
|
|
||||||
/* radeon_irq.c */
|
/* radeon_irq.c */
|
||||||
extern int radeon_irq_emit(DRM_IOCTL_ARGS);
|
extern int radeon_irq_emit(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int radeon_irq_wait(DRM_IOCTL_ARGS);
|
extern int radeon_irq_wait(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
|
|
||||||
extern void radeon_do_release(struct drm_device * dev);
|
extern void radeon_do_release(struct drm_device * dev);
|
||||||
extern int radeon_driver_vblank_wait(struct drm_device * dev,
|
extern int radeon_driver_vblank_wait(struct drm_device * dev,
|
||||||
|
|
|
@ -196,11 +196,10 @@ int radeon_driver_vblank_wait2(struct drm_device *dev, unsigned int *sequence)
|
||||||
|
|
||||||
/* Needs the lock as it touches the ring.
|
/* Needs the lock as it touches the ring.
|
||||||
*/
|
*/
|
||||||
int radeon_irq_emit(DRM_IOCTL_ARGS)
|
int radeon_irq_emit(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
drm_radeon_irq_emit_t emit;
|
drm_radeon_irq_emit_t *emit = data;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
@ -210,12 +209,9 @@ int radeon_irq_emit(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(emit, (drm_radeon_irq_emit_t __user *) data,
|
|
||||||
sizeof(emit));
|
|
||||||
|
|
||||||
result = radeon_emit_irq(dev);
|
result = radeon_emit_irq(dev);
|
||||||
|
|
||||||
if (DRM_COPY_TO_USER(emit.irq_seq, &result, sizeof(int))) {
|
if (DRM_COPY_TO_USER(emit->irq_seq, &result, sizeof(int))) {
|
||||||
DRM_ERROR("copy_to_user\n");
|
DRM_ERROR("copy_to_user\n");
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
@ -225,21 +221,17 @@ int radeon_irq_emit(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
/* Doesn't need the hardware lock.
|
/* Doesn't need the hardware lock.
|
||||||
*/
|
*/
|
||||||
int radeon_irq_wait(DRM_IOCTL_ARGS)
|
int radeon_irq_wait(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
drm_radeon_irq_wait_t irqwait;
|
drm_radeon_irq_wait_t *irqwait = data;
|
||||||
|
|
||||||
if (!dev_priv) {
|
if (!dev_priv) {
|
||||||
DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
|
DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(irqwait, (drm_radeon_irq_wait_t __user *) data,
|
return radeon_wait_irq(dev, irqwait->irq_seq);
|
||||||
sizeof(irqwait));
|
|
||||||
|
|
||||||
return radeon_wait_irq(dev, irqwait.irq_seq);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void radeon_enable_interrupt(struct drm_device *dev)
|
static void radeon_enable_interrupt(struct drm_device *dev)
|
||||||
|
|
|
@ -217,11 +217,10 @@ static struct mem_block **get_heap(drm_radeon_private_t * dev_priv, int region)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int radeon_mem_alloc(DRM_IOCTL_ARGS)
|
int radeon_mem_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
drm_radeon_mem_alloc_t alloc;
|
drm_radeon_mem_alloc_t *alloc = data;
|
||||||
struct mem_block *block, **heap;
|
struct mem_block *block, **heap;
|
||||||
|
|
||||||
if (!dev_priv) {
|
if (!dev_priv) {
|
||||||
|
@ -229,25 +228,23 @@ int radeon_mem_alloc(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(alloc, (drm_radeon_mem_alloc_t __user *) data,
|
heap = get_heap(dev_priv, alloc->region);
|
||||||
sizeof(alloc));
|
|
||||||
|
|
||||||
heap = get_heap(dev_priv, alloc.region);
|
|
||||||
if (!heap || !*heap)
|
if (!heap || !*heap)
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
/* Make things easier on ourselves: all allocations at least
|
/* Make things easier on ourselves: all allocations at least
|
||||||
* 4k aligned.
|
* 4k aligned.
|
||||||
*/
|
*/
|
||||||
if (alloc.alignment < 12)
|
if (alloc->alignment < 12)
|
||||||
alloc.alignment = 12;
|
alloc->alignment = 12;
|
||||||
|
|
||||||
block = alloc_block(*heap, alloc.size, alloc.alignment, file_priv);
|
block = alloc_block(*heap, alloc->size, alloc->alignment, file_priv);
|
||||||
|
|
||||||
if (!block)
|
if (!block)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if (DRM_COPY_TO_USER(alloc.region_offset, &block->start, sizeof(int))) {
|
if (DRM_COPY_TO_USER(alloc->region_offset, &block->start,
|
||||||
|
sizeof(int))) {
|
||||||
DRM_ERROR("copy_to_user\n");
|
DRM_ERROR("copy_to_user\n");
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
@ -255,11 +252,10 @@ int radeon_mem_alloc(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int radeon_mem_free(DRM_IOCTL_ARGS)
|
int radeon_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
drm_radeon_mem_free_t memfree;
|
drm_radeon_mem_free_t *memfree = data;
|
||||||
struct mem_block *block, **heap;
|
struct mem_block *block, **heap;
|
||||||
|
|
||||||
if (!dev_priv) {
|
if (!dev_priv) {
|
||||||
|
@ -267,14 +263,11 @@ int radeon_mem_free(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(memfree, (drm_radeon_mem_free_t __user *) data,
|
heap = get_heap(dev_priv, memfree->region);
|
||||||
sizeof(memfree));
|
|
||||||
|
|
||||||
heap = get_heap(dev_priv, memfree.region);
|
|
||||||
if (!heap || !*heap)
|
if (!heap || !*heap)
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
block = find_block(*heap, memfree.region_offset);
|
block = find_block(*heap, memfree->region_offset);
|
||||||
if (!block)
|
if (!block)
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
|
@ -285,11 +278,10 @@ int radeon_mem_free(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int radeon_mem_init_heap(DRM_IOCTL_ARGS)
|
int radeon_mem_init_heap(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
drm_radeon_mem_init_heap_t initheap;
|
drm_radeon_mem_init_heap_t *initheap = data;
|
||||||
struct mem_block **heap;
|
struct mem_block **heap;
|
||||||
|
|
||||||
if (!dev_priv) {
|
if (!dev_priv) {
|
||||||
|
@ -297,11 +289,7 @@ int radeon_mem_init_heap(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(initheap,
|
heap = get_heap(dev_priv, initheap->region);
|
||||||
(drm_radeon_mem_init_heap_t __user *) data,
|
|
||||||
sizeof(initheap));
|
|
||||||
|
|
||||||
heap = get_heap(dev_priv, initheap.region);
|
|
||||||
if (!heap)
|
if (!heap)
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
|
@ -310,5 +298,5 @@ int radeon_mem_init_heap(DRM_IOCTL_ARGS)
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return init_heap(heap, initheap.start, initheap.size);
|
return init_heap(heap, initheap->start, initheap->size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2075,61 +2075,48 @@ static void radeon_surfaces_release(struct drm_file *file_priv,
|
||||||
/* ================================================================
|
/* ================================================================
|
||||||
* IOCTL functions
|
* IOCTL functions
|
||||||
*/
|
*/
|
||||||
static int radeon_surface_alloc(DRM_IOCTL_ARGS)
|
static int radeon_surface_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
drm_radeon_surface_alloc_t alloc;
|
drm_radeon_surface_alloc_t *alloc = data;
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(alloc,
|
if (alloc_surface(alloc, dev_priv, file_priv) == -1)
|
||||||
(drm_radeon_surface_alloc_t __user *) data,
|
|
||||||
sizeof(alloc));
|
|
||||||
|
|
||||||
if (alloc_surface(&alloc, dev_priv, file_priv) == -1)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int radeon_surface_free(DRM_IOCTL_ARGS)
|
static int radeon_surface_free(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
drm_radeon_surface_free_t memfree;
|
drm_radeon_surface_free_t *memfree = data;
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(memfree, (drm_radeon_surface_free_t __user *) data,
|
if (free_surface(file_priv, dev_priv, memfree->address))
|
||||||
sizeof(memfree));
|
|
||||||
|
|
||||||
if (free_surface(file_priv, dev_priv, memfree.address))
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int radeon_cp_clear(DRM_IOCTL_ARGS)
|
static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
||||||
drm_radeon_clear_t clear;
|
drm_radeon_clear_t *clear = data;
|
||||||
drm_radeon_clear_rect_t depth_boxes[RADEON_NR_SAREA_CLIPRECTS];
|
drm_radeon_clear_rect_t depth_boxes[RADEON_NR_SAREA_CLIPRECTS];
|
||||||
DRM_DEBUG("\n");
|
DRM_DEBUG("\n");
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(clear, (drm_radeon_clear_t __user *) data,
|
|
||||||
sizeof(clear));
|
|
||||||
|
|
||||||
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
||||||
|
|
||||||
if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
|
if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
|
||||||
sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
|
sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
|
||||||
|
|
||||||
if (DRM_COPY_FROM_USER(&depth_boxes, clear.depth_boxes,
|
if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
|
||||||
sarea_priv->nbox * sizeof(depth_boxes[0])))
|
sarea_priv->nbox * sizeof(depth_boxes[0])))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
radeon_cp_dispatch_clear(dev, &clear, depth_boxes);
|
radeon_cp_dispatch_clear(dev, clear, depth_boxes);
|
||||||
|
|
||||||
COMMIT_RING();
|
COMMIT_RING();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2165,9 +2152,8 @@ static int radeon_do_init_pageflip(struct drm_device * dev)
|
||||||
/* Swapping and flipping are different operations, need different ioctls.
|
/* Swapping and flipping are different operations, need different ioctls.
|
||||||
* They can & should be intermixed to support multiple 3d windows.
|
* They can & should be intermixed to support multiple 3d windows.
|
||||||
*/
|
*/
|
||||||
static int radeon_cp_flip(DRM_IOCTL_ARGS)
|
static int radeon_cp_flip(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
DRM_DEBUG("\n");
|
DRM_DEBUG("\n");
|
||||||
|
|
||||||
|
@ -2184,9 +2170,8 @@ static int radeon_cp_flip(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int radeon_cp_swap(DRM_IOCTL_ARGS)
|
static int radeon_cp_swap(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
||||||
DRM_DEBUG("\n");
|
DRM_DEBUG("\n");
|
||||||
|
@ -2205,38 +2190,34 @@ static int radeon_cp_swap(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int radeon_cp_vertex(DRM_IOCTL_ARGS)
|
static int radeon_cp_vertex(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
struct drm_buf *buf;
|
struct drm_buf *buf;
|
||||||
drm_radeon_vertex_t vertex;
|
drm_radeon_vertex_t *vertex = data;
|
||||||
drm_radeon_tcl_prim_t prim;
|
drm_radeon_tcl_prim_t prim;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(vertex, (drm_radeon_vertex_t __user *) data,
|
|
||||||
sizeof(vertex));
|
|
||||||
|
|
||||||
DRM_DEBUG("pid=%d index=%d count=%d discard=%d\n",
|
DRM_DEBUG("pid=%d index=%d count=%d discard=%d\n",
|
||||||
DRM_CURRENTPID, vertex.idx, vertex.count, vertex.discard);
|
DRM_CURRENTPID, vertex->idx, vertex->count, vertex->discard);
|
||||||
|
|
||||||
if (vertex.idx < 0 || vertex.idx >= dma->buf_count) {
|
if (vertex->idx < 0 || vertex->idx >= dma->buf_count) {
|
||||||
DRM_ERROR("buffer index %d (of %d max)\n",
|
DRM_ERROR("buffer index %d (of %d max)\n",
|
||||||
vertex.idx, dma->buf_count - 1);
|
vertex->idx, dma->buf_count - 1);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (vertex.prim < 0 || vertex.prim > RADEON_PRIM_TYPE_3VRT_LINE_LIST) {
|
if (vertex->prim < 0 || vertex->prim > RADEON_PRIM_TYPE_3VRT_LINE_LIST) {
|
||||||
DRM_ERROR("buffer prim %d\n", vertex.prim);
|
DRM_ERROR("buffer prim %d\n", vertex->prim);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
||||||
VB_AGE_TEST_WITH_RETURN(dev_priv);
|
VB_AGE_TEST_WITH_RETURN(dev_priv);
|
||||||
|
|
||||||
buf = dma->buflist[vertex.idx];
|
buf = dma->buflist[vertex->idx];
|
||||||
|
|
||||||
if (buf->file_priv != file_priv) {
|
if (buf->file_priv != file_priv) {
|
||||||
DRM_ERROR("process %d using buffer owned by %p\n",
|
DRM_ERROR("process %d using buffer owned by %p\n",
|
||||||
|
@ -2244,14 +2225,14 @@ static int radeon_cp_vertex(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (buf->pending) {
|
if (buf->pending) {
|
||||||
DRM_ERROR("sending pending buffer %d\n", vertex.idx);
|
DRM_ERROR("sending pending buffer %d\n", vertex->idx);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Build up a prim_t record:
|
/* Build up a prim_t record:
|
||||||
*/
|
*/
|
||||||
if (vertex.count) {
|
if (vertex->count) {
|
||||||
buf->used = vertex.count; /* not used? */
|
buf->used = vertex->count; /* not used? */
|
||||||
|
|
||||||
if (sarea_priv->dirty & ~RADEON_UPLOAD_CLIPRECTS) {
|
if (sarea_priv->dirty & ~RADEON_UPLOAD_CLIPRECTS) {
|
||||||
if (radeon_emit_state(dev_priv, file_priv,
|
if (radeon_emit_state(dev_priv, file_priv,
|
||||||
|
@ -2269,15 +2250,15 @@ static int radeon_cp_vertex(DRM_IOCTL_ARGS)
|
||||||
}
|
}
|
||||||
|
|
||||||
prim.start = 0;
|
prim.start = 0;
|
||||||
prim.finish = vertex.count; /* unused */
|
prim.finish = vertex->count; /* unused */
|
||||||
prim.prim = vertex.prim;
|
prim.prim = vertex->prim;
|
||||||
prim.numverts = vertex.count;
|
prim.numverts = vertex->count;
|
||||||
prim.vc_format = dev_priv->sarea_priv->vc_format;
|
prim.vc_format = dev_priv->sarea_priv->vc_format;
|
||||||
|
|
||||||
radeon_cp_dispatch_vertex(dev, buf, &prim);
|
radeon_cp_dispatch_vertex(dev, buf, &prim);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vertex.discard) {
|
if (vertex->discard) {
|
||||||
radeon_cp_discard_buffer(dev, buf);
|
radeon_cp_discard_buffer(dev, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2285,39 +2266,36 @@ static int radeon_cp_vertex(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int radeon_cp_indices(DRM_IOCTL_ARGS)
|
static int radeon_cp_indices(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
struct drm_buf *buf;
|
struct drm_buf *buf;
|
||||||
drm_radeon_indices_t elts;
|
drm_radeon_indices_t *elts = data;
|
||||||
drm_radeon_tcl_prim_t prim;
|
drm_radeon_tcl_prim_t prim;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(elts, (drm_radeon_indices_t __user *) data,
|
|
||||||
sizeof(elts));
|
|
||||||
|
|
||||||
DRM_DEBUG("pid=%d index=%d start=%d end=%d discard=%d\n",
|
DRM_DEBUG("pid=%d index=%d start=%d end=%d discard=%d\n",
|
||||||
DRM_CURRENTPID, elts.idx, elts.start, elts.end, elts.discard);
|
DRM_CURRENTPID, elts->idx, elts->start, elts->end,
|
||||||
|
elts->discard);
|
||||||
|
|
||||||
if (elts.idx < 0 || elts.idx >= dma->buf_count) {
|
if (elts->idx < 0 || elts->idx >= dma->buf_count) {
|
||||||
DRM_ERROR("buffer index %d (of %d max)\n",
|
DRM_ERROR("buffer index %d (of %d max)\n",
|
||||||
elts.idx, dma->buf_count - 1);
|
elts->idx, dma->buf_count - 1);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (elts.prim < 0 || elts.prim > RADEON_PRIM_TYPE_3VRT_LINE_LIST) {
|
if (elts->prim < 0 || elts->prim > RADEON_PRIM_TYPE_3VRT_LINE_LIST) {
|
||||||
DRM_ERROR("buffer prim %d\n", elts.prim);
|
DRM_ERROR("buffer prim %d\n", elts->prim);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
||||||
VB_AGE_TEST_WITH_RETURN(dev_priv);
|
VB_AGE_TEST_WITH_RETURN(dev_priv);
|
||||||
|
|
||||||
buf = dma->buflist[elts.idx];
|
buf = dma->buflist[elts->idx];
|
||||||
|
|
||||||
if (buf->file_priv != file_priv) {
|
if (buf->file_priv != file_priv) {
|
||||||
DRM_ERROR("process %d using buffer owned by %p\n",
|
DRM_ERROR("process %d using buffer owned by %p\n",
|
||||||
|
@ -2325,23 +2303,23 @@ static int radeon_cp_indices(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (buf->pending) {
|
if (buf->pending) {
|
||||||
DRM_ERROR("sending pending buffer %d\n", elts.idx);
|
DRM_ERROR("sending pending buffer %d\n", elts->idx);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
count = (elts.end - elts.start) / sizeof(u16);
|
count = (elts->end - elts->start) / sizeof(u16);
|
||||||
elts.start -= RADEON_INDEX_PRIM_OFFSET;
|
elts->start -= RADEON_INDEX_PRIM_OFFSET;
|
||||||
|
|
||||||
if (elts.start & 0x7) {
|
if (elts->start & 0x7) {
|
||||||
DRM_ERROR("misaligned buffer 0x%x\n", elts.start);
|
DRM_ERROR("misaligned buffer 0x%x\n", elts->start);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (elts.start < buf->used) {
|
if (elts->start < buf->used) {
|
||||||
DRM_ERROR("no header 0x%x - 0x%x\n", elts.start, buf->used);
|
DRM_ERROR("no header 0x%x - 0x%x\n", elts->start, buf->used);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf->used = elts.end;
|
buf->used = elts->end;
|
||||||
|
|
||||||
if (sarea_priv->dirty & ~RADEON_UPLOAD_CLIPRECTS) {
|
if (sarea_priv->dirty & ~RADEON_UPLOAD_CLIPRECTS) {
|
||||||
if (radeon_emit_state(dev_priv, file_priv,
|
if (radeon_emit_state(dev_priv, file_priv,
|
||||||
|
@ -2360,15 +2338,15 @@ static int radeon_cp_indices(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
/* Build up a prim_t record:
|
/* Build up a prim_t record:
|
||||||
*/
|
*/
|
||||||
prim.start = elts.start;
|
prim.start = elts->start;
|
||||||
prim.finish = elts.end;
|
prim.finish = elts->end;
|
||||||
prim.prim = elts.prim;
|
prim.prim = elts->prim;
|
||||||
prim.offset = 0; /* offset from start of dma buffers */
|
prim.offset = 0; /* offset from start of dma buffers */
|
||||||
prim.numverts = RADEON_MAX_VB_VERTS; /* duh */
|
prim.numverts = RADEON_MAX_VB_VERTS; /* duh */
|
||||||
prim.vc_format = dev_priv->sarea_priv->vc_format;
|
prim.vc_format = dev_priv->sarea_priv->vc_format;
|
||||||
|
|
||||||
radeon_cp_dispatch_indices(dev, buf, &prim);
|
radeon_cp_dispatch_indices(dev, buf, &prim);
|
||||||
if (elts.discard) {
|
if (elts->discard) {
|
||||||
radeon_cp_discard_buffer(dev, buf);
|
radeon_cp_discard_buffer(dev, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2376,51 +2354,43 @@ static int radeon_cp_indices(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int radeon_cp_texture(DRM_IOCTL_ARGS)
|
static int radeon_cp_texture(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
drm_radeon_texture_t tex;
|
drm_radeon_texture_t *tex = data;
|
||||||
drm_radeon_tex_image_t image;
|
drm_radeon_tex_image_t image;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(tex, (drm_radeon_texture_t __user *) data,
|
if (tex->image == NULL) {
|
||||||
sizeof(tex));
|
|
||||||
|
|
||||||
if (tex.image == NULL) {
|
|
||||||
DRM_ERROR("null texture image!\n");
|
DRM_ERROR("null texture image!\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DRM_COPY_FROM_USER(&image,
|
if (DRM_COPY_FROM_USER(&image,
|
||||||
(drm_radeon_tex_image_t __user *) tex.image,
|
(drm_radeon_tex_image_t __user *) tex->image,
|
||||||
sizeof(image)))
|
sizeof(image)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
||||||
VB_AGE_TEST_WITH_RETURN(dev_priv);
|
VB_AGE_TEST_WITH_RETURN(dev_priv);
|
||||||
|
|
||||||
ret = radeon_cp_dispatch_texture(dev, file_priv, &tex, &image);
|
ret = radeon_cp_dispatch_texture(dev, file_priv, tex, &image);
|
||||||
|
|
||||||
COMMIT_RING();
|
COMMIT_RING();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int radeon_cp_stipple(DRM_IOCTL_ARGS)
|
static int radeon_cp_stipple(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
drm_radeon_stipple_t stipple;
|
drm_radeon_stipple_t *stipple = data;
|
||||||
u32 mask[32];
|
u32 mask[32];
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(stipple, (drm_radeon_stipple_t __user *) data,
|
if (DRM_COPY_FROM_USER(&mask, stipple->mask, 32 * sizeof(u32)))
|
||||||
sizeof(stipple));
|
|
||||||
|
|
||||||
if (DRM_COPY_FROM_USER(&mask, stipple.mask, 32 * sizeof(u32)))
|
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
||||||
|
@ -2431,31 +2401,27 @@ static int radeon_cp_stipple(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int radeon_cp_indirect(DRM_IOCTL_ARGS)
|
static int radeon_cp_indirect(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
struct drm_buf *buf;
|
struct drm_buf *buf;
|
||||||
drm_radeon_indirect_t indirect;
|
drm_radeon_indirect_t *indirect = data;
|
||||||
RING_LOCALS;
|
RING_LOCALS;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(indirect,
|
|
||||||
(drm_radeon_indirect_t __user *) data,
|
|
||||||
sizeof(indirect));
|
|
||||||
|
|
||||||
DRM_DEBUG("indirect: idx=%d s=%d e=%d d=%d\n",
|
DRM_DEBUG("indirect: idx=%d s=%d e=%d d=%d\n",
|
||||||
indirect.idx, indirect.start, indirect.end, indirect.discard);
|
indirect->idx, indirect->start, indirect->end,
|
||||||
|
indirect->discard);
|
||||||
|
|
||||||
if (indirect.idx < 0 || indirect.idx >= dma->buf_count) {
|
if (indirect->idx < 0 || indirect->idx >= dma->buf_count) {
|
||||||
DRM_ERROR("buffer index %d (of %d max)\n",
|
DRM_ERROR("buffer index %d (of %d max)\n",
|
||||||
indirect.idx, dma->buf_count - 1);
|
indirect->idx, dma->buf_count - 1);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = dma->buflist[indirect.idx];
|
buf = dma->buflist[indirect->idx];
|
||||||
|
|
||||||
if (buf->file_priv != file_priv) {
|
if (buf->file_priv != file_priv) {
|
||||||
DRM_ERROR("process %d using buffer owned by %p\n",
|
DRM_ERROR("process %d using buffer owned by %p\n",
|
||||||
|
@ -2463,20 +2429,20 @@ static int radeon_cp_indirect(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (buf->pending) {
|
if (buf->pending) {
|
||||||
DRM_ERROR("sending pending buffer %d\n", indirect.idx);
|
DRM_ERROR("sending pending buffer %d\n", indirect->idx);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (indirect.start < buf->used) {
|
if (indirect->start < buf->used) {
|
||||||
DRM_ERROR("reusing indirect: start=0x%x actual=0x%x\n",
|
DRM_ERROR("reusing indirect: start=0x%x actual=0x%x\n",
|
||||||
indirect.start, buf->used);
|
indirect->start, buf->used);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
||||||
VB_AGE_TEST_WITH_RETURN(dev_priv);
|
VB_AGE_TEST_WITH_RETURN(dev_priv);
|
||||||
|
|
||||||
buf->used = indirect.end;
|
buf->used = indirect->end;
|
||||||
|
|
||||||
/* Wait for the 3D stream to idle before the indirect buffer
|
/* Wait for the 3D stream to idle before the indirect buffer
|
||||||
* containing 2D acceleration commands is processed.
|
* containing 2D acceleration commands is processed.
|
||||||
|
@ -2491,8 +2457,8 @@ static int radeon_cp_indirect(DRM_IOCTL_ARGS)
|
||||||
* X server. This is insecure and is thus only available to
|
* X server. This is insecure and is thus only available to
|
||||||
* privileged clients.
|
* privileged clients.
|
||||||
*/
|
*/
|
||||||
radeon_cp_dispatch_indirect(dev, buf, indirect.start, indirect.end);
|
radeon_cp_dispatch_indirect(dev, buf, indirect->start, indirect->end);
|
||||||
if (indirect.discard) {
|
if (indirect->discard) {
|
||||||
radeon_cp_discard_buffer(dev, buf);
|
radeon_cp_discard_buffer(dev, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2500,35 +2466,31 @@ static int radeon_cp_indirect(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int radeon_cp_vertex2(DRM_IOCTL_ARGS)
|
static int radeon_cp_vertex2(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
struct drm_buf *buf;
|
struct drm_buf *buf;
|
||||||
drm_radeon_vertex2_t vertex;
|
drm_radeon_vertex2_t *vertex = data;
|
||||||
int i;
|
int i;
|
||||||
unsigned char laststate;
|
unsigned char laststate;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(vertex, (drm_radeon_vertex2_t __user *) data,
|
|
||||||
sizeof(vertex));
|
|
||||||
|
|
||||||
DRM_DEBUG("pid=%d index=%d discard=%d\n",
|
DRM_DEBUG("pid=%d index=%d discard=%d\n",
|
||||||
DRM_CURRENTPID, vertex.idx, vertex.discard);
|
DRM_CURRENTPID, vertex->idx, vertex->discard);
|
||||||
|
|
||||||
if (vertex.idx < 0 || vertex.idx >= dma->buf_count) {
|
if (vertex->idx < 0 || vertex->idx >= dma->buf_count) {
|
||||||
DRM_ERROR("buffer index %d (of %d max)\n",
|
DRM_ERROR("buffer index %d (of %d max)\n",
|
||||||
vertex.idx, dma->buf_count - 1);
|
vertex->idx, dma->buf_count - 1);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
||||||
VB_AGE_TEST_WITH_RETURN(dev_priv);
|
VB_AGE_TEST_WITH_RETURN(dev_priv);
|
||||||
|
|
||||||
buf = dma->buflist[vertex.idx];
|
buf = dma->buflist[vertex->idx];
|
||||||
|
|
||||||
if (buf->file_priv != file_priv) {
|
if (buf->file_priv != file_priv) {
|
||||||
DRM_ERROR("process %d using buffer owned by %p\n",
|
DRM_ERROR("process %d using buffer owned by %p\n",
|
||||||
|
@ -2537,25 +2499,25 @@ static int radeon_cp_vertex2(DRM_IOCTL_ARGS)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf->pending) {
|
if (buf->pending) {
|
||||||
DRM_ERROR("sending pending buffer %d\n", vertex.idx);
|
DRM_ERROR("sending pending buffer %d\n", vertex->idx);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
|
if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
for (laststate = 0xff, i = 0; i < vertex.nr_prims; i++) {
|
for (laststate = 0xff, i = 0; i < vertex->nr_prims; i++) {
|
||||||
drm_radeon_prim_t prim;
|
drm_radeon_prim_t prim;
|
||||||
drm_radeon_tcl_prim_t tclprim;
|
drm_radeon_tcl_prim_t tclprim;
|
||||||
|
|
||||||
if (DRM_COPY_FROM_USER(&prim, &vertex.prim[i], sizeof(prim)))
|
if (DRM_COPY_FROM_USER(&prim, &vertex->prim[i], sizeof(prim)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
if (prim.stateidx != laststate) {
|
if (prim.stateidx != laststate) {
|
||||||
drm_radeon_state_t state;
|
drm_radeon_state_t state;
|
||||||
|
|
||||||
if (DRM_COPY_FROM_USER(&state,
|
if (DRM_COPY_FROM_USER(&state,
|
||||||
&vertex.state[prim.stateidx],
|
&vertex->state[prim.stateidx],
|
||||||
sizeof(state)))
|
sizeof(state)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
|
@ -2588,7 +2550,7 @@ static int radeon_cp_vertex2(DRM_IOCTL_ARGS)
|
||||||
sarea_priv->nbox = 0;
|
sarea_priv->nbox = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vertex.discard) {
|
if (vertex->discard) {
|
||||||
radeon_cp_discard_buffer(dev, buf);
|
radeon_cp_discard_buffer(dev, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2839,28 +2801,23 @@ static int radeon_emit_wait(struct drm_device * dev, int flags)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS)
|
static int radeon_cp_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
struct drm_buf *buf = NULL;
|
struct drm_buf *buf = NULL;
|
||||||
int idx;
|
int idx;
|
||||||
drm_radeon_kcmd_buffer_t cmdbuf;
|
drm_radeon_kcmd_buffer_t *cmdbuf = data;
|
||||||
drm_radeon_cmd_header_t header;
|
drm_radeon_cmd_header_t header;
|
||||||
int orig_nbox, orig_bufsz;
|
int orig_nbox, orig_bufsz;
|
||||||
char *kbuf = NULL;
|
char *kbuf = NULL;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(cmdbuf,
|
|
||||||
(drm_radeon_cmd_buffer_t __user *) data,
|
|
||||||
sizeof(cmdbuf));
|
|
||||||
|
|
||||||
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
RING_SPACE_TEST_WITH_RETURN(dev_priv);
|
||||||
VB_AGE_TEST_WITH_RETURN(dev_priv);
|
VB_AGE_TEST_WITH_RETURN(dev_priv);
|
||||||
|
|
||||||
if (cmdbuf.bufsz > 64 * 1024 || cmdbuf.bufsz < 0) {
|
if (cmdbuf->bufsz > 64 * 1024 || cmdbuf->bufsz < 0) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2868,24 +2825,24 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS)
|
||||||
* races between checking values and using those values in other code,
|
* races between checking values and using those values in other code,
|
||||||
* and simply to avoid a lot of function calls to copy in data.
|
* and simply to avoid a lot of function calls to copy in data.
|
||||||
*/
|
*/
|
||||||
orig_bufsz = cmdbuf.bufsz;
|
orig_bufsz = cmdbuf->bufsz;
|
||||||
if (orig_bufsz != 0) {
|
if (orig_bufsz != 0) {
|
||||||
kbuf = drm_alloc(cmdbuf.bufsz, DRM_MEM_DRIVER);
|
kbuf = drm_alloc(cmdbuf->bufsz, DRM_MEM_DRIVER);
|
||||||
if (kbuf == NULL)
|
if (kbuf == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
if (DRM_COPY_FROM_USER(kbuf, (void __user *)cmdbuf.buf,
|
if (DRM_COPY_FROM_USER(kbuf, (void __user *)cmdbuf->buf,
|
||||||
cmdbuf.bufsz)) {
|
cmdbuf->bufsz)) {
|
||||||
drm_free(kbuf, orig_bufsz, DRM_MEM_DRIVER);
|
drm_free(kbuf, orig_bufsz, DRM_MEM_DRIVER);
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
cmdbuf.buf = kbuf;
|
cmdbuf->buf = kbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
orig_nbox = cmdbuf.nbox;
|
orig_nbox = cmdbuf->nbox;
|
||||||
|
|
||||||
if (dev_priv->microcode_version == UCODE_R300) {
|
if (dev_priv->microcode_version == UCODE_R300) {
|
||||||
int temp;
|
int temp;
|
||||||
temp = r300_do_cp_cmdbuf(dev, file_priv, &cmdbuf);
|
temp = r300_do_cp_cmdbuf(dev, file_priv, cmdbuf);
|
||||||
|
|
||||||
if (orig_bufsz != 0)
|
if (orig_bufsz != 0)
|
||||||
drm_free(kbuf, orig_bufsz, DRM_MEM_DRIVER);
|
drm_free(kbuf, orig_bufsz, DRM_MEM_DRIVER);
|
||||||
|
@ -2894,17 +2851,17 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* microcode_version != r300 */
|
/* microcode_version != r300 */
|
||||||
while (cmdbuf.bufsz >= sizeof(header)) {
|
while (cmdbuf->bufsz >= sizeof(header)) {
|
||||||
|
|
||||||
header.i = *(int *)cmdbuf.buf;
|
header.i = *(int *)cmdbuf->buf;
|
||||||
cmdbuf.buf += sizeof(header);
|
cmdbuf->buf += sizeof(header);
|
||||||
cmdbuf.bufsz -= sizeof(header);
|
cmdbuf->bufsz -= sizeof(header);
|
||||||
|
|
||||||
switch (header.header.cmd_type) {
|
switch (header.header.cmd_type) {
|
||||||
case RADEON_CMD_PACKET:
|
case RADEON_CMD_PACKET:
|
||||||
DRM_DEBUG("RADEON_CMD_PACKET\n");
|
DRM_DEBUG("RADEON_CMD_PACKET\n");
|
||||||
if (radeon_emit_packets
|
if (radeon_emit_packets
|
||||||
(dev_priv, file_priv, header, &cmdbuf)) {
|
(dev_priv, file_priv, header, cmdbuf)) {
|
||||||
DRM_ERROR("radeon_emit_packets failed\n");
|
DRM_ERROR("radeon_emit_packets failed\n");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -2912,7 +2869,7 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
case RADEON_CMD_SCALARS:
|
case RADEON_CMD_SCALARS:
|
||||||
DRM_DEBUG("RADEON_CMD_SCALARS\n");
|
DRM_DEBUG("RADEON_CMD_SCALARS\n");
|
||||||
if (radeon_emit_scalars(dev_priv, header, &cmdbuf)) {
|
if (radeon_emit_scalars(dev_priv, header, cmdbuf)) {
|
||||||
DRM_ERROR("radeon_emit_scalars failed\n");
|
DRM_ERROR("radeon_emit_scalars failed\n");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -2920,7 +2877,7 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
case RADEON_CMD_VECTORS:
|
case RADEON_CMD_VECTORS:
|
||||||
DRM_DEBUG("RADEON_CMD_VECTORS\n");
|
DRM_DEBUG("RADEON_CMD_VECTORS\n");
|
||||||
if (radeon_emit_vectors(dev_priv, header, &cmdbuf)) {
|
if (radeon_emit_vectors(dev_priv, header, cmdbuf)) {
|
||||||
DRM_ERROR("radeon_emit_vectors failed\n");
|
DRM_ERROR("radeon_emit_vectors failed\n");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -2948,7 +2905,7 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
case RADEON_CMD_PACKET3:
|
case RADEON_CMD_PACKET3:
|
||||||
DRM_DEBUG("RADEON_CMD_PACKET3\n");
|
DRM_DEBUG("RADEON_CMD_PACKET3\n");
|
||||||
if (radeon_emit_packet3(dev, file_priv, &cmdbuf)) {
|
if (radeon_emit_packet3(dev, file_priv, cmdbuf)) {
|
||||||
DRM_ERROR("radeon_emit_packet3 failed\n");
|
DRM_ERROR("radeon_emit_packet3 failed\n");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -2957,7 +2914,7 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS)
|
||||||
case RADEON_CMD_PACKET3_CLIP:
|
case RADEON_CMD_PACKET3_CLIP:
|
||||||
DRM_DEBUG("RADEON_CMD_PACKET3_CLIP\n");
|
DRM_DEBUG("RADEON_CMD_PACKET3_CLIP\n");
|
||||||
if (radeon_emit_packet3_cliprect
|
if (radeon_emit_packet3_cliprect
|
||||||
(dev, file_priv, &cmdbuf, orig_nbox)) {
|
(dev, file_priv, cmdbuf, orig_nbox)) {
|
||||||
DRM_ERROR("radeon_emit_packet3_clip failed\n");
|
DRM_ERROR("radeon_emit_packet3_clip failed\n");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -2965,7 +2922,7 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
case RADEON_CMD_SCALARS2:
|
case RADEON_CMD_SCALARS2:
|
||||||
DRM_DEBUG("RADEON_CMD_SCALARS2\n");
|
DRM_DEBUG("RADEON_CMD_SCALARS2\n");
|
||||||
if (radeon_emit_scalars2(dev_priv, header, &cmdbuf)) {
|
if (radeon_emit_scalars2(dev_priv, header, cmdbuf)) {
|
||||||
DRM_ERROR("radeon_emit_scalars2 failed\n");
|
DRM_ERROR("radeon_emit_scalars2 failed\n");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -2980,7 +2937,7 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS)
|
||||||
break;
|
break;
|
||||||
case RADEON_CMD_VECLINEAR:
|
case RADEON_CMD_VECLINEAR:
|
||||||
DRM_DEBUG("RADEON_CMD_VECLINEAR\n");
|
DRM_DEBUG("RADEON_CMD_VECLINEAR\n");
|
||||||
if (radeon_emit_veclinear(dev_priv, header, &cmdbuf)) {
|
if (radeon_emit_veclinear(dev_priv, header, cmdbuf)) {
|
||||||
DRM_ERROR("radeon_emit_veclinear failed\n");
|
DRM_ERROR("radeon_emit_veclinear failed\n");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -2989,7 +2946,7 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS)
|
||||||
default:
|
default:
|
||||||
DRM_ERROR("bad cmd_type %d at %p\n",
|
DRM_ERROR("bad cmd_type %d at %p\n",
|
||||||
header.header.cmd_type,
|
header.header.cmd_type,
|
||||||
cmdbuf.buf - sizeof(header));
|
cmdbuf->buf - sizeof(header));
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3007,19 +2964,15 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int radeon_cp_getparam(DRM_IOCTL_ARGS)
|
static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
drm_radeon_getparam_t param;
|
drm_radeon_getparam_t *param = data;
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(param, (drm_radeon_getparam_t __user *) data,
|
|
||||||
sizeof(param));
|
|
||||||
|
|
||||||
DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
|
DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
|
||||||
|
|
||||||
switch (param.param) {
|
switch (param->param) {
|
||||||
case RADEON_PARAM_GART_BUFFER_OFFSET:
|
case RADEON_PARAM_GART_BUFFER_OFFSET:
|
||||||
value = dev_priv->gart_buffers_offset;
|
value = dev_priv->gart_buffers_offset;
|
||||||
break;
|
break;
|
||||||
|
@ -3081,11 +3034,11 @@ static int radeon_cp_getparam(DRM_IOCTL_ARGS)
|
||||||
value = radeon_vblank_crtc_get(dev);
|
value = radeon_vblank_crtc_get(dev);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DRM_DEBUG("Invalid parameter %d\n", param.param);
|
DRM_DEBUG("Invalid parameter %d\n", param->param);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DRM_COPY_TO_USER(param.value, &value, sizeof(int))) {
|
if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) {
|
||||||
DRM_ERROR("copy_to_user\n");
|
DRM_ERROR("copy_to_user\n");
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
@ -3093,28 +3046,25 @@ static int radeon_cp_getparam(DRM_IOCTL_ARGS)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int radeon_cp_setparam(DRM_IOCTL_ARGS)
|
static int radeon_cp_setparam(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
drm_radeon_setparam_t sp;
|
drm_radeon_setparam_t *sp = data;
|
||||||
struct drm_radeon_driver_file_fields *radeon_priv;
|
struct drm_radeon_driver_file_fields *radeon_priv;
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(sp, (drm_radeon_setparam_t __user *) data,
|
switch (sp->param) {
|
||||||
sizeof(sp));
|
|
||||||
|
|
||||||
switch (sp.param) {
|
|
||||||
case RADEON_SETPARAM_FB_LOCATION:
|
case RADEON_SETPARAM_FB_LOCATION:
|
||||||
radeon_priv = file_priv->driver_priv;
|
radeon_priv = file_priv->driver_priv;
|
||||||
radeon_priv->radeon_fb_delta = dev_priv->fb_location - sp.value;
|
radeon_priv->radeon_fb_delta = dev_priv->fb_location -
|
||||||
|
sp->value;
|
||||||
break;
|
break;
|
||||||
case RADEON_SETPARAM_SWITCH_TILING:
|
case RADEON_SETPARAM_SWITCH_TILING:
|
||||||
if (sp.value == 0) {
|
if (sp->value == 0) {
|
||||||
DRM_DEBUG("color tiling disabled\n");
|
DRM_DEBUG("color tiling disabled\n");
|
||||||
dev_priv->front_pitch_offset &= ~RADEON_DST_TILE_MACRO;
|
dev_priv->front_pitch_offset &= ~RADEON_DST_TILE_MACRO;
|
||||||
dev_priv->back_pitch_offset &= ~RADEON_DST_TILE_MACRO;
|
dev_priv->back_pitch_offset &= ~RADEON_DST_TILE_MACRO;
|
||||||
dev_priv->sarea_priv->tiling_enabled = 0;
|
dev_priv->sarea_priv->tiling_enabled = 0;
|
||||||
} else if (sp.value == 1) {
|
} else if (sp->value == 1) {
|
||||||
DRM_DEBUG("color tiling enabled\n");
|
DRM_DEBUG("color tiling enabled\n");
|
||||||
dev_priv->front_pitch_offset |= RADEON_DST_TILE_MACRO;
|
dev_priv->front_pitch_offset |= RADEON_DST_TILE_MACRO;
|
||||||
dev_priv->back_pitch_offset |= RADEON_DST_TILE_MACRO;
|
dev_priv->back_pitch_offset |= RADEON_DST_TILE_MACRO;
|
||||||
|
@ -3122,22 +3072,22 @@ static int radeon_cp_setparam(DRM_IOCTL_ARGS)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RADEON_SETPARAM_PCIGART_LOCATION:
|
case RADEON_SETPARAM_PCIGART_LOCATION:
|
||||||
dev_priv->pcigart_offset = sp.value;
|
dev_priv->pcigart_offset = sp->value;
|
||||||
dev_priv->pcigart_offset_set = 1;
|
dev_priv->pcigart_offset_set = 1;
|
||||||
break;
|
break;
|
||||||
case RADEON_SETPARAM_NEW_MEMMAP:
|
case RADEON_SETPARAM_NEW_MEMMAP:
|
||||||
dev_priv->new_memmap = sp.value;
|
dev_priv->new_memmap = sp->value;
|
||||||
break;
|
break;
|
||||||
case RADEON_SETPARAM_PCIGART_TABLE_SIZE:
|
case RADEON_SETPARAM_PCIGART_TABLE_SIZE:
|
||||||
dev_priv->gart_info.table_size = sp.value;
|
dev_priv->gart_info.table_size = sp->value;
|
||||||
if (dev_priv->gart_info.table_size < RADEON_PCIGART_TABLE_SIZE)
|
if (dev_priv->gart_info.table_size < RADEON_PCIGART_TABLE_SIZE)
|
||||||
dev_priv->gart_info.table_size = RADEON_PCIGART_TABLE_SIZE;
|
dev_priv->gart_info.table_size = RADEON_PCIGART_TABLE_SIZE;
|
||||||
break;
|
break;
|
||||||
case RADEON_SETPARAM_VBLANK_CRTC:
|
case RADEON_SETPARAM_VBLANK_CRTC:
|
||||||
return radeon_vblank_crtc_set(dev, sp.value);
|
return radeon_vblank_crtc_set(dev, sp->value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DRM_DEBUG("Invalid parameter %d\n", sp.param);
|
DRM_DEBUG("Invalid parameter %d\n", sp->param);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3205,34 +3155,34 @@ void radeon_driver_postclose(struct drm_device *dev, struct drm_file *file_priv)
|
||||||
drm_free(radeon_priv, sizeof(*radeon_priv), DRM_MEM_FILES);
|
drm_free(radeon_priv, sizeof(*radeon_priv), DRM_MEM_FILES);
|
||||||
}
|
}
|
||||||
|
|
||||||
drm_ioctl_desc_t radeon_ioctls[] = {
|
struct drm_ioctl_desc radeon_ioctls[] = {
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_CP_INIT)] = {radeon_cp_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_RADEON_CP_INIT, radeon_cp_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_CP_START)] = {radeon_cp_start, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_RADEON_CP_START, radeon_cp_start, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_CP_STOP)] = {radeon_cp_stop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_RADEON_CP_STOP, radeon_cp_stop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_CP_RESET)] = {radeon_cp_reset, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_RADEON_CP_RESET, radeon_cp_reset, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_CP_IDLE)] = {radeon_cp_idle, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_RADEON_CP_IDLE, radeon_cp_idle, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_CP_RESUME)] = {radeon_cp_resume, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_RADEON_CP_RESUME, radeon_cp_resume, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_RESET)] = {radeon_engine_reset, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_RADEON_RESET, radeon_engine_reset, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_FULLSCREEN)] = {radeon_fullscreen, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_RADEON_FULLSCREEN, radeon_fullscreen, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_SWAP)] = {radeon_cp_swap, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_RADEON_SWAP, radeon_cp_swap, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_CLEAR)] = {radeon_cp_clear, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_RADEON_CLEAR, radeon_cp_clear, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_VERTEX)] = {radeon_cp_vertex, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_RADEON_VERTEX, radeon_cp_vertex, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_INDICES)] = {radeon_cp_indices, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_RADEON_INDICES, radeon_cp_indices, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_TEXTURE)] = {radeon_cp_texture, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_RADEON_TEXTURE, radeon_cp_texture, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_STIPPLE)] = {radeon_cp_stipple, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_RADEON_STIPPLE, radeon_cp_stipple, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_INDIRECT)] = {radeon_cp_indirect, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_RADEON_INDIRECT, radeon_cp_indirect, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_VERTEX2)] = {radeon_cp_vertex2, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_RADEON_VERTEX2, radeon_cp_vertex2, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_CMDBUF)] = {radeon_cp_cmdbuf, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_RADEON_CMDBUF, radeon_cp_cmdbuf, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_GETPARAM)] = {radeon_cp_getparam, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_RADEON_GETPARAM, radeon_cp_getparam, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_FLIP)] = {radeon_cp_flip, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_RADEON_FLIP, radeon_cp_flip, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_ALLOC)] = {radeon_mem_alloc, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_RADEON_ALLOC, radeon_mem_alloc, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_FREE)] = {radeon_mem_free, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_RADEON_FREE, radeon_mem_free, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_INIT_HEAP)] = {radeon_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_RADEON_INIT_HEAP, radeon_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_IRQ_EMIT)] = {radeon_irq_emit, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_RADEON_IRQ_EMIT, radeon_irq_emit, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_IRQ_WAIT)] = {radeon_irq_wait, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_RADEON_IRQ_WAIT, radeon_irq_wait, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_SETPARAM)] = {radeon_cp_setparam, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_RADEON_SETPARAM, radeon_cp_setparam, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_SURF_ALLOC)] = {radeon_surface_alloc, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_RADEON_SURF_ALLOC, radeon_surface_alloc, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_RADEON_SURF_FREE)] = {radeon_surface_free, DRM_AUTH}
|
DRM_IOCTL_DEF(DRM_RADEON_SURF_FREE, radeon_surface_free, DRM_AUTH)
|
||||||
};
|
};
|
||||||
|
|
||||||
int radeon_max_ioctl = DRM_ARRAY_SIZE(radeon_ioctls);
|
int radeon_max_ioctl = DRM_ARRAY_SIZE(radeon_ioctls);
|
||||||
|
|
|
@ -928,19 +928,15 @@ static int savage_do_cleanup_bci(struct drm_device * dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int savage_bci_init(DRM_IOCTL_ARGS)
|
static int savage_bci_init(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
drm_savage_init_t *init = data;
|
||||||
drm_savage_init_t init;
|
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(init, (drm_savage_init_t __user *) data,
|
switch (init->func) {
|
||||||
sizeof(init));
|
|
||||||
|
|
||||||
switch (init.func) {
|
|
||||||
case SAVAGE_INIT_BCI:
|
case SAVAGE_INIT_BCI:
|
||||||
return savage_do_init_bci(dev, &init);
|
return savage_do_init_bci(dev, init);
|
||||||
case SAVAGE_CLEANUP_BCI:
|
case SAVAGE_CLEANUP_BCI:
|
||||||
return savage_do_cleanup_bci(dev);
|
return savage_do_cleanup_bci(dev);
|
||||||
}
|
}
|
||||||
|
@ -948,31 +944,25 @@ static int savage_bci_init(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int savage_bci_event_emit(DRM_IOCTL_ARGS)
|
static int savage_bci_event_emit(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_savage_private_t *dev_priv = dev->dev_private;
|
drm_savage_private_t *dev_priv = dev->dev_private;
|
||||||
drm_savage_event_emit_t event;
|
drm_savage_event_emit_t *event = data;
|
||||||
|
|
||||||
DRM_DEBUG("\n");
|
DRM_DEBUG("\n");
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(event, (drm_savage_event_emit_t __user *) data,
|
event->count = savage_bci_emit_event(dev_priv, event->flags);
|
||||||
sizeof(event));
|
event->count |= dev_priv->event_wrap << 16;
|
||||||
|
|
||||||
event.count = savage_bci_emit_event(dev_priv, event.flags);
|
|
||||||
event.count |= dev_priv->event_wrap << 16;
|
|
||||||
DRM_COPY_TO_USER_IOCTL((drm_savage_event_emit_t __user *) data,
|
|
||||||
event, sizeof(event));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int savage_bci_event_wait(DRM_IOCTL_ARGS)
|
static int savage_bci_event_wait(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_savage_private_t *dev_priv = dev->dev_private;
|
drm_savage_private_t *dev_priv = dev->dev_private;
|
||||||
drm_savage_event_wait_t event;
|
drm_savage_event_wait_t *event = data;
|
||||||
unsigned int event_e, hw_e;
|
unsigned int event_e, hw_e;
|
||||||
unsigned int event_w, hw_w;
|
unsigned int event_w, hw_w;
|
||||||
|
|
||||||
|
@ -990,8 +980,8 @@ static int savage_bci_event_wait(DRM_IOCTL_ARGS)
|
||||||
if (hw_e > dev_priv->event_counter)
|
if (hw_e > dev_priv->event_counter)
|
||||||
hw_w--; /* hardware hasn't passed the last wrap yet */
|
hw_w--; /* hardware hasn't passed the last wrap yet */
|
||||||
|
|
||||||
event_e = event.count & 0xffff;
|
event_e = event->count & 0xffff;
|
||||||
event_w = event.count >> 16;
|
event_w = event->count >> 16;
|
||||||
|
|
||||||
/* Don't need to wait if
|
/* Don't need to wait if
|
||||||
* - event counter wrapped since the event was emitted or
|
* - event counter wrapped since the event was emitted or
|
||||||
|
@ -1033,41 +1023,36 @@ static int savage_bci_get_buffers(struct drm_device *dev,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int savage_bci_buffers(DRM_IOCTL_ARGS)
|
int savage_bci_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
struct drm_dma d;
|
struct drm_dma *d = data;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(d, (struct drm_dma __user *) data, sizeof(d));
|
|
||||||
|
|
||||||
/* Please don't send us buffers.
|
/* Please don't send us buffers.
|
||||||
*/
|
*/
|
||||||
if (d.send_count != 0) {
|
if (d->send_count != 0) {
|
||||||
DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n",
|
DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n",
|
||||||
DRM_CURRENTPID, d.send_count);
|
DRM_CURRENTPID, d->send_count);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We'll send you buffers.
|
/* We'll send you buffers.
|
||||||
*/
|
*/
|
||||||
if (d.request_count < 0 || d.request_count > dma->buf_count) {
|
if (d->request_count < 0 || d->request_count > dma->buf_count) {
|
||||||
DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n",
|
DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n",
|
||||||
DRM_CURRENTPID, d.request_count, dma->buf_count);
|
DRM_CURRENTPID, d->request_count, dma->buf_count);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
d.granted_count = 0;
|
d->granted_count = 0;
|
||||||
|
|
||||||
if (d.request_count) {
|
if (d->request_count) {
|
||||||
ret = savage_bci_get_buffers(dev, file_priv, &d);
|
ret = savage_bci_get_buffers(dev, file_priv, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_TO_USER_IOCTL((struct drm_dma __user *) data, d, sizeof(d));
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1103,11 +1088,11 @@ void savage_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv)
|
||||||
drm_core_reclaim_buffers(dev, file_priv);
|
drm_core_reclaim_buffers(dev, file_priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
drm_ioctl_desc_t savage_ioctls[] = {
|
struct drm_ioctl_desc savage_ioctls[] = {
|
||||||
[DRM_IOCTL_NR(DRM_SAVAGE_BCI_INIT)] = {savage_bci_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_SAVAGE_BCI_INIT, savage_bci_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_SAVAGE_BCI_CMDBUF)] = {savage_bci_cmdbuf, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_SAVAGE_BCI_CMDBUF, savage_bci_cmdbuf, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_SAVAGE_BCI_EVENT_EMIT)] = {savage_bci_event_emit, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_SAVAGE_BCI_EVENT_EMIT, savage_bci_event_emit, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_SAVAGE_BCI_EVENT_WAIT)] = {savage_bci_event_wait, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_SAVAGE_BCI_EVENT_WAIT, savage_bci_event_wait, DRM_AUTH),
|
||||||
};
|
};
|
||||||
|
|
||||||
int savage_max_ioctl = DRM_ARRAY_SIZE(savage_ioctls);
|
int savage_max_ioctl = DRM_ARRAY_SIZE(savage_ioctls);
|
||||||
|
|
|
@ -104,7 +104,7 @@ enum savage_family {
|
||||||
S3_LAST
|
S3_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
extern drm_ioctl_desc_t savage_ioctls[];
|
extern struct drm_ioctl_desc savage_ioctls[];
|
||||||
extern int savage_max_ioctl;
|
extern int savage_max_ioctl;
|
||||||
|
|
||||||
#define S3_SAVAGE3D_SERIES(chip) ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE_MX))
|
#define S3_SAVAGE3D_SERIES(chip) ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE_MX))
|
||||||
|
@ -197,8 +197,8 @@ typedef struct drm_savage_private {
|
||||||
} drm_savage_private_t;
|
} drm_savage_private_t;
|
||||||
|
|
||||||
/* ioctls */
|
/* ioctls */
|
||||||
extern int savage_bci_cmdbuf(DRM_IOCTL_ARGS);
|
extern int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int savage_bci_buffers(DRM_IOCTL_ARGS);
|
extern int savage_bci_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
|
|
||||||
/* BCI functions */
|
/* BCI functions */
|
||||||
extern uint16_t savage_bci_emit_event(drm_savage_private_t * dev_priv,
|
extern uint16_t savage_bci_emit_event(drm_savage_private_t * dev_priv,
|
||||||
|
|
|
@ -953,13 +953,12 @@ static int savage_dispatch_draw(drm_savage_private_t * dev_priv,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int savage_bci_cmdbuf(DRM_IOCTL_ARGS)
|
int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_savage_private_t *dev_priv = dev->dev_private;
|
drm_savage_private_t *dev_priv = dev->dev_private;
|
||||||
struct drm_device_dma *dma = dev->dma;
|
struct drm_device_dma *dma = dev->dma;
|
||||||
struct drm_buf *dmabuf;
|
struct drm_buf *dmabuf;
|
||||||
drm_savage_cmdbuf_t cmdbuf;
|
drm_savage_cmdbuf_t *cmdbuf = data;
|
||||||
drm_savage_cmd_header_t *kcmd_addr = NULL;
|
drm_savage_cmd_header_t *kcmd_addr = NULL;
|
||||||
drm_savage_cmd_header_t *first_draw_cmd;
|
drm_savage_cmd_header_t *first_draw_cmd;
|
||||||
unsigned int *kvb_addr = NULL;
|
unsigned int *kvb_addr = NULL;
|
||||||
|
@ -971,17 +970,14 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(cmdbuf, (drm_savage_cmdbuf_t __user *) data,
|
|
||||||
sizeof(cmdbuf));
|
|
||||||
|
|
||||||
if (dma && dma->buflist) {
|
if (dma && dma->buflist) {
|
||||||
if (cmdbuf.dma_idx > dma->buf_count) {
|
if (cmdbuf->dma_idx > dma->buf_count) {
|
||||||
DRM_ERROR
|
DRM_ERROR
|
||||||
("vertex buffer index %u out of range (0-%u)\n",
|
("vertex buffer index %u out of range (0-%u)\n",
|
||||||
cmdbuf.dma_idx, dma->buf_count - 1);
|
cmdbuf->dma_idx, dma->buf_count - 1);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
dmabuf = dma->buflist[cmdbuf.dma_idx];
|
dmabuf = dma->buflist[cmdbuf->dma_idx];
|
||||||
} else {
|
} else {
|
||||||
dmabuf = NULL;
|
dmabuf = NULL;
|
||||||
}
|
}
|
||||||
|
@ -991,47 +987,47 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS)
|
||||||
* COPY_FROM_USER_UNCHECKED when done in other drivers, and is correct
|
* COPY_FROM_USER_UNCHECKED when done in other drivers, and is correct
|
||||||
* for locking on FreeBSD.
|
* for locking on FreeBSD.
|
||||||
*/
|
*/
|
||||||
if (cmdbuf.size) {
|
if (cmdbuf->size) {
|
||||||
kcmd_addr = drm_alloc(cmdbuf.size * 8, DRM_MEM_DRIVER);
|
kcmd_addr = drm_alloc(cmdbuf->size * 8, DRM_MEM_DRIVER);
|
||||||
if (kcmd_addr == NULL)
|
if (kcmd_addr == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if (DRM_COPY_FROM_USER(kcmd_addr, cmdbuf.cmd_addr,
|
if (DRM_COPY_FROM_USER(kcmd_addr, cmdbuf->cmd_addr,
|
||||||
cmdbuf.size * 8))
|
cmdbuf->size * 8))
|
||||||
{
|
{
|
||||||
drm_free(kcmd_addr, cmdbuf.size * 8, DRM_MEM_DRIVER);
|
drm_free(kcmd_addr, cmdbuf->size * 8, DRM_MEM_DRIVER);
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
cmdbuf.cmd_addr = kcmd_addr;
|
cmdbuf->cmd_addr = kcmd_addr;
|
||||||
}
|
}
|
||||||
if (cmdbuf.vb_size) {
|
if (cmdbuf->vb_size) {
|
||||||
kvb_addr = drm_alloc(cmdbuf.vb_size, DRM_MEM_DRIVER);
|
kvb_addr = drm_alloc(cmdbuf->vb_size, DRM_MEM_DRIVER);
|
||||||
if (kvb_addr == NULL) {
|
if (kvb_addr == NULL) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DRM_COPY_FROM_USER(kvb_addr, cmdbuf.vb_addr,
|
if (DRM_COPY_FROM_USER(kvb_addr, cmdbuf->vb_addr,
|
||||||
cmdbuf.vb_size)) {
|
cmdbuf->vb_size)) {
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
cmdbuf.vb_addr = kvb_addr;
|
cmdbuf->vb_addr = kvb_addr;
|
||||||
}
|
}
|
||||||
if (cmdbuf.nbox) {
|
if (cmdbuf->nbox) {
|
||||||
kbox_addr = drm_alloc(cmdbuf.nbox * sizeof(struct drm_clip_rect),
|
kbox_addr = drm_alloc(cmdbuf->nbox * sizeof(struct drm_clip_rect),
|
||||||
DRM_MEM_DRIVER);
|
DRM_MEM_DRIVER);
|
||||||
if (kbox_addr == NULL) {
|
if (kbox_addr == NULL) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DRM_COPY_FROM_USER(kbox_addr, cmdbuf.box_addr,
|
if (DRM_COPY_FROM_USER(kbox_addr, cmdbuf->box_addr,
|
||||||
cmdbuf.nbox * sizeof(struct drm_clip_rect))) {
|
cmdbuf->nbox * sizeof(struct drm_clip_rect))) {
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
cmdbuf.box_addr = kbox_addr;
|
cmdbuf->box_addr = kbox_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure writes to DMA buffers are finished before sending
|
/* Make sure writes to DMA buffers are finished before sending
|
||||||
|
@ -1044,10 +1040,10 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
first_draw_cmd = NULL;
|
first_draw_cmd = NULL;
|
||||||
while (i < cmdbuf.size) {
|
while (i < cmdbuf->size) {
|
||||||
drm_savage_cmd_header_t cmd_header;
|
drm_savage_cmd_header_t cmd_header;
|
||||||
cmd_header = *(drm_savage_cmd_header_t *)cmdbuf.cmd_addr;
|
cmd_header = *(drm_savage_cmd_header_t *)cmdbuf->cmd_addr;
|
||||||
cmdbuf.cmd_addr++;
|
cmdbuf->cmd_addr++;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
/* Group drawing commands with same state to minimize
|
/* Group drawing commands with same state to minimize
|
||||||
|
@ -1057,7 +1053,7 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS)
|
||||||
case SAVAGE_CMD_DMA_IDX:
|
case SAVAGE_CMD_DMA_IDX:
|
||||||
case SAVAGE_CMD_VB_IDX:
|
case SAVAGE_CMD_VB_IDX:
|
||||||
j = (cmd_header.idx.count + 3) / 4;
|
j = (cmd_header.idx.count + 3) / 4;
|
||||||
if (i + j > cmdbuf.size) {
|
if (i + j > cmdbuf->size) {
|
||||||
DRM_ERROR("indexed drawing command extends "
|
DRM_ERROR("indexed drawing command extends "
|
||||||
"beyond end of command buffer\n");
|
"beyond end of command buffer\n");
|
||||||
DMA_FLUSH();
|
DMA_FLUSH();
|
||||||
|
@ -1067,18 +1063,18 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS)
|
||||||
case SAVAGE_CMD_DMA_PRIM:
|
case SAVAGE_CMD_DMA_PRIM:
|
||||||
case SAVAGE_CMD_VB_PRIM:
|
case SAVAGE_CMD_VB_PRIM:
|
||||||
if (!first_draw_cmd)
|
if (!first_draw_cmd)
|
||||||
first_draw_cmd = cmdbuf.cmd_addr - 1;
|
first_draw_cmd = cmdbuf->cmd_addr - 1;
|
||||||
cmdbuf.cmd_addr += j;
|
cmdbuf->cmd_addr += j;
|
||||||
i += j;
|
i += j;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (first_draw_cmd) {
|
if (first_draw_cmd) {
|
||||||
ret = savage_dispatch_draw(
|
ret = savage_dispatch_draw(
|
||||||
dev_priv, first_draw_cmd,
|
dev_priv, first_draw_cmd,
|
||||||
cmdbuf.cmd_addr - 1,
|
cmdbuf->cmd_addr - 1,
|
||||||
dmabuf, cmdbuf.vb_addr, cmdbuf.vb_size,
|
dmabuf, cmdbuf->vb_addr, cmdbuf->vb_size,
|
||||||
cmdbuf.vb_stride,
|
cmdbuf->vb_stride,
|
||||||
cmdbuf.nbox, cmdbuf.box_addr);
|
cmdbuf->nbox, cmdbuf->box_addr);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return ret;
|
return ret;
|
||||||
first_draw_cmd = NULL;
|
first_draw_cmd = NULL;
|
||||||
|
@ -1090,7 +1086,7 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS)
|
||||||
switch (cmd_header.cmd.cmd) {
|
switch (cmd_header.cmd.cmd) {
|
||||||
case SAVAGE_CMD_STATE:
|
case SAVAGE_CMD_STATE:
|
||||||
j = (cmd_header.state.count + 1) / 2;
|
j = (cmd_header.state.count + 1) / 2;
|
||||||
if (i + j > cmdbuf.size) {
|
if (i + j > cmdbuf->size) {
|
||||||
DRM_ERROR("command SAVAGE_CMD_STATE extends "
|
DRM_ERROR("command SAVAGE_CMD_STATE extends "
|
||||||
"beyond end of command buffer\n");
|
"beyond end of command buffer\n");
|
||||||
DMA_FLUSH();
|
DMA_FLUSH();
|
||||||
|
@ -1098,12 +1094,12 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
ret = savage_dispatch_state(dev_priv, &cmd_header,
|
ret = savage_dispatch_state(dev_priv, &cmd_header,
|
||||||
(const uint32_t *)cmdbuf.cmd_addr);
|
(const uint32_t *)cmdbuf->cmd_addr);
|
||||||
cmdbuf.cmd_addr += j;
|
cmdbuf->cmd_addr += j;
|
||||||
i += j;
|
i += j;
|
||||||
break;
|
break;
|
||||||
case SAVAGE_CMD_CLEAR:
|
case SAVAGE_CMD_CLEAR:
|
||||||
if (i + 1 > cmdbuf.size) {
|
if (i + 1 > cmdbuf->size) {
|
||||||
DRM_ERROR("command SAVAGE_CMD_CLEAR extends "
|
DRM_ERROR("command SAVAGE_CMD_CLEAR extends "
|
||||||
"beyond end of command buffer\n");
|
"beyond end of command buffer\n");
|
||||||
DMA_FLUSH();
|
DMA_FLUSH();
|
||||||
|
@ -1111,17 +1107,19 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
ret = savage_dispatch_clear(dev_priv, &cmd_header,
|
ret = savage_dispatch_clear(dev_priv, &cmd_header,
|
||||||
cmdbuf.cmd_addr,
|
cmdbuf->cmd_addr,
|
||||||
cmdbuf.nbox, cmdbuf.box_addr);
|
cmdbuf->nbox,
|
||||||
cmdbuf.cmd_addr++;
|
cmdbuf->box_addr);
|
||||||
|
cmdbuf->cmd_addr++;
|
||||||
i++;
|
i++;
|
||||||
break;
|
break;
|
||||||
case SAVAGE_CMD_SWAP:
|
case SAVAGE_CMD_SWAP:
|
||||||
ret = savage_dispatch_swap(dev_priv, cmdbuf.nbox,
|
ret = savage_dispatch_swap(dev_priv, cmdbuf->nbox,
|
||||||
cmdbuf.box_addr);
|
cmdbuf->box_addr);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DRM_ERROR("invalid command 0x%x\n", cmd_header.cmd.cmd);
|
DRM_ERROR("invalid command 0x%x\n",
|
||||||
|
cmd_header.cmd.cmd);
|
||||||
DMA_FLUSH();
|
DMA_FLUSH();
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -1135,9 +1133,9 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
if (first_draw_cmd) {
|
if (first_draw_cmd) {
|
||||||
ret = savage_dispatch_draw (
|
ret = savage_dispatch_draw (
|
||||||
dev_priv, first_draw_cmd, cmdbuf.cmd_addr, dmabuf,
|
dev_priv, first_draw_cmd, cmdbuf->cmd_addr, dmabuf,
|
||||||
cmdbuf.vb_addr, cmdbuf.vb_size, cmdbuf.vb_stride,
|
cmdbuf->vb_addr, cmdbuf->vb_size, cmdbuf->vb_stride,
|
||||||
cmdbuf.nbox, cmdbuf.box_addr);
|
cmdbuf->nbox, cmdbuf->box_addr);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
DMA_FLUSH();
|
DMA_FLUSH();
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -1146,7 +1144,7 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
DMA_FLUSH();
|
DMA_FLUSH();
|
||||||
|
|
||||||
if (dmabuf && cmdbuf.discard) {
|
if (dmabuf && cmdbuf->discard) {
|
||||||
drm_savage_buf_priv_t *buf_priv = dmabuf->dev_private;
|
drm_savage_buf_priv_t *buf_priv = dmabuf->dev_private;
|
||||||
uint16_t event;
|
uint16_t event;
|
||||||
event = savage_bci_emit_event(dev_priv, SAVAGE_WAIT_3D);
|
event = savage_bci_emit_event(dev_priv, SAVAGE_WAIT_3D);
|
||||||
|
@ -1156,9 +1154,9 @@ int savage_bci_cmdbuf(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
done:
|
done:
|
||||||
/* If we didn't need to allocate them, these'll be NULL */
|
/* If we didn't need to allocate them, these'll be NULL */
|
||||||
drm_free(kcmd_addr, cmdbuf.size * 8, DRM_MEM_DRIVER);
|
drm_free(kcmd_addr, cmdbuf->size * 8, DRM_MEM_DRIVER);
|
||||||
drm_free(kvb_addr, cmdbuf.vb_size, DRM_MEM_DRIVER);
|
drm_free(kvb_addr, cmdbuf->vb_size, DRM_MEM_DRIVER);
|
||||||
drm_free(kbox_addr, cmdbuf.nbox * sizeof(struct drm_clip_rect),
|
drm_free(kbox_addr, cmdbuf->nbox * sizeof(struct drm_clip_rect),
|
||||||
DRM_MEM_DRIVER);
|
DRM_MEM_DRIVER);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -67,7 +67,7 @@ extern void sis_reclaim_buffers_locked(struct drm_device *dev,
|
||||||
struct drm_file *file_priv);
|
struct drm_file *file_priv);
|
||||||
extern void sis_lastclose(struct drm_device *dev);
|
extern void sis_lastclose(struct drm_device *dev);
|
||||||
|
|
||||||
extern drm_ioctl_desc_t sis_ioctls[];
|
extern struct drm_ioctl_desc sis_ioctls[];
|
||||||
extern int sis_max_ioctl;
|
extern int sis_max_ioctl;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -82,15 +82,12 @@ static unsigned long sis_sman_mm_offset(void *private, void *ref)
|
||||||
|
|
||||||
#endif /* CONFIG_FB_SIS */
|
#endif /* CONFIG_FB_SIS */
|
||||||
|
|
||||||
static int sis_fb_init(DRM_IOCTL_ARGS)
|
static int sis_fb_init(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_sis_private_t *dev_priv = dev->dev_private;
|
drm_sis_private_t *dev_priv = dev->dev_private;
|
||||||
drm_sis_fb_t fb;
|
drm_sis_fb_t *fb = data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(fb, (drm_sis_fb_t __user *) data, sizeof(fb));
|
|
||||||
|
|
||||||
mutex_lock(&dev->struct_mutex);
|
mutex_lock(&dev->struct_mutex);
|
||||||
#if defined(CONFIG_FB_SIS)
|
#if defined(CONFIG_FB_SIS)
|
||||||
{
|
{
|
||||||
|
@ -105,7 +102,7 @@ static int sis_fb_init(DRM_IOCTL_ARGS)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
ret = drm_sman_set_range(&dev_priv->sman, VIDEO_TYPE, 0,
|
ret = drm_sman_set_range(&dev_priv->sman, VIDEO_TYPE, 0,
|
||||||
fb.size >> SIS_MM_ALIGN_SHIFT);
|
fb->size >> SIS_MM_ALIGN_SHIFT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
@ -115,25 +112,22 @@ static int sis_fb_init(DRM_IOCTL_ARGS)
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_priv->vram_initialized = 1;
|
dev_priv->vram_initialized = 1;
|
||||||
dev_priv->vram_offset = fb.offset;
|
dev_priv->vram_offset = fb->offset;
|
||||||
|
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
DRM_DEBUG("offset = %u, size = %u", fb.offset, fb.size);
|
DRM_DEBUG("offset = %u, size = %u", fb->offset, fb->size);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file_priv,
|
static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file_priv,
|
||||||
unsigned long data, int pool)
|
void *data, int pool)
|
||||||
{
|
{
|
||||||
drm_sis_private_t *dev_priv = dev->dev_private;
|
drm_sis_private_t *dev_priv = dev->dev_private;
|
||||||
drm_sis_mem_t __user *argp = (drm_sis_mem_t __user *) data;
|
drm_sis_mem_t *mem = data;
|
||||||
drm_sis_mem_t mem;
|
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
struct drm_memblock_item *item;
|
struct drm_memblock_item *item;
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(mem, argp, sizeof(mem));
|
|
||||||
|
|
||||||
mutex_lock(&dev->struct_mutex);
|
mutex_lock(&dev->struct_mutex);
|
||||||
|
|
||||||
if (0 == ((pool == 0) ? dev_priv->vram_initialized :
|
if (0 == ((pool == 0) ? dev_priv->vram_initialized :
|
||||||
|
@ -143,70 +137,62 @@ static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file_priv,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
mem.size = (mem.size + SIS_MM_ALIGN_MASK) >> SIS_MM_ALIGN_SHIFT;
|
mem->size = (mem->size + SIS_MM_ALIGN_MASK) >> SIS_MM_ALIGN_SHIFT;
|
||||||
item = drm_sman_alloc(&dev_priv->sman, pool, mem.size, 0,
|
item = drm_sman_alloc(&dev_priv->sman, pool, mem->size, 0,
|
||||||
(unsigned long)file_priv);
|
(unsigned long)file_priv);
|
||||||
|
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
if (item) {
|
if (item) {
|
||||||
mem.offset = ((pool == 0) ?
|
mem->offset = ((pool == 0) ?
|
||||||
dev_priv->vram_offset : dev_priv->agp_offset) +
|
dev_priv->vram_offset : dev_priv->agp_offset) +
|
||||||
(item->mm->
|
(item->mm->
|
||||||
offset(item->mm, item->mm_info) << SIS_MM_ALIGN_SHIFT);
|
offset(item->mm, item->mm_info) << SIS_MM_ALIGN_SHIFT);
|
||||||
mem.free = item->user_hash.key;
|
mem->free = item->user_hash.key;
|
||||||
mem.size = mem.size << SIS_MM_ALIGN_SHIFT;
|
mem->size = mem->size << SIS_MM_ALIGN_SHIFT;
|
||||||
} else {
|
} else {
|
||||||
mem.offset = 0;
|
mem->offset = 0;
|
||||||
mem.size = 0;
|
mem->size = 0;
|
||||||
mem.free = 0;
|
mem->free = 0;
|
||||||
retval = -ENOMEM;
|
retval = -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_TO_USER_IOCTL(argp, mem, sizeof(mem));
|
DRM_DEBUG("alloc %d, size = %d, offset = %d\n", pool, mem->size,
|
||||||
|
mem->offset);
|
||||||
DRM_DEBUG("alloc %d, size = %d, offset = %d\n", pool, mem.size,
|
|
||||||
mem.offset);
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sis_drm_free(DRM_IOCTL_ARGS)
|
static int sis_drm_free(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_sis_private_t *dev_priv = dev->dev_private;
|
drm_sis_private_t *dev_priv = dev->dev_private;
|
||||||
drm_sis_mem_t mem;
|
drm_sis_mem_t *mem = data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(mem, (drm_sis_mem_t __user *) data,
|
|
||||||
sizeof(mem));
|
|
||||||
|
|
||||||
mutex_lock(&dev->struct_mutex);
|
mutex_lock(&dev->struct_mutex);
|
||||||
ret = drm_sman_free_key(&dev_priv->sman, mem.free);
|
ret = drm_sman_free_key(&dev_priv->sman, mem->free);
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
DRM_DEBUG("free = 0x%lx\n", mem.free);
|
DRM_DEBUG("free = 0x%lx\n", mem->free);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sis_fb_alloc(DRM_IOCTL_ARGS)
|
static int sis_fb_alloc(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
return sis_drm_alloc(dev, file_priv, data, VIDEO_TYPE);
|
return sis_drm_alloc(dev, file_priv, data, VIDEO_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sis_ioctl_agp_init(DRM_IOCTL_ARGS)
|
static int sis_ioctl_agp_init(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_sis_private_t *dev_priv = dev->dev_private;
|
drm_sis_private_t *dev_priv = dev->dev_private;
|
||||||
drm_sis_agp_t agp;
|
drm_sis_agp_t *agp = data;
|
||||||
int ret;
|
int ret;
|
||||||
dev_priv = dev->dev_private;
|
dev_priv = dev->dev_private;
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(agp, (drm_sis_agp_t __user *) data,
|
|
||||||
sizeof(agp));
|
|
||||||
mutex_lock(&dev->struct_mutex);
|
mutex_lock(&dev->struct_mutex);
|
||||||
ret = drm_sman_set_range(&dev_priv->sman, AGP_TYPE, 0,
|
ret = drm_sman_set_range(&dev_priv->sman, AGP_TYPE, 0,
|
||||||
agp.size >> SIS_MM_ALIGN_SHIFT);
|
agp->size >> SIS_MM_ALIGN_SHIFT);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
DRM_ERROR("AGP memory manager initialisation error\n");
|
DRM_ERROR("AGP memory manager initialisation error\n");
|
||||||
|
@ -215,16 +201,16 @@ static int sis_ioctl_agp_init(DRM_IOCTL_ARGS)
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_priv->agp_initialized = 1;
|
dev_priv->agp_initialized = 1;
|
||||||
dev_priv->agp_offset = agp.offset;
|
dev_priv->agp_offset = agp->offset;
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
|
|
||||||
DRM_DEBUG("offset = %u, size = %u", agp.offset, agp.size);
|
DRM_DEBUG("offset = %u, size = %u", agp->offset, agp->size);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sis_ioctl_agp_alloc(DRM_IOCTL_ARGS)
|
static int sis_ioctl_agp_alloc(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
|
|
||||||
return sis_drm_alloc(dev, file_priv, data, AGP_TYPE);
|
return sis_drm_alloc(dev, file_priv, data, AGP_TYPE);
|
||||||
}
|
}
|
||||||
|
@ -334,15 +320,13 @@ void sis_reclaim_buffers_locked(struct drm_device * dev,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
drm_ioctl_desc_t sis_ioctls[] = {
|
struct drm_ioctl_desc sis_ioctls[] = {
|
||||||
[DRM_IOCTL_NR(DRM_SIS_FB_ALLOC)] = {sis_fb_alloc, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_SIS_FB_ALLOC, sis_fb_alloc, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_SIS_FB_FREE)] = {sis_drm_free, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_SIS_FB_FREE, sis_drm_free, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_SIS_AGP_INIT)] =
|
DRM_IOCTL_DEF(DRM_SIS_AGP_INIT, sis_ioctl_agp_init, DRM_AUTH | DRM_MASTER | DRM_ROOT_ONLY),
|
||||||
{sis_ioctl_agp_init, DRM_AUTH | DRM_MASTER | DRM_ROOT_ONLY},
|
DRM_IOCTL_DEF(DRM_SIS_AGP_ALLOC, sis_ioctl_agp_alloc, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_SIS_AGP_ALLOC)] = {sis_ioctl_agp_alloc, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_SIS_AGP_FREE, sis_drm_free, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_SIS_AGP_FREE)] = {sis_drm_free, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_SIS_FB_INIT, sis_fb_init, DRM_AUTH | DRM_MASTER | DRM_ROOT_ONLY),
|
||||||
[DRM_IOCTL_NR(DRM_SIS_FB_INIT)] =
|
|
||||||
{sis_fb_init, DRM_AUTH | DRM_MASTER | DRM_ROOT_ONLY}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int sis_max_ioctl = DRM_ARRAY_SIZE(sis_ioctls);
|
int sis_max_ioctl = DRM_ARRAY_SIZE(sis_ioctls);
|
||||||
|
|
|
@ -227,22 +227,18 @@ static int via_initialize(struct drm_device * dev,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int via_dma_init(DRM_IOCTL_ARGS)
|
static int via_dma_init(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
|
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
|
||||||
drm_via_dma_init_t init;
|
drm_via_dma_init_t *init = data;
|
||||||
int retcode = 0;
|
int retcode = 0;
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(init, (drm_via_dma_init_t __user *) data,
|
switch (init->func) {
|
||||||
sizeof(init));
|
|
||||||
|
|
||||||
switch (init.func) {
|
|
||||||
case VIA_INIT_DMA:
|
case VIA_INIT_DMA:
|
||||||
if (!DRM_SUSER(DRM_CURPROC))
|
if (!DRM_SUSER(DRM_CURPROC))
|
||||||
retcode = -EPERM;
|
retcode = -EPERM;
|
||||||
else
|
else
|
||||||
retcode = via_initialize(dev, dev_priv, &init);
|
retcode = via_initialize(dev, dev_priv, init);
|
||||||
break;
|
break;
|
||||||
case VIA_CLEANUP_DMA:
|
case VIA_CLEANUP_DMA:
|
||||||
if (!DRM_SUSER(DRM_CURPROC))
|
if (!DRM_SUSER(DRM_CURPROC))
|
||||||
|
@ -326,29 +322,25 @@ int via_driver_dma_quiescent(struct drm_device * dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int via_flush_ioctl(DRM_IOCTL_ARGS)
|
static int via_flush_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
return via_driver_dma_quiescent(dev);
|
return via_driver_dma_quiescent(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int via_cmdbuffer(DRM_IOCTL_ARGS)
|
static int via_cmdbuffer(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
drm_via_cmdbuffer_t *cmdbuf = data;
|
||||||
drm_via_cmdbuffer_t cmdbuf;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(cmdbuf, (drm_via_cmdbuffer_t __user *) data,
|
DRM_DEBUG("via cmdbuffer, buf %p size %lu\n", cmdbuf->buf,
|
||||||
sizeof(cmdbuf));
|
cmdbuf->size);
|
||||||
|
|
||||||
DRM_DEBUG("via cmdbuffer, buf %p size %lu\n", cmdbuf.buf, cmdbuf.size);
|
ret = via_dispatch_cmdbuffer(dev, cmdbuf);
|
||||||
|
|
||||||
ret = via_dispatch_cmdbuffer(dev, &cmdbuf);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -380,21 +372,17 @@ static int via_dispatch_pci_cmdbuffer(struct drm_device * dev,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int via_pci_cmdbuffer(DRM_IOCTL_ARGS)
|
static int via_pci_cmdbuffer(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
drm_via_cmdbuffer_t *cmdbuf = data;
|
||||||
drm_via_cmdbuffer_t cmdbuf;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
LOCK_TEST_WITH_RETURN(dev, file_priv);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(cmdbuf, (drm_via_cmdbuffer_t __user *) data,
|
DRM_DEBUG("via_pci_cmdbuffer, buf %p size %lu\n", cmdbuf->buf,
|
||||||
sizeof(cmdbuf));
|
cmdbuf->size);
|
||||||
|
|
||||||
DRM_DEBUG("via_pci_cmdbuffer, buf %p size %lu\n", cmdbuf.buf,
|
ret = via_dispatch_pci_cmdbuffer(dev, cmdbuf);
|
||||||
cmdbuf.size);
|
|
||||||
|
|
||||||
ret = via_dispatch_pci_cmdbuffer(dev, &cmdbuf);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -653,10 +641,9 @@ static void via_cmdbuf_reset(drm_via_private_t * dev_priv)
|
||||||
* User interface to the space and lag functions.
|
* User interface to the space and lag functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int via_cmdbuf_size(DRM_IOCTL_ARGS)
|
static int via_cmdbuf_size(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
drm_via_cmdbuf_size_t *d_siz = data;
|
||||||
drm_via_cmdbuf_size_t d_siz;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
uint32_t tmp_size, count;
|
uint32_t tmp_size, count;
|
||||||
drm_via_private_t *dev_priv;
|
drm_via_private_t *dev_priv;
|
||||||
|
@ -672,16 +659,13 @@ static int via_cmdbuf_size(DRM_IOCTL_ARGS)
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(d_siz, (drm_via_cmdbuf_size_t __user *) data,
|
|
||||||
sizeof(d_siz));
|
|
||||||
|
|
||||||
count = 1000000;
|
count = 1000000;
|
||||||
tmp_size = d_siz.size;
|
tmp_size = d_siz->size;
|
||||||
switch (d_siz.func) {
|
switch (d_siz->func) {
|
||||||
case VIA_CMDBUF_SPACE:
|
case VIA_CMDBUF_SPACE:
|
||||||
while (((tmp_size = via_cmdbuf_space(dev_priv)) < d_siz.size)
|
while (((tmp_size = via_cmdbuf_space(dev_priv)) < d_siz->size)
|
||||||
&& count--) {
|
&& count--) {
|
||||||
if (!d_siz.wait) {
|
if (!d_siz->wait) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -691,9 +675,9 @@ static int via_cmdbuf_size(DRM_IOCTL_ARGS)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case VIA_CMDBUF_LAG:
|
case VIA_CMDBUF_LAG:
|
||||||
while (((tmp_size = via_cmdbuf_lag(dev_priv)) > d_siz.size)
|
while (((tmp_size = via_cmdbuf_lag(dev_priv)) > d_siz->size)
|
||||||
&& count--) {
|
&& count--) {
|
||||||
if (!d_siz.wait) {
|
if (!d_siz->wait) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -705,28 +689,26 @@ static int via_cmdbuf_size(DRM_IOCTL_ARGS)
|
||||||
default:
|
default:
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
}
|
}
|
||||||
d_siz.size = tmp_size;
|
d_siz->size = tmp_size;
|
||||||
|
|
||||||
DRM_COPY_TO_USER_IOCTL((drm_via_cmdbuf_size_t __user *) data, d_siz,
|
|
||||||
sizeof(d_siz));
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
drm_ioctl_desc_t via_ioctls[] = {
|
struct drm_ioctl_desc via_ioctls[] = {
|
||||||
[DRM_IOCTL_NR(DRM_VIA_ALLOCMEM)] = {via_mem_alloc, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_VIA_ALLOCMEM, via_mem_alloc, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_VIA_FREEMEM)] = {via_mem_free, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_VIA_FREEMEM, via_mem_free, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_VIA_AGP_INIT)] = {via_agp_init, DRM_AUTH|DRM_MASTER},
|
DRM_IOCTL_DEF(DRM_VIA_AGP_INIT, via_agp_init, DRM_AUTH|DRM_MASTER),
|
||||||
[DRM_IOCTL_NR(DRM_VIA_FB_INIT)] = {via_fb_init, DRM_AUTH|DRM_MASTER},
|
DRM_IOCTL_DEF(DRM_VIA_FB_INIT, via_fb_init, DRM_AUTH|DRM_MASTER),
|
||||||
[DRM_IOCTL_NR(DRM_VIA_MAP_INIT)] = {via_map_init, DRM_AUTH|DRM_MASTER},
|
DRM_IOCTL_DEF(DRM_VIA_MAP_INIT, via_map_init, DRM_AUTH|DRM_MASTER),
|
||||||
[DRM_IOCTL_NR(DRM_VIA_DEC_FUTEX)] = {via_decoder_futex, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_VIA_DEC_FUTEX, via_decoder_futex, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_VIA_DMA_INIT)] = {via_dma_init, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_VIA_DMA_INIT, via_dma_init, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_VIA_CMDBUFFER)] = {via_cmdbuffer, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_VIA_CMDBUFFER, via_cmdbuffer, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_VIA_FLUSH)] = {via_flush_ioctl, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_VIA_FLUSH, via_flush_ioctl, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_VIA_PCICMD)] = {via_pci_cmdbuffer, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_VIA_PCICMD, via_pci_cmdbuffer, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_VIA_CMDBUF_SIZE)] = {via_cmdbuf_size, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_VIA_CMDBUF_SIZE, via_cmdbuf_size, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_VIA_WAIT_IRQ)] = {via_wait_irq, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_VIA_WAIT_IRQ, via_wait_irq, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_VIA_DMA_BLIT)] = {via_dma_blit, DRM_AUTH},
|
DRM_IOCTL_DEF(DRM_VIA_DMA_BLIT, via_dma_blit, DRM_AUTH),
|
||||||
[DRM_IOCTL_NR(DRM_VIA_BLIT_SYNC)] = {via_dma_blit_sync, DRM_AUTH}
|
DRM_IOCTL_DEF(DRM_VIA_BLIT_SYNC, via_dma_blit_sync, DRM_AUTH)
|
||||||
};
|
};
|
||||||
|
|
||||||
int via_max_ioctl = DRM_ARRAY_SIZE(via_ioctls);
|
int via_max_ioctl = DRM_ARRAY_SIZE(via_ioctls);
|
||||||
|
|
|
@ -781,18 +781,15 @@ via_dmablit(struct drm_device *dev, drm_via_dmablit_t *xfer)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
via_dma_blit_sync( DRM_IOCTL_ARGS )
|
via_dma_blit_sync( struct drm_device *dev, void *data, struct drm_file *file_priv )
|
||||||
{
|
{
|
||||||
drm_via_blitsync_t sync;
|
drm_via_blitsync_t *sync = data;
|
||||||
int err;
|
int err;
|
||||||
DRM_DEVICE;
|
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(sync, (drm_via_blitsync_t *)data, sizeof(sync));
|
if (sync->engine >= VIA_NUM_BLIT_ENGINES)
|
||||||
|
|
||||||
if (sync.engine >= VIA_NUM_BLIT_ENGINES)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
err = via_dmablit_sync(dev, sync.sync_handle, sync.engine);
|
err = via_dmablit_sync(dev, sync->sync_handle, sync->engine);
|
||||||
|
|
||||||
if (-EINTR == err)
|
if (-EINTR == err)
|
||||||
err = -EAGAIN;
|
err = -EAGAIN;
|
||||||
|
@ -808,17 +805,12 @@ via_dma_blit_sync( DRM_IOCTL_ARGS )
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
via_dma_blit( DRM_IOCTL_ARGS )
|
via_dma_blit( struct drm_device *dev, void *data, struct drm_file *file_priv )
|
||||||
{
|
{
|
||||||
drm_via_dmablit_t xfer;
|
drm_via_dmablit_t *xfer = data;
|
||||||
int err;
|
int err;
|
||||||
DRM_DEVICE;
|
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(xfer, (drm_via_dmablit_t __user *)data, sizeof(xfer));
|
err = via_dmablit(dev, xfer);
|
||||||
|
|
||||||
err = via_dmablit(dev, &xfer);
|
|
||||||
|
|
||||||
DRM_COPY_TO_USER_IOCTL((void __user *)data, xfer, sizeof(xfer));
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,18 +110,18 @@ enum via_family {
|
||||||
#define VIA_READ8(reg) DRM_READ8(VIA_BASE, reg)
|
#define VIA_READ8(reg) DRM_READ8(VIA_BASE, reg)
|
||||||
#define VIA_WRITE8(reg,val) DRM_WRITE8(VIA_BASE, reg, val)
|
#define VIA_WRITE8(reg,val) DRM_WRITE8(VIA_BASE, reg, val)
|
||||||
|
|
||||||
extern drm_ioctl_desc_t via_ioctls[];
|
extern struct drm_ioctl_desc via_ioctls[];
|
||||||
extern int via_max_ioctl;
|
extern int via_max_ioctl;
|
||||||
|
|
||||||
extern int via_fb_init(DRM_IOCTL_ARGS);
|
extern int via_fb_init(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int via_mem_alloc(DRM_IOCTL_ARGS);
|
extern int via_mem_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int via_mem_free(DRM_IOCTL_ARGS);
|
extern int via_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int via_agp_init(DRM_IOCTL_ARGS);
|
extern int via_agp_init(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int via_map_init(DRM_IOCTL_ARGS);
|
extern int via_map_init(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int via_decoder_futex(DRM_IOCTL_ARGS);
|
extern int via_decoder_futex(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int via_wait_irq(DRM_IOCTL_ARGS);
|
extern int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv);
|
||||||
extern int via_dma_blit_sync( DRM_IOCTL_ARGS );
|
extern int via_dma_blit_sync( struct drm_device *dev, void *data, struct drm_file *file_priv );
|
||||||
extern int via_dma_blit( DRM_IOCTL_ARGS );
|
extern int via_dma_blit( struct drm_device *dev, void *data, struct drm_file *file_priv );
|
||||||
|
|
||||||
extern int via_driver_load(struct drm_device *dev, unsigned long chipset);
|
extern int via_driver_load(struct drm_device *dev, unsigned long chipset);
|
||||||
extern int via_driver_unload(struct drm_device *dev);
|
extern int via_driver_unload(struct drm_device *dev);
|
||||||
|
|
|
@ -331,11 +331,9 @@ void via_driver_irq_uninstall(struct drm_device * dev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int via_wait_irq(DRM_IOCTL_ARGS)
|
int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
drm_via_irqwait_t *irqwait = data;
|
||||||
drm_via_irqwait_t __user *argp = (void __user *)data;
|
|
||||||
drm_via_irqwait_t irqwait;
|
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
|
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
|
||||||
|
@ -345,40 +343,37 @@ int via_wait_irq(DRM_IOCTL_ARGS)
|
||||||
if (!dev->irq)
|
if (!dev->irq)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(irqwait, argp, sizeof(irqwait));
|
if (irqwait->request.irq >= dev_priv->num_irqs) {
|
||||||
if (irqwait.request.irq >= dev_priv->num_irqs) {
|
|
||||||
DRM_ERROR("%s Trying to wait on unknown irq %d\n", __FUNCTION__,
|
DRM_ERROR("%s Trying to wait on unknown irq %d\n", __FUNCTION__,
|
||||||
irqwait.request.irq);
|
irqwait->request.irq);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_irq += irqwait.request.irq;
|
cur_irq += irqwait->request.irq;
|
||||||
|
|
||||||
switch (irqwait.request.type & ~VIA_IRQ_FLAGS_MASK) {
|
switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
|
||||||
case VIA_IRQ_RELATIVE:
|
case VIA_IRQ_RELATIVE:
|
||||||
irqwait.request.sequence += atomic_read(&cur_irq->irq_received);
|
irqwait->request.sequence += atomic_read(&cur_irq->irq_received);
|
||||||
irqwait.request.type &= ~_DRM_VBLANK_RELATIVE;
|
irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
|
||||||
case VIA_IRQ_ABSOLUTE:
|
case VIA_IRQ_ABSOLUTE:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (irqwait.request.type & VIA_IRQ_SIGNAL) {
|
if (irqwait->request.type & VIA_IRQ_SIGNAL) {
|
||||||
DRM_ERROR("%s Signals on Via IRQs not implemented yet.\n",
|
DRM_ERROR("%s Signals on Via IRQs not implemented yet.\n",
|
||||||
__FUNCTION__);
|
__FUNCTION__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
force_sequence = (irqwait.request.type & VIA_IRQ_FORCE_SEQUENCE);
|
force_sequence = (irqwait->request.type & VIA_IRQ_FORCE_SEQUENCE);
|
||||||
|
|
||||||
ret = via_driver_irq_wait(dev, irqwait.request.irq, force_sequence,
|
ret = via_driver_irq_wait(dev, irqwait->request.irq, force_sequence,
|
||||||
&irqwait.request.sequence);
|
&irqwait->request.sequence);
|
||||||
do_gettimeofday(&now);
|
do_gettimeofday(&now);
|
||||||
irqwait.reply.tval_sec = now.tv_sec;
|
irqwait->reply.tval_sec = now.tv_sec;
|
||||||
irqwait.reply.tval_usec = now.tv_usec;
|
irqwait->reply.tval_usec = now.tv_usec;
|
||||||
|
|
||||||
DRM_COPY_TO_USER_IOCTL(argp, irqwait, sizeof(irqwait));
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,19 +75,15 @@ int via_do_cleanup_map(struct drm_device * dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int via_map_init(DRM_IOCTL_ARGS)
|
int via_map_init(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
drm_via_init_t *init = data;
|
||||||
drm_via_init_t init;
|
|
||||||
|
|
||||||
DRM_DEBUG("%s\n", __FUNCTION__);
|
DRM_DEBUG("%s\n", __FUNCTION__);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(init, (drm_via_init_t __user *) data,
|
switch (init->func) {
|
||||||
sizeof(init));
|
|
||||||
|
|
||||||
switch (init.func) {
|
|
||||||
case VIA_INIT_MAP:
|
case VIA_INIT_MAP:
|
||||||
return via_do_init_map(dev, &init);
|
return via_do_init_map(dev, init);
|
||||||
case VIA_CLEANUP_MAP:
|
case VIA_CLEANUP_MAP:
|
||||||
return via_do_cleanup_map(dev);
|
return via_do_cleanup_map(dev);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,18 +33,15 @@
|
||||||
#define VIA_MM_ALIGN_SHIFT 4
|
#define VIA_MM_ALIGN_SHIFT 4
|
||||||
#define VIA_MM_ALIGN_MASK ( (1 << VIA_MM_ALIGN_SHIFT) - 1)
|
#define VIA_MM_ALIGN_MASK ( (1 << VIA_MM_ALIGN_SHIFT) - 1)
|
||||||
|
|
||||||
int via_agp_init(DRM_IOCTL_ARGS)
|
int via_agp_init(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
drm_via_agp_t *agp = data;
|
||||||
drm_via_agp_t agp;
|
|
||||||
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
|
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(agp, (drm_via_agp_t __user *) data,
|
|
||||||
sizeof(agp));
|
|
||||||
mutex_lock(&dev->struct_mutex);
|
mutex_lock(&dev->struct_mutex);
|
||||||
ret = drm_sman_set_range(&dev_priv->sman, VIA_MEM_AGP, 0,
|
ret = drm_sman_set_range(&dev_priv->sman, VIA_MEM_AGP, 0,
|
||||||
agp.size >> VIA_MM_ALIGN_SHIFT);
|
agp->size >> VIA_MM_ALIGN_SHIFT);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
DRM_ERROR("AGP memory manager initialisation error\n");
|
DRM_ERROR("AGP memory manager initialisation error\n");
|
||||||
|
@ -53,25 +50,22 @@ int via_agp_init(DRM_IOCTL_ARGS)
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_priv->agp_initialized = 1;
|
dev_priv->agp_initialized = 1;
|
||||||
dev_priv->agp_offset = agp.offset;
|
dev_priv->agp_offset = agp->offset;
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
|
|
||||||
DRM_DEBUG("offset = %u, size = %u", agp.offset, agp.size);
|
DRM_DEBUG("offset = %u, size = %u", agp->offset, agp->size);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int via_fb_init(DRM_IOCTL_ARGS)
|
int via_fb_init(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
drm_via_fb_t *fb = data;
|
||||||
drm_via_fb_t fb;
|
|
||||||
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
|
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(fb, (drm_via_fb_t __user *) data, sizeof(fb));
|
|
||||||
|
|
||||||
mutex_lock(&dev->struct_mutex);
|
mutex_lock(&dev->struct_mutex);
|
||||||
ret = drm_sman_set_range(&dev_priv->sman, VIA_MEM_VIDEO, 0,
|
ret = drm_sman_set_range(&dev_priv->sman, VIA_MEM_VIDEO, 0,
|
||||||
fb.size >> VIA_MM_ALIGN_SHIFT);
|
fb->size >> VIA_MM_ALIGN_SHIFT);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
DRM_ERROR("VRAM memory manager initialisation error\n");
|
DRM_ERROR("VRAM memory manager initialisation error\n");
|
||||||
|
@ -80,10 +74,10 @@ int via_fb_init(DRM_IOCTL_ARGS)
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_priv->vram_initialized = 1;
|
dev_priv->vram_initialized = 1;
|
||||||
dev_priv->vram_offset = fb.offset;
|
dev_priv->vram_offset = fb->offset;
|
||||||
|
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
DRM_DEBUG("offset = %u, size = %u", fb.offset, fb.size);
|
DRM_DEBUG("offset = %u, size = %u", fb->offset, fb->size);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -121,25 +115,21 @@ void via_lastclose(struct drm_device *dev)
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
int via_mem_alloc(DRM_IOCTL_ARGS)
|
int via_mem_alloc(struct drm_device *dev, void *data,
|
||||||
|
struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
drm_via_mem_t *mem = data;
|
||||||
|
|
||||||
drm_via_mem_t mem;
|
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
struct drm_memblock_item *item;
|
struct drm_memblock_item *item;
|
||||||
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
|
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
|
||||||
unsigned long tmpSize;
|
unsigned long tmpSize;
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(mem, (drm_via_mem_t __user *) data,
|
if (mem->type > VIA_MEM_AGP) {
|
||||||
sizeof(mem));
|
|
||||||
|
|
||||||
if (mem.type > VIA_MEM_AGP) {
|
|
||||||
DRM_ERROR("Unknown memory type allocation\n");
|
DRM_ERROR("Unknown memory type allocation\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
mutex_lock(&dev->struct_mutex);
|
mutex_lock(&dev->struct_mutex);
|
||||||
if (0 == ((mem.type == VIA_MEM_VIDEO) ? dev_priv->vram_initialized :
|
if (0 == ((mem->type == VIA_MEM_VIDEO) ? dev_priv->vram_initialized :
|
||||||
dev_priv->agp_initialized)) {
|
dev_priv->agp_initialized)) {
|
||||||
DRM_ERROR
|
DRM_ERROR
|
||||||
("Attempt to allocate from uninitialized memory manager.\n");
|
("Attempt to allocate from uninitialized memory manager.\n");
|
||||||
|
@ -147,42 +137,37 @@ int via_mem_alloc(DRM_IOCTL_ARGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpSize = (mem.size + VIA_MM_ALIGN_MASK) >> VIA_MM_ALIGN_SHIFT;
|
tmpSize = (mem->size + VIA_MM_ALIGN_MASK) >> VIA_MM_ALIGN_SHIFT;
|
||||||
item = drm_sman_alloc(&dev_priv->sman, mem.type, tmpSize, 0,
|
item = drm_sman_alloc(&dev_priv->sman, mem->type, tmpSize, 0,
|
||||||
(unsigned long)file_priv);
|
(unsigned long)file_priv);
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
if (item) {
|
if (item) {
|
||||||
mem.offset = ((mem.type == VIA_MEM_VIDEO) ?
|
mem->offset = ((mem->type == VIA_MEM_VIDEO) ?
|
||||||
dev_priv->vram_offset : dev_priv->agp_offset) +
|
dev_priv->vram_offset : dev_priv->agp_offset) +
|
||||||
(item->mm->
|
(item->mm->
|
||||||
offset(item->mm, item->mm_info) << VIA_MM_ALIGN_SHIFT);
|
offset(item->mm, item->mm_info) << VIA_MM_ALIGN_SHIFT);
|
||||||
mem.index = item->user_hash.key;
|
mem->index = item->user_hash.key;
|
||||||
} else {
|
} else {
|
||||||
mem.offset = 0;
|
mem->offset = 0;
|
||||||
mem.size = 0;
|
mem->size = 0;
|
||||||
mem.index = 0;
|
mem->index = 0;
|
||||||
DRM_DEBUG("Video memory allocation failed\n");
|
DRM_DEBUG("Video memory allocation failed\n");
|
||||||
retval = -ENOMEM;
|
retval = -ENOMEM;
|
||||||
}
|
}
|
||||||
DRM_COPY_TO_USER_IOCTL((drm_via_mem_t __user *) data, mem, sizeof(mem));
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
int via_mem_free(DRM_IOCTL_ARGS)
|
int via_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
|
||||||
drm_via_private_t *dev_priv = dev->dev_private;
|
drm_via_private_t *dev_priv = dev->dev_private;
|
||||||
drm_via_mem_t mem;
|
drm_via_mem_t *mem = data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(mem, (drm_via_mem_t __user *) data,
|
|
||||||
sizeof(mem));
|
|
||||||
|
|
||||||
mutex_lock(&dev->struct_mutex);
|
mutex_lock(&dev->struct_mutex);
|
||||||
ret = drm_sman_free_key(&dev_priv->sman, mem.index);
|
ret = drm_sman_free_key(&dev_priv->sman, mem->index);
|
||||||
mutex_unlock(&dev->struct_mutex);
|
mutex_unlock(&dev->struct_mutex);
|
||||||
DRM_DEBUG("free = 0x%lx\n", mem.index);
|
DRM_DEBUG("free = 0x%lx\n", mem->index);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,10 +65,9 @@ void via_release_futex(drm_via_private_t * dev_priv, int context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int via_decoder_futex(DRM_IOCTL_ARGS)
|
int via_decoder_futex(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
||||||
{
|
{
|
||||||
DRM_DEVICE;
|
drm_via_futex_t *fx = data;
|
||||||
drm_via_futex_t fx;
|
|
||||||
volatile int *lock;
|
volatile int *lock;
|
||||||
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
|
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
|
||||||
drm_via_sarea_t *sAPriv = dev_priv->sarea_priv;
|
drm_via_sarea_t *sAPriv = dev_priv->sarea_priv;
|
||||||
|
@ -76,21 +75,18 @@ int via_decoder_futex(DRM_IOCTL_ARGS)
|
||||||
|
|
||||||
DRM_DEBUG("%s\n", __FUNCTION__);
|
DRM_DEBUG("%s\n", __FUNCTION__);
|
||||||
|
|
||||||
DRM_COPY_FROM_USER_IOCTL(fx, (drm_via_futex_t __user *) data,
|
if (fx->lock > VIA_NR_XVMC_LOCKS)
|
||||||
sizeof(fx));
|
|
||||||
|
|
||||||
if (fx.lock > VIA_NR_XVMC_LOCKS)
|
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
lock = (volatile int *)XVMCLOCKPTR(sAPriv, fx.lock);
|
lock = (volatile int *)XVMCLOCKPTR(sAPriv, fx->lock);
|
||||||
|
|
||||||
switch (fx.func) {
|
switch (fx->func) {
|
||||||
case VIA_FUTEX_WAIT:
|
case VIA_FUTEX_WAIT:
|
||||||
DRM_WAIT_ON(ret, dev_priv->decoder_queue[fx.lock],
|
DRM_WAIT_ON(ret, dev_priv->decoder_queue[fx->lock],
|
||||||
(fx.ms / 10) * (DRM_HZ / 100), *lock != fx.val);
|
(fx->ms / 10) * (DRM_HZ / 100), *lock != fx->val);
|
||||||
return ret;
|
return ret;
|
||||||
case VIA_FUTEX_WAKE:
|
case VIA_FUTEX_WAKE:
|
||||||
DRM_WAKEUP(&(dev_priv->decoder_queue[fx.lock]));
|
DRM_WAKEUP(&(dev_priv->decoder_queue[fx->lock]));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue