📄 drmp.h
字号:
/** * \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/config.h>#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>#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"#define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))#define __OS_HAS_MTRR (defined(CONFIG_MTRR))#include "drm_os_linux.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/***********************************************************************//** \name Begin the DRM... *//*@{*/#define DRM_DEBUG_CODE 2 /**< Include debugging code if > 1, then also include looping detection. */#define DRM_HASH_SIZE 16 /**< 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_MAX_CTXBITMAP (PAGE_SIZE * 8)/*@}*//***********************************************************************//** \name Backward compatibility section *//*@{*/#ifndef MODULE_LICENSE#define MODULE_LICENSE(x)#endif#ifndef preempt_disable#define preempt_disable()#define preempt_enable()#endif#ifndef pte_offset_map#define pte_offset_map pte_offset#define pte_unmap(pte)#endif#define DRM_RPR_ARG(vma) vma,#define VM_OFFSET(vma) ((vma)->vm_pgoff << PAGE_SHIFT)/*@}*//***********************************************************************//** \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_MIN(a,b) min(a,b)#define DRM_MAX(a,b) max(a,b)#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, filp ) \do { \ if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \ dev->lock.filp != filp ) { \ DRM_ERROR( "%s called without lock held\n", \ __FUNCTION__ ); \ 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 filp file pointer. * \param cmd command. * \param arg argument. */typedef int drm_ioctl_t(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd, unsigned long arg);typedef struct drm_ioctl_desc { drm_ioctl_t *func; int auth_needed; int root_only;} drm_ioctl_desc_t;typedef struct drm_devstate { pid_t owner; /**< X server pid holding x_lock */} drm_devstate_t;typedef struct drm_magic_entry { drm_magic_t magic; struct drm_file *priv; struct drm_magic_entry *next;} drm_magic_entry_t;typedef struct drm_magic_head { struct drm_magic_entry *head; struct drm_magic_entry *tail;} drm_magic_head_t;typedef struct drm_vma_entry { struct vm_area_struct *vma; struct drm_vma_entry *next; pid_t pid;} drm_vma_entry_t;/** * DMA buffer. */typedef 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 file *filp; /**< Pointer to 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 */} drm_buf_t;/** bufs is one longer than it has to be */typedef struct drm_waitlist { int count; /**< Number of possible buffers */ drm_buf_t **bufs; /**< List of pointers to buffers */ drm_buf_t **rp; /**< Read pointer */ drm_buf_t **wp; /**< Write pointer */ drm_buf_t **end; /**< End pointer */ spinlock_t read_lock; spinlock_t write_lock;} drm_waitlist_t;typedef struct drm_freelist { int initialized; /**< Freelist in use */ atomic_t count; /**< Number of free buffers */ drm_buf_t *next; /**< End pointer */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -