aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm/drmP.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/drm/drmP.h')
-rw-r--r--include/drm/drmP.h87
1 files changed, 53 insertions, 34 deletions
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index c8e64bbadbcf..19ef8ebdc662 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -245,16 +245,6 @@ extern void drm_ut_debug_printk(unsigned int request_level,
245 245
246#endif 246#endif
247 247
248#define DRM_PROC_LIMIT (PAGE_SIZE-80)
249
250#define DRM_PROC_PRINT(fmt, arg...) \
251 len += sprintf(&buf[len], fmt , ##arg); \
252 if (len > DRM_PROC_LIMIT) { *eof = 1; return len - offset; }
253
254#define DRM_PROC_PRINT_RET(ret, fmt, arg...) \
255 len += sprintf(&buf[len], fmt , ##arg); \
256 if (len > DRM_PROC_LIMIT) { ret; *eof = 1; return len - offset; }
257
258/*@}*/ 248/*@}*/
259 249
260/***********************************************************************/ 250/***********************************************************************/
@@ -265,19 +255,8 @@ extern void drm_ut_debug_printk(unsigned int request_level,
265 255
266#define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1)) 256#define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1))
267#define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x)) 257#define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x))
268#define DRM_WAITCOUNT(dev,idx) DRM_BUFCOUNT(&dev->queuelist[idx]->waitlist)
269 258
270#define DRM_IF_VERSION(maj, min) (maj << 16 | min) 259#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
271/**
272 * Get the private SAREA mapping.
273 *
274 * \param _dev DRM device.
275 * \param _ctx context number.
276 * \param _map output mapping.
277 */
278#define DRM_GET_PRIV_SAREA(_dev, _ctx, _map) do { \
279 (_map) = (_dev)->context_sareas[_ctx]; \
280} while(0)
281 260
282/** 261/**
283 * Test that the hardware lock is held by the caller, returning otherwise. 262 * Test that the hardware lock is held by the caller, returning otherwise.
@@ -297,18 +276,6 @@ do { \
297} while (0) 276} while (0)
298 277
299/** 278/**
300 * Copy and IOCTL return string to user space
301 */
302#define DRM_COPY( name, value ) \
303 len = strlen( value ); \
304 if ( len > name##_len ) len = name##_len; \
305 name##_len = strlen( value ); \
306 if ( len && name ) { \
307 if ( copy_to_user( name, value, len ) ) \
308 return -EFAULT; \
309 }
310
311/**
312 * Ioctl function type. 279 * Ioctl function type.
313 * 280 *
314 * \param inode device inode. 281 * \param inode device inode.
@@ -322,6 +289,9 @@ typedef int drm_ioctl_t(struct drm_device *dev, void *data,
322typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd, 289typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
323 unsigned long arg); 290 unsigned long arg);
324 291
292#define DRM_IOCTL_NR(n) _IOC_NR(n)
293#define DRM_MAJOR 226
294
325#define DRM_AUTH 0x1 295#define DRM_AUTH 0x1
326#define DRM_MASTER 0x2 296#define DRM_MASTER 0x2
327#define DRM_ROOT_ONLY 0x4 297#define DRM_ROOT_ONLY 0x4
@@ -426,6 +396,14 @@ struct drm_buf_entry {
426 struct drm_freelist freelist; 396 struct drm_freelist freelist;
427}; 397};
428 398
399/* Event queued up for userspace to read */
400struct drm_pending_event {
401 struct drm_event *event;
402 struct list_head link;
403 struct drm_file *file_priv;
404 void (*destroy)(struct drm_pending_event *event);
405};
406
429/** File private data */ 407/** File private data */
430struct drm_file { 408struct drm_file {
431 int authenticated; 409 int authenticated;
@@ -449,6 +427,10 @@ struct drm_file {
449 struct drm_master *master; /* master this node is currently associated with 427 struct drm_master *master; /* master this node is currently associated with
450 N.B. not always minor->master */ 428 N.B. not always minor->master */
451 struct list_head fbs; 429 struct list_head fbs;
430
431 wait_queue_head_t event_wait;
432 struct list_head event_list;
433 int event_space;
452}; 434};
453 435
454/** Wait queue */ 436/** Wait queue */
@@ -795,6 +777,15 @@ struct drm_driver {
795 /* Master routines */ 777 /* Master routines */
796 int (*master_create)(struct drm_device *dev, struct drm_master *master); 778 int (*master_create)(struct drm_device *dev, struct drm_master *master);
797 void (*master_destroy)(struct drm_device *dev, struct drm_master *master); 779 void (*master_destroy)(struct drm_device *dev, struct drm_master *master);
780 /**
781 * master_set is called whenever the minor master is set.
782 * master_drop is called whenever the minor master is dropped.
783 */
784
785 int (*master_set)(struct drm_device *dev, struct drm_file *file_priv,
786 bool from_open);
787 void (*master_drop)(struct drm_device *dev, struct drm_file *file_priv,
788 bool from_release);
798 789
799 int (*proc_init)(struct drm_minor *minor); 790 int (*proc_init)(struct drm_minor *minor);
800 void (*proc_cleanup)(struct drm_minor *minor); 791 void (*proc_cleanup)(struct drm_minor *minor);
@@ -900,6 +891,12 @@ struct drm_minor {
900 struct drm_mode_group mode_group; 891 struct drm_mode_group mode_group;
901}; 892};
902 893
894struct drm_pending_vblank_event {
895 struct drm_pending_event base;
896 int pipe;
897 struct drm_event_vblank event;
898};
899
903/** 900/**
904 * DRM device structure. This structure represent a complete card that 901 * DRM device structure. This structure represent a complete card that
905 * may contain multiple heads. 902 * may contain multiple heads.
@@ -999,6 +996,12 @@ struct drm_device {
999 996
1000 u32 max_vblank_count; /**< size of vblank counter register */ 997 u32 max_vblank_count; /**< size of vblank counter register */
1001 998
999 /**
1000 * List of events
1001 */
1002 struct list_head vblank_event_list;
1003 spinlock_t event_lock;
1004
1002 /*@} */ 1005 /*@} */
1003 cycles_t ctx_start; 1006 cycles_t ctx_start;
1004 cycles_t lck_start; 1007 cycles_t lck_start;
@@ -1135,6 +1138,8 @@ extern int drm_lastclose(struct drm_device *dev);
1135extern int drm_open(struct inode *inode, struct file *filp); 1138extern int drm_open(struct inode *inode, struct file *filp);
1136extern int drm_stub_open(struct inode *inode, struct file *filp); 1139extern int drm_stub_open(struct inode *inode, struct file *filp);
1137extern int drm_fasync(int fd, struct file *filp, int on); 1140extern int drm_fasync(int fd, struct file *filp, int on);
1141extern ssize_t drm_read(struct file *filp, char __user *buffer,
1142 size_t count, loff_t *offset);
1138extern int drm_release(struct inode *inode, struct file *filp); 1143extern int drm_release(struct inode *inode, struct file *filp);
1139 1144
1140 /* Mapping support (drm_vm.h) */ 1145 /* Mapping support (drm_vm.h) */
@@ -1295,6 +1300,7 @@ extern u32 drm_vblank_count(struct drm_device *dev, int crtc);
1295extern void drm_handle_vblank(struct drm_device *dev, int crtc); 1300extern void drm_handle_vblank(struct drm_device *dev, int crtc);
1296extern int drm_vblank_get(struct drm_device *dev, int crtc); 1301extern int drm_vblank_get(struct drm_device *dev, int crtc);
1297extern void drm_vblank_put(struct drm_device *dev, int crtc); 1302extern void drm_vblank_put(struct drm_device *dev, int crtc);
1303extern void drm_vblank_off(struct drm_device *dev, int crtc);
1298extern void drm_vblank_cleanup(struct drm_device *dev); 1304extern void drm_vblank_cleanup(struct drm_device *dev);
1299/* Modesetting support */ 1305/* Modesetting support */
1300extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc); 1306extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc);
@@ -1519,14 +1525,27 @@ static __inline__ void drm_core_dropmap(struct drm_local_map *map)
1519 1525
1520static __inline__ void *drm_calloc_large(size_t nmemb, size_t size) 1526static __inline__ void *drm_calloc_large(size_t nmemb, size_t size)
1521{ 1527{
1528 if (size != 0 && nmemb > ULONG_MAX / size)
1529 return NULL;
1530
1522 if (size * nmemb <= PAGE_SIZE) 1531 if (size * nmemb <= PAGE_SIZE)
1523 return kcalloc(nmemb, size, GFP_KERNEL); 1532 return kcalloc(nmemb, size, GFP_KERNEL);
1524 1533
1534 return __vmalloc(size * nmemb,
1535 GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL);
1536}
1537
1538/* Modeled after cairo's malloc_ab, it's like calloc but without the zeroing. */
1539static __inline__ void *drm_malloc_ab(size_t nmemb, size_t size)
1540{
1525 if (size != 0 && nmemb > ULONG_MAX / size) 1541 if (size != 0 && nmemb > ULONG_MAX / size)
1526 return NULL; 1542 return NULL;
1527 1543
1544 if (size * nmemb <= PAGE_SIZE)
1545 return kmalloc(nmemb * size, GFP_KERNEL);
1546
1528 return __vmalloc(size * nmemb, 1547 return __vmalloc(size * nmemb,
1529 GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL); 1548 GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL);
1530} 1549}
1531 1550
1532static __inline void drm_free_large(void *ptr) 1551static __inline void drm_free_large(void *ptr)