drmp.h

来自「linux 内核源代码」· C头文件 代码 · 共 1,152 行 · 第 1/3 页

H
1,152
字号
/** * \file drmP.h * Private header for Direct Rendering Manager * * \author Rickard E. (Rik) Faith <faith@valinux.com> * \author Gareth Hughes <gareth@valinux.com> *//* * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */#ifndef _DRM_P_H_#define _DRM_P_H_/* If you want the memory alloc debug functionality, change define below *//* #define DEBUG_MEMORY */#ifdef __KERNEL__#ifdef __alpha__/* add include of current.h so that "current" is defined * before static inline funcs in wait.h. Doing this so we * can build the DRM (part of PI DRI). 4/21/2000 S + B */#include <asm/current.h>#endif				/* __alpha__ */#include <linux/module.h>#include <linux/kernel.h>#include <linux/miscdevice.h>#include <linux/fs.h>#include <linux/proc_fs.h>#include <linux/init.h>#include <linux/file.h>#include <linux/pci.h>#include <linux/jiffies.h>#include <linux/smp_lock.h>	/* For (un)lock_kernel */#include <linux/mm.h>#include <linux/cdev.h>#include <linux/mutex.h>#if defined(__alpha__) || defined(__powerpc__)#include <asm/pgtable.h>	/* For pte_wrprotect */#endif#include <asm/io.h>#include <asm/mman.h>#include <asm/uaccess.h>#ifdef CONFIG_MTRR#include <asm/mtrr.h>#endif#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)#include <linux/types.h>#include <linux/agp_backend.h>#endif#include <linux/workqueue.h>#include <linux/poll.h>#include <asm/pgalloc.h>#include "drm.h"#include <linux/idr.h>#define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))#define __OS_HAS_MTRR (defined(CONFIG_MTRR))struct drm_file;struct drm_device;#include "drm_os_linux.h"#include "drm_hashtab.h"/***********************************************************************//** \name DRM template customization defaults *//*@{*//* driver capabilities and requirements mask */#define DRIVER_USE_AGP     0x1#define DRIVER_REQUIRE_AGP 0x2#define DRIVER_USE_MTRR    0x4#define DRIVER_PCI_DMA     0x8#define DRIVER_SG          0x10#define DRIVER_HAVE_DMA    0x20#define DRIVER_HAVE_IRQ    0x40#define DRIVER_IRQ_SHARED  0x80#define DRIVER_IRQ_VBL     0x100#define DRIVER_DMA_QUEUE   0x200#define DRIVER_FB_DMA      0x400#define DRIVER_IRQ_VBL2    0x800/***********************************************************************//** \name Begin the DRM... *//*@{*/#define DRM_DEBUG_CODE 2	  /**< Include debugging code if > 1, then				     also include looping detection. */#define DRM_MAGIC_HASH_ORDER  4  /**< Size of key hash table. Must be power of 2. */#define DRM_KERNEL_CONTEXT    0	 /**< Change drm_resctx if changed */#define DRM_RESERVED_CONTEXTS 1	 /**< Change drm_resctx if changed */#define DRM_LOOPING_LIMIT     5000000#define DRM_TIME_SLICE	      (HZ/20)  /**< Time slice for GLXContexts */#define DRM_LOCK_SLICE	      1	/**< Time slice for lock, in jiffies */#define DRM_FLAG_DEBUG	  0x01#define DRM_MEM_DMA	   0#define DRM_MEM_SAREA	   1#define DRM_MEM_DRIVER	   2#define DRM_MEM_MAGIC	   3#define DRM_MEM_IOCTLS	   4#define DRM_MEM_MAPS	   5#define DRM_MEM_VMAS	   6#define DRM_MEM_BUFS	   7#define DRM_MEM_SEGS	   8#define DRM_MEM_PAGES	   9#define DRM_MEM_FILES	  10#define DRM_MEM_QUEUES	  11#define DRM_MEM_CMDS	  12#define DRM_MEM_MAPPINGS  13#define DRM_MEM_BUFLISTS  14#define DRM_MEM_AGPLISTS  15#define DRM_MEM_TOTALAGP  16#define DRM_MEM_BOUNDAGP  17#define DRM_MEM_CTXBITMAP 18#define DRM_MEM_STUB      19#define DRM_MEM_SGLISTS   20#define DRM_MEM_CTXLIST   21#define DRM_MEM_MM        22#define DRM_MEM_HASHTAB   23#define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)#define DRM_MAP_HASH_OFFSET 0x10000000/*@}*//***********************************************************************//** \name Macros to make printk easier *//*@{*//** * Error output. * * \param fmt printf() like format string. * \param arg arguments */#define DRM_ERROR(fmt, arg...) \	printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __FUNCTION__ , ##arg)/** * Memory error output. * * \param area memory area where the error occurred. * \param fmt printf() like format string. * \param arg arguments */#define DRM_MEM_ERROR(area, fmt, arg...) \	printk(KERN_ERR "[" DRM_NAME ":%s:%s] *ERROR* " fmt , __FUNCTION__, \	       drm_mem_stats[area].name , ##arg)#define DRM_INFO(fmt, arg...)  printk(KERN_INFO "[" DRM_NAME "] " fmt , ##arg)/** * Debug output. * * \param fmt printf() like format string. * \param arg arguments */#if DRM_DEBUG_CODE#define DRM_DEBUG(fmt, arg...)						\	do {								\		if ( drm_debug )			\			printk(KERN_DEBUG				\			       "[" DRM_NAME ":%s] " fmt ,	\			       __FUNCTION__ , ##arg);			\	} while (0)#else#define DRM_DEBUG(fmt, arg...)		 do { } while (0)#endif#define DRM_PROC_LIMIT (PAGE_SIZE-80)#define DRM_PROC_PRINT(fmt, arg...)					\   len += sprintf(&buf[len], fmt , ##arg);				\   if (len > DRM_PROC_LIMIT) { *eof = 1; return len - offset; }#define DRM_PROC_PRINT_RET(ret, fmt, arg...)				\   len += sprintf(&buf[len], fmt , ##arg);				\   if (len > DRM_PROC_LIMIT) { ret; *eof = 1; return len - offset; }/*@}*//***********************************************************************//** \name Internal types and structures *//*@{*/#define DRM_ARRAY_SIZE(x) ARRAY_SIZE(x)#define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1))#define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x))#define DRM_WAITCOUNT(dev,idx) DRM_BUFCOUNT(&dev->queuelist[idx]->waitlist)#define DRM_IF_VERSION(maj, min) (maj << 16 | min)/** * Get the private SAREA mapping. * * \param _dev DRM device. * \param _ctx context number. * \param _map output mapping. */#define DRM_GET_PRIV_SAREA(_dev, _ctx, _map) do {	\	(_map) = (_dev)->context_sareas[_ctx];		\} while(0)/** * Test that the hardware lock is held by the caller, returning otherwise. * * \param dev DRM device. * \param filp file pointer of the caller. */#define LOCK_TEST_WITH_RETURN( dev, file_priv )				\do {									\	if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) ||		\	     dev->lock.file_priv != file_priv )	{			\		DRM_ERROR( "%s called without lock held, held  %d owner %p %p\n",\			   __FUNCTION__, _DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ),\			   dev->lock.file_priv, file_priv );		\		return -EINVAL;						\	}								\} while (0)/** * Copy and IOCTL return string to user space */#define DRM_COPY( name, value )						\	len = strlen( value );						\	if ( len > name##_len ) len = name##_len;			\	name##_len = strlen( value );					\	if ( len && name ) {						\		if ( copy_to_user( name, value, len ) )			\			return -EFAULT;					\	}/** * Ioctl function type. * * \param inode device inode. * \param file_priv DRM file private pointer. * \param cmd command. * \param arg argument. */typedef int drm_ioctl_t(struct drm_device *dev, void *data,			struct drm_file *file_priv);typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,			       unsigned long arg);#define DRM_AUTH	0x1#define	DRM_MASTER	0x2#define DRM_ROOT_ONLY	0x4struct drm_ioctl_desc {	unsigned int cmd;	drm_ioctl_t *func;	int flags;};/** * 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 list_head head;	struct drm_hash_item hash_item;	struct drm_file *priv;	struct drm_magic_entry *next;};struct drm_vma_entry {	struct list_head head;	struct vm_area_struct *vma;	pid_t pid;};/** * DMA buffer. */struct drm_buf {	int idx;		       /**< Index into master buflist */	int total;		       /**< Buffer size */	int order;		       /**< log-base-2(total) */	int used;		       /**< Amount of buffer in use (for DMA) */	unsigned long offset;	       /**< Byte offset (used internally) */	void *address;		       /**< Address of buffer */	unsigned long bus_address;     /**< Bus address of buffer */	struct drm_buf *next;	       /**< Kernel-only: used for free list */	__volatile__ int waiting;      /**< On kernel DMA queue */	__volatile__ int pending;      /**< On hardware DMA queue */	wait_queue_head_t dma_wait;    /**< Processes waiting */	struct drm_file *file_priv;    /**< Private of holding file descr */	int context;		       /**< Kernel queue for this buffer */	int while_locked;	       /**< Dispatch this buffer while locked */	enum {		DRM_LIST_NONE = 0,		DRM_LIST_FREE = 1,		DRM_LIST_WAIT = 2,		DRM_LIST_PEND = 3,		DRM_LIST_PRIO = 4,		DRM_LIST_RECLAIM = 5	} list;			       /**< Which list we're on */	int dev_priv_size;		 /**< Size of buffer private storage */	void *dev_private;		 /**< Per-buffer private storage */};/** bufs is one longer than it has to be */struct drm_waitlist {	int count;			/**< Number of possible buffers */	struct drm_buf **bufs;		/**< List of pointers to buffers */	struct drm_buf **rp;			/**< Read pointer */	struct drm_buf **wp;			/**< Write pointer */	struct drm_buf **end;		/**< End pointer */	spinlock_t read_lock;	spinlock_t write_lock;};struct drm_freelist {	int initialized;	       /**< Freelist in use */	atomic_t count;		       /**< Number of free buffers */	struct drm_buf *next;	       /**< End pointer */	wait_queue_head_t waiting;     /**< Processes waiting on free bufs */	int low_mark;		       /**< Low water mark */	int high_mark;		       /**< High water mark */	atomic_t wfh;		       /**< If waiting for high mark */	spinlock_t lock;};typedef struct drm_dma_handle {	dma_addr_t busaddr;	void *vaddr;	size_t size;} drm_dma_handle_t;/** * Buffer entry.  There is one of this for each buffer size order. */struct drm_buf_entry {	int buf_size;			/**< size */	int buf_count;			/**< number of buffers */	struct drm_buf *buflist;		/**< buffer list */	int seg_count;	int page_order;	struct drm_dma_handle **seglist;	struct drm_freelist freelist;};/** File private data */struct drm_file {	int authenticated;	int master;	int minor;	pid_t pid;	uid_t uid;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?