Subversion Repositories Kolibri OS

Rev

Rev 1964 | Rev 2161 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /**
  2.  * \file drmP.h
  3.  * Private header for Direct Rendering Manager
  4.  *
  5.  * \author Rickard E. (Rik) Faith <faith@valinux.com>
  6.  * \author Gareth Hughes <gareth@valinux.com>
  7.  */
  8.  
  9. /*
  10.  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
  11.  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
  12.  * Copyright (c) 2009-2010, Code Aurora Forum.
  13.  * All rights reserved.
  14.  *
  15.  * Permission is hereby granted, free of charge, to any person obtaining a
  16.  * copy of this software and associated documentation files (the "Software"),
  17.  * to deal in the Software without restriction, including without limitation
  18.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  19.  * and/or sell copies of the Software, and to permit persons to whom the
  20.  * Software is furnished to do so, subject to the following conditions:
  21.  *
  22.  * The above copyright notice and this permission notice (including the next
  23.  * paragraph) shall be included in all copies or substantial portions of the
  24.  * Software.
  25.  *
  26.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  27.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  28.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  29.  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  30.  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  31.  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  32.  * OTHER DEALINGS IN THE SOFTWARE.
  33.  */
  34.  
  35. #ifndef _DRM_P_H_
  36. #define _DRM_P_H_
  37.  
  38. #ifdef __KERNEL__
  39. #ifdef __alpha__
  40. /* add include of current.h so that "current" is defined
  41.  * before static inline funcs in wait.h. Doing this so we
  42.  * can build the DRM (part of PI DRI). 4/21/2000 S + B */
  43. #include <asm/current.h>
  44. #endif                          /* __alpha__ */
  45. #include <linux/module.h>
  46. #include <linux/kernel.h>
  47. #include <linux/kref.h>
  48. #include <linux/spinlock.h>
  49.  
  50. //#include <linux/miscdevice.h>
  51. //#include <linux/fs.h>
  52. //#include <linux/proc_fs.h>
  53. //#include <linux/init.h>
  54. //#include <linux/file.h>
  55. #include <linux/pci.h>
  56. //#include <linux/jiffies.h>
  57. //#include <linux/smp_lock.h>    /* For (un)lock_kernel */
  58. //#include <linux/dma-mapping.h>
  59. //#include <linux/mm.h>
  60. //#include <linux/cdev.h>
  61. #include <linux/mutex.h>
  62. //#include <asm/io.h>
  63. //#include <asm/mman.h>
  64. //#include <asm/uaccess.h>
  65. //#include <linux/workqueue.h>
  66. //#include <linux/poll.h>
  67. //#include <asm/pgalloc.h>
  68.  
  69. #include "drm.h"
  70.  
  71. #include <linux/idr.h>
  72.  
  73. #define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))
  74. #define __OS_HAS_MTRR (defined(CONFIG_MTRR))
  75.  
  76.  
  77.  
  78.  
  79. #include <drm_edid.h>
  80. #include <drm_crtc.h>
  81.  
  82.  
  83. struct drm_file;
  84. struct drm_device;
  85.  
  86. //#include "drm_os_linux.h"
  87. #include "drm_hashtab.h"
  88. #include "drm_mm.h"
  89.  
  90. #define DRM_UT_CORE             0x01
  91. #define DRM_UT_DRIVER           0x02
  92. #define DRM_UT_KMS          0x04
  93. #define DRM_UT_MODE         0x08
  94.  
  95. #define KHZ2PICOS(a) (1000000000UL/(a))
  96.  
  97. /* get_scanout_position() return flags */
  98. #define DRM_SCANOUTPOS_VALID        (1 << 0)
  99. #define DRM_SCANOUTPOS_INVBL        (1 << 1)
  100. #define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
  101.  
  102.  
  103. extern void drm_ut_debug_printk(unsigned int request_level,
  104.                                 const char *prefix,
  105.                                 const char *function_name,
  106.                                 const char *format, ...);
  107.  
  108. #define DRM_DEBUG_MODE(prefix, fmt, args...)    \
  109.     do {                                        \
  110.         dbgprintf("drm debug: %s" fmt,          \
  111.                      __func__, ##args);         \
  112.     } while (0)
  113.  
  114. #define DRM_DEBUG(fmt, args...)                                 \
  115.     do {                                                        \
  116.         printk("[" DRM_NAME ":%s] " fmt , __func__ , ##args);   \
  117.     } while(0)
  118.  
  119. #define DRM_DEBUG_KMS(fmt, args...)                             \
  120.     do {                                                        \
  121.         printk("[" DRM_NAME ":%s] " fmt , __func__ , ##args);   \
  122.     } while(0)
  123.  
  124. #define dev_err(dev, format, arg...)            \
  125.         printk("Error %s " format, __func__ , ## arg)
  126.  
  127. #define dev_warn(dev, format, arg...)            \
  128.         printk("Warning %s " format, __func__ , ## arg)
  129.  
  130. #define dev_info(dev, format, arg...)       \
  131.         printk("Info %s " format , __func__, ## arg)
  132.  
  133.  
  134.  
  135. static inline int drm_sysfs_connector_add(struct drm_connector *connector)
  136. { return 0; };
  137.  
  138. static inline void drm_sysfs_connector_remove(struct drm_connector *connector)
  139. { };
  140.  
  141. #if 0
  142.  
  143. /***********************************************************************/
  144. /** \name DRM template customization defaults */
  145. /*@{*/
  146.  
  147. /* driver capabilities and requirements mask */
  148. #define DRIVER_USE_AGP     0x1
  149. #define DRIVER_REQUIRE_AGP 0x2
  150. #define DRIVER_USE_MTRR    0x4
  151. #define DRIVER_PCI_DMA     0x8
  152. #define DRIVER_SG          0x10
  153. #define DRIVER_HAVE_DMA    0x20
  154. #define DRIVER_HAVE_IRQ    0x40
  155. #define DRIVER_IRQ_SHARED  0x80
  156. #define DRIVER_IRQ_VBL     0x100
  157. #define DRIVER_DMA_QUEUE   0x200
  158. #define DRIVER_FB_DMA      0x400
  159. #define DRIVER_IRQ_VBL2    0x800
  160. #define DRIVER_GEM         0x1000
  161. #define DRIVER_MODESET     0x2000
  162. #define DRIVER_USE_PLATFORM_DEVICE  0x4000
  163.  
  164. /***********************************************************************/
  165. /** \name Begin the DRM... */
  166. /*@{*/
  167.  
  168. #define DRM_DEBUG_CODE 2          /**< Include debugging code if > 1, then
  169.                                      also include looping detection. */
  170.  
  171. #define DRM_MAGIC_HASH_ORDER  4  /**< Size of key hash table. Must be power of 2. */
  172. #define DRM_KERNEL_CONTEXT    0  /**< Change drm_resctx if changed */
  173. #define DRM_RESERVED_CONTEXTS 1  /**< Change drm_resctx if changed */
  174. #define DRM_LOOPING_LIMIT     5000000
  175. #define DRM_TIME_SLICE        (HZ/20)  /**< Time slice for GLXContexts */
  176. #define DRM_LOCK_SLICE        1 /**< Time slice for lock, in jiffies */
  177.  
  178. #define DRM_FLAG_DEBUG    0x01
  179.  
  180. #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
  181. #define DRM_MAP_HASH_OFFSET 0x10000000
  182.  
  183. /*@}*/
  184.  
  185. /***********************************************************************/
  186. /** \name Macros to make printk easier */
  187. /*@{*/
  188.  
  189. /**
  190.  * Error output.
  191.  *
  192.  * \param fmt printf() like format string.
  193.  * \param arg arguments
  194.  */
  195. #define DRM_ERROR(fmt, arg...) \
  196.         printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __func__ , ##arg)
  197.  
  198. /**
  199.  * Memory error output.
  200.  *
  201.  * \param area memory area where the error occurred.
  202.  * \param fmt printf() like format string.
  203.  * \param arg arguments
  204.  */
  205. #define DRM_MEM_ERROR(area, fmt, arg...) \
  206.         printk(KERN_ERR "[" DRM_NAME ":%s:%s] *ERROR* " fmt , __func__, \
  207.                drm_mem_stats[area].name , ##arg)
  208.  
  209. #define DRM_INFO(fmt, arg...)  printk(KERN_INFO "[" DRM_NAME "] " fmt , ##arg)
  210.  
  211. /**
  212.  * Debug output.
  213.  *
  214.  * \param fmt printf() like format string.
  215.  * \param arg arguments
  216.  */
  217. #if DRM_DEBUG_CODE
  218. #define DRM_DEBUG(fmt, args...)                                         \
  219.         do {                                                            \
  220.                 drm_ut_debug_printk(DRM_UT_CORE, DRM_NAME,              \
  221.                                         __func__, fmt, ##args);         \
  222.         } while (0)
  223.  
  224. #define DRM_DEBUG_DRIVER(fmt, args...)                                  \
  225.         do {                                                            \
  226.                 drm_ut_debug_printk(DRM_UT_DRIVER, DRM_NAME,            \
  227.                                         __func__, fmt, ##args);         \
  228.         } while (0)
  229. #define DRM_DEBUG_KMS(fmt, args...)                             \
  230.         do {                                                            \
  231.                 drm_ut_debug_printk(DRM_UT_KMS, DRM_NAME,               \
  232.                                          __func__, fmt, ##args);        \
  233.         } while (0)
  234. #define DRM_LOG(fmt, args...)                                           \
  235.         do {                                                            \
  236.                 drm_ut_debug_printk(DRM_UT_CORE, NULL,                  \
  237.                                         NULL, fmt, ##args);             \
  238.         } while (0)
  239. #define DRM_LOG_KMS(fmt, args...)                                       \
  240.         do {                                                            \
  241.                 drm_ut_debug_printk(DRM_UT_KMS, NULL,                   \
  242.                                         NULL, fmt, ##args);             \
  243.         } while (0)
  244. #define DRM_LOG_MODE(fmt, args...)                                      \
  245.         do {                                                            \
  246.                 drm_ut_debug_printk(DRM_UT_MODE, NULL,                  \
  247.                                         NULL, fmt, ##args);             \
  248.         } while (0)
  249. #define DRM_LOG_DRIVER(fmt, args...)                                    \
  250.         do {                                                            \
  251.                 drm_ut_debug_printk(DRM_UT_DRIVER, NULL,                \
  252.                                         NULL, fmt, ##args);             \
  253.         } while (0)
  254. #else
  255. #define DRM_DEBUG_DRIVER(fmt, args...) do { } while (0)
  256. #define DRM_DEBUG_KMS(fmt, args...)     do { } while (0)
  257. #define DRM_DEBUG(fmt, arg...)           do { } while (0)
  258. #define DRM_LOG(fmt, arg...)            do { } while (0)
  259. #define DRM_LOG_KMS(fmt, args...) do { } while (0)
  260. #define DRM_LOG_MODE(fmt, arg...) do { } while (0)
  261. #define DRM_LOG_DRIVER(fmt, arg...) do { } while (0)
  262.  
  263. #endif
  264.  
  265. /*@}*/
  266.  
  267. /***********************************************************************/
  268. /** \name Internal types and structures */
  269. /*@{*/
  270.  
  271. #define DRM_ARRAY_SIZE(x) ARRAY_SIZE(x)
  272.  
  273. #define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1))
  274. #define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x))
  275.  
  276. #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
  277.  
  278. /**
  279.  * Test that the hardware lock is held by the caller, returning otherwise.
  280.  *
  281.  * \param dev DRM device.
  282.  * \param filp file pointer of the caller.
  283.  */
  284. #define LOCK_TEST_WITH_RETURN( dev, _file_priv )                                \
  285. do {                                                                            \
  286.         if (!_DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock) ||       \
  287.             _file_priv->master->lock.file_priv != _file_priv)   {               \
  288.                 DRM_ERROR( "%s called without lock held, held  %d owner %p %p\n",\
  289.                            __func__, _DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock),\
  290.                            _file_priv->master->lock.file_priv, _file_priv);     \
  291.                 return -EINVAL;                                                 \
  292.         }                                                                       \
  293. } while (0)
  294.  
  295. /**
  296.  * Ioctl function type.
  297.  *
  298.  * \param inode device inode.
  299.  * \param file_priv DRM file private pointer.
  300.  * \param cmd command.
  301.  * \param arg argument.
  302.  */
  303. typedef int drm_ioctl_t(struct drm_device *dev, void *data,
  304.                         struct drm_file *file_priv);
  305.  
  306. typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
  307.                                unsigned long arg);
  308.  
  309. #define DRM_IOCTL_NR(n)                _IOC_NR(n)
  310. #define DRM_MAJOR       226
  311.  
  312. #define DRM_AUTH        0x1
  313. #define DRM_MASTER      0x2
  314. #define DRM_ROOT_ONLY   0x4
  315. #define DRM_CONTROL_ALLOW 0x8
  316. #define DRM_UNLOCKED    0x10
  317.  
  318. struct drm_ioctl_desc {
  319.         unsigned int cmd;
  320.         int flags;
  321.         drm_ioctl_t *func;
  322.         unsigned int cmd_drv;
  323. };
  324.  
  325. /**
  326.  * Creates a driver or general drm_ioctl_desc array entry for the given
  327.  * ioctl, for use by drm_ioctl().
  328.  */
  329.  
  330. #define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags)                 \
  331.         [DRM_IOCTL_NR(DRM_##ioctl)] = {.cmd = DRM_##ioctl, .func = _func, .flags = _flags, .cmd_drv = DRM_IOCTL_##ioctl}
  332.  
  333. struct drm_magic_entry {
  334.         struct list_head head;
  335.         struct drm_hash_item hash_item;
  336.         struct drm_file *priv;
  337. };
  338.  
  339. struct drm_vma_entry {
  340.         struct list_head head;
  341.         struct vm_area_struct *vma;
  342.         pid_t pid;
  343. };
  344.  
  345. /**
  346.  * DMA buffer.
  347.  */
  348. struct drm_buf {
  349.         int idx;                       /**< Index into master buflist */
  350.         int total;                     /**< Buffer size */
  351.         int order;                     /**< log-base-2(total) */
  352.         int used;                      /**< Amount of buffer in use (for DMA) */
  353.         unsigned long offset;          /**< Byte offset (used internally) */
  354.         void *address;                 /**< Address of buffer */
  355.         unsigned long bus_address;     /**< Bus address of buffer */
  356.         struct drm_buf *next;          /**< Kernel-only: used for free list */
  357.         __volatile__ int waiting;      /**< On kernel DMA queue */
  358.         __volatile__ int pending;      /**< On hardware DMA queue */
  359.         wait_queue_head_t dma_wait;    /**< Processes waiting */
  360.         struct drm_file *file_priv;    /**< Private of holding file descr */
  361.         int context;                   /**< Kernel queue for this buffer */
  362.         int while_locked;              /**< Dispatch this buffer while locked */
  363.         enum {
  364.                 DRM_LIST_NONE = 0,
  365.                 DRM_LIST_FREE = 1,
  366.                 DRM_LIST_WAIT = 2,
  367.                 DRM_LIST_PEND = 3,
  368.                 DRM_LIST_PRIO = 4,
  369.                 DRM_LIST_RECLAIM = 5
  370.         } list;                        /**< Which list we're on */
  371.  
  372.         int dev_priv_size;               /**< Size of buffer private storage */
  373.         void *dev_private;               /**< Per-buffer private storage */
  374. };
  375.  
  376. /** bufs is one longer than it has to be */
  377. struct drm_waitlist {
  378.         int count;                      /**< Number of possible buffers */
  379.         struct drm_buf **bufs;          /**< List of pointers to buffers */
  380.         struct drm_buf **rp;                    /**< Read pointer */
  381.         struct drm_buf **wp;                    /**< Write pointer */
  382.         struct drm_buf **end;           /**< End pointer */
  383.         spinlock_t read_lock;
  384.         spinlock_t write_lock;
  385. };
  386.  
  387. struct drm_freelist {
  388.         int initialized;               /**< Freelist in use */
  389.         atomic_t count;                /**< Number of free buffers */
  390.         struct drm_buf *next;          /**< End pointer */
  391.  
  392.         wait_queue_head_t waiting;     /**< Processes waiting on free bufs */
  393.         int low_mark;                  /**< Low water mark */
  394.         int high_mark;                 /**< High water mark */
  395.         atomic_t wfh;                  /**< If waiting for high mark */
  396.         spinlock_t lock;
  397. };
  398.  
  399. typedef struct drm_dma_handle {
  400.         dma_addr_t busaddr;
  401.         void *vaddr;
  402.         size_t size;
  403. } drm_dma_handle_t;
  404.  
  405. /**
  406.  * Buffer entry.  There is one of this for each buffer size order.
  407.  */
  408. struct drm_buf_entry {
  409.         int buf_size;                   /**< size */
  410.         int buf_count;                  /**< number of buffers */
  411.         struct drm_buf *buflist;                /**< buffer list */
  412.         int seg_count;
  413.         int page_order;
  414.         struct drm_dma_handle **seglist;
  415.  
  416.         struct drm_freelist freelist;
  417. };
  418.  
  419. /* Event queued up for userspace to read */
  420. struct drm_pending_event {
  421.         struct drm_event *event;
  422.         struct list_head link;
  423.         struct drm_file *file_priv;
  424.         pid_t pid; /* pid of requester, no guarantee it's valid by the time
  425.                       we deliver the event, for tracing only */
  426.         void (*destroy)(struct drm_pending_event *event);
  427. };
  428.  
  429. /** File private data */
  430. struct drm_file {
  431.         int authenticated;
  432.         pid_t pid;
  433.         uid_t uid;
  434.         drm_magic_t magic;
  435.         unsigned long ioctl_count;
  436.         struct list_head lhead;
  437.         struct drm_minor *minor;
  438.         unsigned long lock_count;
  439.  
  440.         /** Mapping of mm object handles to object pointers. */
  441.         struct idr object_idr;
  442.         /** Lock for synchronization of access to object_idr. */
  443.         spinlock_t table_lock;
  444.  
  445.         struct file *filp;
  446.         void *driver_priv;
  447.  
  448.         int is_master; /* this file private is a master for a minor */
  449.         struct drm_master *master; /* master this node is currently associated with
  450.                                       N.B. not always minor->master */
  451.         struct list_head fbs;
  452.  
  453.         wait_queue_head_t event_wait;
  454.         struct list_head event_list;
  455.         int event_space;
  456. };
  457.  
  458. /** Wait queue */
  459. struct drm_queue {
  460.         atomic_t use_count;             /**< Outstanding uses (+1) */
  461.         atomic_t finalization;          /**< Finalization in progress */
  462.         atomic_t block_count;           /**< Count of processes waiting */
  463.         atomic_t block_read;            /**< Queue blocked for reads */
  464.         wait_queue_head_t read_queue;   /**< Processes waiting on block_read */
  465.         atomic_t block_write;           /**< Queue blocked for writes */
  466.         wait_queue_head_t write_queue;  /**< Processes waiting on block_write */
  467.         atomic_t total_queued;          /**< Total queued statistic */
  468.         atomic_t total_flushed;         /**< Total flushes statistic */
  469.         atomic_t total_locks;           /**< Total locks statistics */
  470.         enum drm_ctx_flags flags;       /**< Context preserving and 2D-only */
  471.         struct drm_waitlist waitlist;   /**< Pending buffers */
  472.         wait_queue_head_t flush_queue;  /**< Processes waiting until flush */
  473. };
  474.  
  475. /**
  476.  * Lock data.
  477.  */
  478. struct drm_lock_data {
  479.         struct drm_hw_lock *hw_lock;    /**< Hardware lock */
  480.         /** Private of lock holder's file (NULL=kernel) */
  481.         struct drm_file *file_priv;
  482.         wait_queue_head_t lock_queue;   /**< Queue of blocked processes */
  483.         unsigned long lock_time;        /**< Time of last lock in jiffies */
  484.         spinlock_t spinlock;
  485.         uint32_t kernel_waiters;
  486.         uint32_t user_waiters;
  487.         int idle_has_lock;
  488. };
  489.  
  490. /**
  491.  * DMA data.
  492.  */
  493. struct drm_device_dma {
  494.  
  495.         struct drm_buf_entry bufs[DRM_MAX_ORDER + 1];   /**< buffers, grouped by their size order */
  496.         int buf_count;                  /**< total number of buffers */
  497.         struct drm_buf **buflist;               /**< Vector of pointers into drm_device_dma::bufs */
  498.         int seg_count;
  499.         int page_count;                 /**< number of pages */
  500.         unsigned long *pagelist;        /**< page list */
  501.         unsigned long byte_count;
  502.         enum {
  503.                 _DRM_DMA_USE_AGP = 0x01,
  504.                 _DRM_DMA_USE_SG = 0x02,
  505.                 _DRM_DMA_USE_FB = 0x04,
  506.                 _DRM_DMA_USE_PCI_RO = 0x08
  507.         } flags;
  508.  
  509. };
  510.  
  511. /**
  512.  * AGP memory entry.  Stored as a doubly linked list.
  513.  */
  514. struct drm_agp_mem {
  515.         unsigned long handle;           /**< handle */
  516.         DRM_AGP_MEM *memory;
  517.         unsigned long bound;            /**< address */
  518.         int pages;
  519.         struct list_head head;
  520. };
  521.  
  522. /**
  523.  * AGP data.
  524.  *
  525.  * \sa drm_agp_init() and drm_device::agp.
  526.  */
  527. struct drm_agp_head {
  528.         DRM_AGP_KERN agp_info;          /**< AGP device information */
  529.         struct list_head memory;
  530.         unsigned long mode;             /**< AGP mode */
  531.         struct agp_bridge_data *bridge;
  532.         int enabled;                    /**< whether the AGP bus as been enabled */
  533.         int acquired;                   /**< whether the AGP device has been acquired */
  534.         unsigned long base;
  535.         int agp_mtrr;
  536.         int cant_use_aperture;
  537.         unsigned long page_mask;
  538. };
  539.  
  540. /**
  541.  * Scatter-gather memory.
  542.  */
  543. struct drm_sg_mem {
  544.         unsigned long handle;
  545.         void *virtual;
  546.         int pages;
  547.         struct page **pagelist;
  548.         dma_addr_t *busaddr;
  549. };
  550.  
  551. struct drm_sigdata {
  552.         int context;
  553.         struct drm_hw_lock *lock;
  554. };
  555.  
  556.  
  557. /**
  558.  * Kernel side of a mapping
  559.  */
  560. struct drm_local_map {
  561.         resource_size_t offset;  /**< Requested physical address (0 for SAREA)*/
  562.         unsigned long size;      /**< Requested physical size (bytes) */
  563.         enum drm_map_type type;  /**< Type of memory to map */
  564.         enum drm_map_flags flags;        /**< Flags */
  565.         void *handle;            /**< User-space: "Handle" to pass to mmap() */
  566.                                  /**< Kernel-space: kernel-virtual address */
  567.         int mtrr;                /**< MTRR slot used */
  568. };
  569.  
  570. typedef struct drm_local_map drm_local_map_t;
  571.  
  572. /**
  573.  * Mappings list
  574.  */
  575. struct drm_map_list {
  576.         struct list_head head;          /**< list head */
  577.         struct drm_hash_item hash;
  578.         struct drm_local_map *map;      /**< mapping */
  579.         uint64_t user_token;
  580.         struct drm_master *master;
  581.         struct drm_mm_node *file_offset_node;   /**< fake offset */
  582. };
  583.  
  584. /**
  585.  * Context handle list
  586.  */
  587. struct drm_ctx_list {
  588.         struct list_head head;          /**< list head */
  589.         drm_context_t handle;           /**< context handle */
  590.         struct drm_file *tag;           /**< associated fd private data */
  591. };
  592.  
  593. /* location of GART table */
  594. #define DRM_ATI_GART_MAIN 1
  595. #define DRM_ATI_GART_FB   2
  596.  
  597. #define DRM_ATI_GART_PCI 1
  598. #define DRM_ATI_GART_PCIE 2
  599. #define DRM_ATI_GART_IGP 3
  600.  
  601. struct drm_ati_pcigart_info {
  602.         int gart_table_location;
  603.         int gart_reg_if;
  604.         void *addr;
  605.         dma_addr_t bus_addr;
  606.         dma_addr_t table_mask;
  607.         struct drm_dma_handle *table_handle;
  608.         struct drm_local_map mapping;
  609.         int table_size;
  610. };
  611.  
  612. /**
  613.  * GEM specific mm private for tracking GEM objects
  614.  */
  615. struct drm_gem_mm {
  616.         struct drm_mm offset_manager;   /**< Offset mgmt for buffer objects */
  617.         struct drm_open_hash offset_hash; /**< User token hash table for maps */
  618. };
  619.  
  620. #endif
  621.  
  622. /**
  623.  * This structure defines the drm_mm memory object, which will be used by the
  624.  * DRM for its buffer objects.
  625.  */
  626. struct drm_gem_object {
  627.         /** Reference count of this object */
  628.         struct kref refcount;
  629.  
  630.         /** Handle count of this object. Each handle also holds a reference */
  631.         atomic_t handle_count; /* number of handles on this object */
  632.  
  633.         /** Related drm device */
  634.         struct drm_device *dev;
  635.  
  636.         /** File representing the shmem storage */
  637.         struct file *filp;
  638.  
  639.         /* Mapping info for this object */
  640. //      struct drm_map_list map_list;
  641.  
  642.         /**
  643.          * Size of the object, in bytes.  Immutable over the object's
  644.          * lifetime.
  645.          */
  646.         size_t size;
  647.  
  648.         /**
  649.          * Global name for this object, starts at 1. 0 means unnamed.
  650.          * Access is covered by the object_name_lock in the related drm_device
  651.          */
  652.         int name;
  653.  
  654.         /**
  655.          * Memory domains. These monitor which caches contain read/write data
  656.          * related to the object. When transitioning from one set of domains
  657.          * to another, the driver is called to ensure that caches are suitably
  658.          * flushed and invalidated
  659.          */
  660.         uint32_t read_domains;
  661.         uint32_t write_domain;
  662.  
  663.         /**
  664.          * While validating an exec operation, the
  665.          * new read/write domain values are computed here.
  666.          * They will be transferred to the above values
  667.          * at the point that any cache flushing occurs
  668.          */
  669.         uint32_t pending_read_domains;
  670.         uint32_t pending_write_domain;
  671.  
  672.         void *driver_private;
  673. };
  674.  
  675. #if 0
  676.  
  677. #include "drm_crtc.h"
  678.  
  679. /* per-master structure */
  680. struct drm_master {
  681.  
  682.         struct kref refcount; /* refcount for this master */
  683.  
  684.         struct list_head head; /**< each minor contains a list of masters */
  685.         struct drm_minor *minor; /**< link back to minor we are a master for */
  686.  
  687.         char *unique;                   /**< Unique identifier: e.g., busid */
  688.         int unique_len;                 /**< Length of unique field */
  689.         int unique_size;                /**< amount allocated */
  690.  
  691.         int blocked;                    /**< Blocked due to VC switch? */
  692.  
  693.         /** \name Authentication */
  694.         /*@{ */
  695.         struct drm_open_hash magiclist;
  696.         struct list_head magicfree;
  697.         /*@} */
  698.  
  699.         struct drm_lock_data lock;      /**< Information on hardware lock */
  700.  
  701.         void *driver_priv; /**< Private structure for driver to use */
  702. };
  703.  
  704. /* Size of ringbuffer for vblank timestamps. Just double-buffer
  705.  * in initial implementation.
  706.  */
  707. #define DRM_VBLANKTIME_RBSIZE 2
  708.  
  709. /* Flags and return codes for get_vblank_timestamp() driver function. */
  710. #define DRM_CALLED_FROM_VBLIRQ 1
  711. #define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
  712. #define DRM_VBLANKTIME_INVBL             (1 << 1)
  713.  
  714. /* get_scanout_position() return flags */
  715. #define DRM_SCANOUTPOS_VALID        (1 << 0)
  716. #define DRM_SCANOUTPOS_INVBL        (1 << 1)
  717. #define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
  718.  
  719. struct drm_bus {
  720.         int bus_type;
  721.         int (*get_irq)(struct drm_device *dev);
  722.         const char *(*get_name)(struct drm_device *dev);
  723.         int (*set_busid)(struct drm_device *dev, struct drm_master *master);
  724.         int (*set_unique)(struct drm_device *dev, struct drm_master *master,
  725.                           struct drm_unique *unique);
  726.         int (*irq_by_busid)(struct drm_device *dev, struct drm_irq_busid *p);
  727.         /* hooks that are for PCI */
  728.         int (*agp_init)(struct drm_device *dev);
  729.  
  730. };
  731.  
  732. /**
  733.  * DRM driver structure. This structure represent the common code for
  734.  * a family of cards. There will one drm_device for each card present
  735.  * in this family
  736.  */
  737. struct drm_driver {
  738.         int (*load) (struct drm_device *, unsigned long flags);
  739.         int (*firstopen) (struct drm_device *);
  740.         int (*open) (struct drm_device *, struct drm_file *);
  741.         void (*preclose) (struct drm_device *, struct drm_file *file_priv);
  742.         void (*postclose) (struct drm_device *, struct drm_file *);
  743.         void (*lastclose) (struct drm_device *);
  744.         int (*unload) (struct drm_device *);
  745.         int (*suspend) (struct drm_device *, pm_message_t state);
  746.         int (*resume) (struct drm_device *);
  747.         int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
  748.         int (*dma_quiescent) (struct drm_device *);
  749.         int (*context_dtor) (struct drm_device *dev, int context);
  750.  
  751.         /**
  752.          * get_vblank_counter - get raw hardware vblank counter
  753.          * @dev: DRM device
  754.          * @crtc: counter to fetch
  755.          *
  756.          * Driver callback for fetching a raw hardware vblank counter
  757.          * for @crtc.  If a device doesn't have a hardware counter, the
  758.          * driver can simply return the value of drm_vblank_count and
  759.          * make the enable_vblank() and disable_vblank() hooks into no-ops,
  760.          * leaving interrupts enabled at all times.
  761.          *
  762.          * Wraparound handling and loss of events due to modesetting is dealt
  763.          * with in the DRM core code.
  764.          *
  765.          * RETURNS
  766.          * Raw vblank counter value.
  767.          */
  768.         u32 (*get_vblank_counter) (struct drm_device *dev, int crtc);
  769.  
  770.         /**
  771.          * enable_vblank - enable vblank interrupt events
  772.          * @dev: DRM device
  773.          * @crtc: which irq to enable
  774.          *
  775.          * Enable vblank interrupts for @crtc.  If the device doesn't have
  776.          * a hardware vblank counter, this routine should be a no-op, since
  777.          * interrupts will have to stay on to keep the count accurate.
  778.          *
  779.          * RETURNS
  780.          * Zero on success, appropriate errno if the given @crtc's vblank
  781.          * interrupt cannot be enabled.
  782.          */
  783.         int (*enable_vblank) (struct drm_device *dev, int crtc);
  784.  
  785.         /**
  786.          * disable_vblank - disable vblank interrupt events
  787.          * @dev: DRM device
  788.          * @crtc: which irq to enable
  789.          *
  790.          * Disable vblank interrupts for @crtc.  If the device doesn't have
  791.          * a hardware vblank counter, this routine should be a no-op, since
  792.          * interrupts will have to stay on to keep the count accurate.
  793.          */
  794.         void (*disable_vblank) (struct drm_device *dev, int crtc);
  795.  
  796.         /**
  797.          * Called by \c drm_device_is_agp.  Typically used to determine if a
  798.          * card is really attached to AGP or not.
  799.          *
  800.          * \param dev  DRM device handle
  801.          *
  802.          * \returns
  803.          * One of three values is returned depending on whether or not the
  804.          * card is absolutely \b not AGP (return of 0), absolutely \b is AGP
  805.          * (return of 1), or may or may not be AGP (return of 2).
  806.          */
  807.         int (*device_is_agp) (struct drm_device *dev);
  808.  
  809.         /**
  810.          * Called by vblank timestamping code.
  811.          *
  812.          * Return the current display scanout position from a crtc.
  813.          *
  814.          * \param dev  DRM device.
  815.          * \param crtc Id of the crtc to query.
  816.          * \param *vpos Target location for current vertical scanout position.
  817.          * \param *hpos Target location for current horizontal scanout position.
  818.          *
  819.          * Returns vpos as a positive number while in active scanout area.
  820.          * Returns vpos as a negative number inside vblank, counting the number
  821.          * of scanlines to go until end of vblank, e.g., -1 means "one scanline
  822.          * until start of active scanout / end of vblank."
  823.          *
  824.          * \return Flags, or'ed together as follows:
  825.          *
  826.          * DRM_SCANOUTPOS_VALID = Query successful.
  827.          * DRM_SCANOUTPOS_INVBL = Inside vblank.
  828.          * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of
  829.          * this flag means that returned position may be offset by a constant
  830.          * but unknown small number of scanlines wrt. real scanout position.
  831.          *
  832.          */
  833.         int (*get_scanout_position) (struct drm_device *dev, int crtc,
  834.                                      int *vpos, int *hpos);
  835.  
  836.         /**
  837.          * Called by \c drm_get_last_vbltimestamp. Should return a precise
  838.          * timestamp when the most recent VBLANK interval ended or will end.
  839.          *
  840.          * Specifically, the timestamp in @vblank_time should correspond as
  841.          * closely as possible to the time when the first video scanline of
  842.          * the video frame after the end of VBLANK will start scanning out,
  843.          * the time immmediately after end of the VBLANK interval. If the
  844.          * @crtc is currently inside VBLANK, this will be a time in the future.
  845.          * If the @crtc is currently scanning out a frame, this will be the
  846.          * past start time of the current scanout. This is meant to adhere
  847.          * to the OpenML OML_sync_control extension specification.
  848.          *
  849.          * \param dev dev DRM device handle.
  850.          * \param crtc crtc for which timestamp should be returned.
  851.          * \param *max_error Maximum allowable timestamp error in nanoseconds.
  852.          *                   Implementation should strive to provide timestamp
  853.          *                   with an error of at most *max_error nanoseconds.
  854.          *                   Returns true upper bound on error for timestamp.
  855.          * \param *vblank_time Target location for returned vblank timestamp.
  856.          * \param flags 0 = Defaults, no special treatment needed.
  857.          * \param       DRM_CALLED_FROM_VBLIRQ = Function is called from vblank
  858.          *              irq handler. Some drivers need to apply some workarounds
  859.          *              for gpu-specific vblank irq quirks if flag is set.
  860.          *
  861.          * \returns
  862.          * Zero if timestamping isn't supported in current display mode or a
  863.          * negative number on failure. A positive status code on success,
  864.          * which describes how the vblank_time timestamp was computed.
  865.          */
  866.         int (*get_vblank_timestamp) (struct drm_device *dev, int crtc,
  867.                                      int *max_error,
  868.                                      struct timeval *vblank_time,
  869.                                      unsigned flags);
  870.  
  871.         /* these have to be filled in */
  872.  
  873.         irqreturn_t(*irq_handler) (DRM_IRQ_ARGS);
  874.         void (*irq_preinstall) (struct drm_device *dev);
  875.         int (*irq_postinstall) (struct drm_device *dev);
  876.         void (*irq_uninstall) (struct drm_device *dev);
  877.         void (*reclaim_buffers) (struct drm_device *dev,
  878.                                  struct drm_file * file_priv);
  879.         void (*reclaim_buffers_locked) (struct drm_device *dev,
  880.                                         struct drm_file *file_priv);
  881.         void (*reclaim_buffers_idlelocked) (struct drm_device *dev,
  882.                                             struct drm_file *file_priv);
  883.         void (*set_version) (struct drm_device *dev,
  884.                              struct drm_set_version *sv);
  885.  
  886.         /* Master routines */
  887.         int (*master_create)(struct drm_device *dev, struct drm_master *master);
  888.         void (*master_destroy)(struct drm_device *dev, struct drm_master *master);
  889.         /**
  890.          * master_set is called whenever the minor master is set.
  891.          * master_drop is called whenever the minor master is dropped.
  892.          */
  893.  
  894.         int (*master_set)(struct drm_device *dev, struct drm_file *file_priv,
  895.                           bool from_open);
  896.         void (*master_drop)(struct drm_device *dev, struct drm_file *file_priv,
  897.                             bool from_release);
  898.  
  899.         int (*debugfs_init)(struct drm_minor *minor);
  900.         void (*debugfs_cleanup)(struct drm_minor *minor);
  901.  
  902.         /**
  903.          * Driver-specific constructor for drm_gem_objects, to set up
  904.          * obj->driver_private.
  905.          *
  906.          * Returns 0 on success.
  907.          */
  908.         int (*gem_init_object) (struct drm_gem_object *obj);
  909.         void (*gem_free_object) (struct drm_gem_object *obj);
  910.  
  911.         /* vga arb irq handler */
  912.         void (*vgaarb_irq)(struct drm_device *dev, bool state);
  913.  
  914.         /* Driver private ops for this object */
  915.         struct vm_operations_struct *gem_vm_ops;
  916.  
  917.         int major;
  918.         int minor;
  919.         int patchlevel;
  920.         char *name;
  921.         char *desc;
  922.         char *date;
  923.  
  924.         u32 driver_features;
  925.         int dev_priv_size;
  926.         struct drm_ioctl_desc *ioctls;
  927.         int num_ioctls;
  928.         struct file_operations fops;
  929.         struct pci_driver pci_driver;
  930.         /* List of devices hanging off this driver */
  931.         struct list_head device_list;
  932. };
  933.  
  934. #define DRM_MINOR_UNASSIGNED 0
  935. #define DRM_MINOR_LEGACY 1
  936. #define DRM_MINOR_CONTROL 2
  937. #define DRM_MINOR_RENDER 3
  938.  
  939.  
  940. /**
  941.  * debugfs node list. This structure represents a debugfs file to
  942.  * be created by the drm core
  943.  */
  944. struct drm_debugfs_list {
  945.         const char *name; /** file name */
  946.         int (*show)(struct seq_file*, void*); /** show callback */
  947.         u32 driver_features; /**< Required driver features for this entry */
  948. };
  949.  
  950. /**
  951.  * debugfs node structure. This structure represents a debugfs file.
  952.  */
  953. struct drm_debugfs_node {
  954.         struct list_head list;
  955.         struct drm_minor *minor;
  956.         struct drm_debugfs_list *debugfs_ent;
  957.         struct dentry *dent;
  958. };
  959.  
  960. /**
  961.  * Info file list entry. This structure represents a debugfs or proc file to
  962.  * be created by the drm core
  963.  */
  964. struct drm_info_list {
  965.         const char *name; /** file name */
  966.         int (*show)(struct seq_file*, void*); /** show callback */
  967.         u32 driver_features; /**< Required driver features for this entry */
  968.         void *data;
  969. };
  970.  
  971. /**
  972.  * debugfs node structure. This structure represents a debugfs file.
  973.  */
  974. struct drm_info_node {
  975.         struct list_head list;
  976.         struct drm_minor *minor;
  977.         struct drm_info_list *info_ent;
  978.         struct dentry *dent;
  979. };
  980.  
  981. /**
  982.  * DRM minor structure. This structure represents a drm minor number.
  983.  */
  984. struct drm_minor {
  985.         int index;                      /**< Minor device number */
  986.         int type;                       /**< Control or render */
  987.         dev_t device;                   /**< Device number for mknod */
  988.         struct device kdev;             /**< Linux device */
  989.         struct drm_device *dev;
  990.  
  991.         struct proc_dir_entry *proc_root;  /**< proc directory entry */
  992.         struct drm_info_node proc_nodes;
  993.         struct dentry *debugfs_root;
  994.         struct drm_info_node debugfs_nodes;
  995.  
  996.         struct drm_master *master; /* currently active master for this node */
  997.         struct list_head master_list;
  998.         struct drm_mode_group mode_group;
  999. };
  1000.  
  1001. #endif
  1002.  
  1003. /* mode specified on the command line */
  1004. struct drm_cmdline_mode {
  1005.         bool specified;
  1006.         bool refresh_specified;
  1007.         bool bpp_specified;
  1008.         int xres, yres;
  1009.         int bpp;
  1010.         int refresh;
  1011.         bool rb;
  1012.         bool interlace;
  1013.         bool cvt;
  1014.         bool margins;
  1015.         enum drm_connector_force force;
  1016. };
  1017.  
  1018.  
  1019.  
  1020. /**
  1021.  * DRM device structure. This structure represent a complete card that
  1022.  * may contain multiple heads.
  1023.  */
  1024. struct drm_device {
  1025.         struct list_head driver_item;   /**< list of devices per driver */
  1026.         char *devname;                  /**< For /proc/interrupts */
  1027.         int if_version;                 /**< Highest interface version set */
  1028.  
  1029.         /** \name Locks */
  1030.         /*@{ */
  1031.     spinlock_t count_lock;      /**< For inuse, drm_device::open_count, drm_device::buf_use */
  1032.         struct mutex struct_mutex;      /**< For others */
  1033.         /*@} */
  1034.  
  1035.         /** \name Usage Counters */
  1036.         /*@{ */
  1037.         int open_count;                 /**< Outstanding files open */
  1038.    atomic_t ioctl_count;       /**< Outstanding IOCTLs pending */
  1039.    atomic_t vma_count;     /**< Outstanding vma areas open */
  1040.         int buf_use;                    /**< Buffers in use -- cannot alloc */
  1041.    atomic_t buf_alloc;     /**< Buffer allocation in progress */
  1042.         /*@} */
  1043.  
  1044.         /** \name Performance counters */
  1045.         /*@{ */
  1046.         unsigned long counters;
  1047. //   enum drm_stat_type types[15];
  1048.    atomic_t counts[15];
  1049.         /*@} */
  1050.  
  1051.         struct list_head filelist;
  1052.  
  1053.         /** \name Memory management */
  1054.         /*@{ */
  1055.         struct list_head maplist;       /**< Linked list of regions */
  1056.         int map_count;                  /**< Number of mappable regions */
  1057. //   struct drm_open_hash map_hash;  /**< User token hash table for maps */
  1058.  
  1059.         /** \name Context handle management */
  1060.         /*@{ */
  1061.         struct list_head ctxlist;       /**< Linked list of context handles */
  1062.         int ctx_count;                  /**< Number of context handles */
  1063.         struct mutex ctxlist_mutex;     /**< For ctxlist */
  1064.  
  1065.         struct idr ctx_idr;
  1066.  
  1067.         struct list_head vmalist;       /**< List of vmas (for debugging) */
  1068.  
  1069.         /*@} */
  1070.  
  1071.         /** \name DMA queues (contexts) */
  1072.         /*@{ */
  1073.         int queue_count;                /**< Number of active DMA queues */
  1074.         int queue_reserved;               /**< Number of reserved DMA queues */
  1075.         int queue_slots;                /**< Actual length of queuelist */
  1076. //   struct drm_queue **queuelist;   /**< Vector of pointers to DMA queues */
  1077. //   struct drm_device_dma *dma;     /**< Optional pointer for DMA support */
  1078.         /*@} */
  1079.  
  1080.         /** \name Context support */
  1081.         /*@{ */
  1082.         int irq_enabled;                /**< True if irq handler is enabled */
  1083.         __volatile__ long context_flag; /**< Context swapping flag */
  1084.         __volatile__ long interrupt_flag; /**< Interruption handler flag */
  1085.         __volatile__ long dma_flag;     /**< DMA dispatch flag */
  1086. //   wait_queue_head_t context_wait; /**< Processes waiting on ctx switch */
  1087.         int last_checked;               /**< Last context checked for DMA */
  1088.         int last_context;               /**< Last current context */
  1089.         unsigned long last_switch;      /**< jiffies at last context switch */
  1090.         /*@} */
  1091.  
  1092. //   struct work_struct work;
  1093.         /** \name VBLANK IRQ support */
  1094.         /*@{ */
  1095.  
  1096.         /*
  1097.          * At load time, disabling the vblank interrupt won't be allowed since
  1098.          * old clients may not call the modeset ioctl and therefore misbehave.
  1099.          * Once the modeset ioctl *has* been called though, we can safely
  1100.          * disable them when unused.
  1101.          */
  1102.         int vblank_disable_allowed;
  1103.  
  1104. //   wait_queue_head_t *vbl_queue;   /**< VBLANK wait queue */
  1105.    atomic_t *_vblank_count;        /**< number of VBLANK interrupts (driver must alloc the right number of counters) */
  1106.         struct timeval *_vblank_time;   /**< timestamp of current vblank_count (drivers must alloc right number of fields) */
  1107.         spinlock_t vblank_time_lock;    /**< Protects vblank count and time updates during vblank enable/disable */
  1108.    spinlock_t vbl_lock;
  1109.    atomic_t *vblank_refcount;      /* number of users of vblank interruptsper crtc */
  1110.         u32 *last_vblank;               /* protected by dev->vbl_lock, used */
  1111.                                         /* for wraparound handling */
  1112.         int *vblank_enabled;            /* so we don't call enable more than
  1113.                                            once per disable */
  1114.         int *vblank_inmodeset;          /* Display driver is setting mode */
  1115.         u32 *last_vblank_wait;          /* Last vblank seqno waited per CRTC */
  1116. //   struct timer_list vblank_disable_timer;
  1117.  
  1118.         u32 max_vblank_count;           /**< size of vblank counter register */
  1119.  
  1120.         /**
  1121.          * List of events
  1122.          */
  1123.         struct list_head vblank_event_list;
  1124.         spinlock_t event_lock;
  1125.  
  1126.         /*@} */
  1127. //   cycles_t ctx_start;
  1128. //   cycles_t lck_start;
  1129.  
  1130. //   struct fasync_struct *buf_async;/**< Processes waiting for SIGIO */
  1131. //   wait_queue_head_t buf_readers;  /**< Processes waiting to read */
  1132. //   wait_queue_head_t buf_writers;  /**< Processes waiting to ctx switch */
  1133.  
  1134. //   struct drm_agp_head *agp;   /**< AGP data */
  1135.  
  1136.         struct device *dev;             /**< Device structure */
  1137.         struct pci_dev *pdev;           /**< PCI device structure */
  1138.         int pci_vendor;                 /**< PCI vendor id */
  1139.         int pci_device;                 /**< PCI device id */
  1140.         unsigned int num_crtcs;                  /**< Number of CRTCs on this device */
  1141.         void *dev_private;              /**< device private data */
  1142.         void *mm_private;
  1143.     struct address_space *dev_mapping;
  1144. //   struct drm_sigdata sigdata;    /**< For block_all_signals */
  1145. //   sigset_t sigmask;
  1146.  
  1147. //   struct drm_driver *driver;
  1148. //   struct drm_local_map *agp_buffer_map;
  1149. //   unsigned int agp_buffer_token;
  1150. //   struct drm_minor *control;      /**< Control node for card */
  1151. //   struct drm_minor *primary;      /**< render type primary screen head */
  1152.  
  1153.         struct drm_mode_config mode_config;     /**< Current mode config */
  1154.  
  1155.         /** \name GEM information */
  1156.         /*@{ */
  1157.    spinlock_t object_name_lock;
  1158.         struct idr object_name_idr;
  1159.         /*@} */
  1160.         int switch_power_state;
  1161. };
  1162.  
  1163. #define DRM_SWITCH_POWER_ON 0
  1164. #define DRM_SWITCH_POWER_OFF 1
  1165. #define DRM_SWITCH_POWER_CHANGING 2
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176. static __inline__ int drm_device_is_agp(struct drm_device *dev)
  1177. {
  1178.     return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP);
  1179. }
  1180.  
  1181. static __inline__ int drm_device_is_pcie(struct drm_device *dev)
  1182. {
  1183.     return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP);
  1184. }
  1185.  
  1186.  
  1187.  
  1188. #if 0
  1189. static inline int drm_dev_to_irq(struct drm_device *dev)
  1190. {
  1191.         return dev->pdev->irq;
  1192. }
  1193.  
  1194. static __inline__ int drm_core_check_feature(struct drm_device *dev,
  1195.                                              int feature)
  1196. {
  1197.         return ((dev->driver->driver_features & feature) ? 1 : 0);
  1198. }
  1199.  
  1200. #ifdef __alpha__
  1201. #define drm_get_pci_domain(dev) dev->hose->index
  1202. #else
  1203. #define drm_get_pci_domain(dev) 0
  1204. #endif
  1205.  
  1206. #if __OS_HAS_AGP
  1207. static inline int drm_core_has_AGP(struct drm_device *dev)
  1208. {
  1209.         return drm_core_check_feature(dev, DRIVER_USE_AGP);
  1210. }
  1211. #else
  1212. #define drm_core_has_AGP(dev) (0)
  1213. #endif
  1214.  
  1215. #if __OS_HAS_MTRR
  1216. static inline int drm_core_has_MTRR(struct drm_device *dev)
  1217. {
  1218.         return drm_core_check_feature(dev, DRIVER_USE_MTRR);
  1219. }
  1220.  
  1221. #define DRM_MTRR_WC             MTRR_TYPE_WRCOMB
  1222.  
  1223. static inline int drm_mtrr_add(unsigned long offset, unsigned long size,
  1224.                                unsigned int flags)
  1225. {
  1226.         return mtrr_add(offset, size, flags, 1);
  1227. }
  1228.  
  1229. static inline int drm_mtrr_del(int handle, unsigned long offset,
  1230.                                unsigned long size, unsigned int flags)
  1231. {
  1232.         return mtrr_del(handle, offset, size);
  1233. }
  1234.  
  1235. #else
  1236. #define drm_core_has_MTRR(dev) (0)
  1237.  
  1238. #define DRM_MTRR_WC             0
  1239.  
  1240. static inline int drm_mtrr_add(unsigned long offset, unsigned long size,
  1241.                                unsigned int flags)
  1242. {
  1243.         return 0;
  1244. }
  1245.  
  1246. static inline int drm_mtrr_del(int handle, unsigned long offset,
  1247.                                unsigned long size, unsigned int flags)
  1248. {
  1249.         return 0;
  1250. }
  1251. #endif
  1252.  
  1253. /******************************************************************/
  1254. /** \name Internal function definitions */
  1255. /*@{*/
  1256.  
  1257.                                 /* Driver support (drm_drv.h) */
  1258. extern long drm_ioctl(struct file *filp,
  1259.                      unsigned int cmd, unsigned long arg);
  1260. extern long drm_compat_ioctl(struct file *filp,
  1261.                              unsigned int cmd, unsigned long arg);
  1262. extern int drm_lastclose(struct drm_device *dev);
  1263.  
  1264.                                 /* Device support (drm_fops.h) */
  1265. extern struct mutex drm_global_mutex;
  1266. extern int drm_open(struct inode *inode, struct file *filp);
  1267. extern int drm_stub_open(struct inode *inode, struct file *filp);
  1268. extern int drm_fasync(int fd, struct file *filp, int on);
  1269. extern ssize_t drm_read(struct file *filp, char __user *buffer,
  1270.                         size_t count, loff_t *offset);
  1271. extern int drm_release(struct inode *inode, struct file *filp);
  1272.  
  1273.                                 /* Mapping support (drm_vm.h) */
  1274. extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
  1275. extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma);
  1276. extern void drm_vm_open_locked(struct vm_area_struct *vma);
  1277. extern void drm_vm_close_locked(struct vm_area_struct *vma);
  1278. extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
  1279.  
  1280.                                 /* Memory management support (drm_memory.h) */
  1281. #include "drm_memory.h"
  1282. extern void drm_mem_init(void);
  1283. extern int drm_mem_info(char *buf, char **start, off_t offset,
  1284.                         int request, int *eof, void *data);
  1285. extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area);
  1286.  
  1287. extern void drm_free_agp(DRM_AGP_MEM * handle, int pages);
  1288. extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start);
  1289. extern DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev,
  1290.                                        struct page **pages,
  1291.                                        unsigned long num_pages,
  1292.                                        uint32_t gtt_offset,
  1293.                                        uint32_t type);
  1294. extern int drm_unbind_agp(DRM_AGP_MEM * handle);
  1295.  
  1296.                                 /* Misc. IOCTL support (drm_ioctl.h) */
  1297. extern int drm_irq_by_busid(struct drm_device *dev, void *data,
  1298.                             struct drm_file *file_priv);
  1299. extern int drm_getunique(struct drm_device *dev, void *data,
  1300.                          struct drm_file *file_priv);
  1301. extern int drm_setunique(struct drm_device *dev, void *data,
  1302.                          struct drm_file *file_priv);
  1303. extern int drm_getmap(struct drm_device *dev, void *data,
  1304.                       struct drm_file *file_priv);
  1305. extern int drm_getclient(struct drm_device *dev, void *data,
  1306.                          struct drm_file *file_priv);
  1307. extern int drm_getstats(struct drm_device *dev, void *data,
  1308.                         struct drm_file *file_priv);
  1309. extern int drm_getcap(struct drm_device *dev, void *data,
  1310.                       struct drm_file *file_priv);
  1311. extern int drm_setversion(struct drm_device *dev, void *data,
  1312.                           struct drm_file *file_priv);
  1313. extern int drm_noop(struct drm_device *dev, void *data,
  1314.                     struct drm_file *file_priv);
  1315.  
  1316.                                 /* Context IOCTL support (drm_context.h) */
  1317. extern int drm_resctx(struct drm_device *dev, void *data,
  1318.                       struct drm_file *file_priv);
  1319. extern int drm_addctx(struct drm_device *dev, void *data,
  1320.                       struct drm_file *file_priv);
  1321. extern int drm_modctx(struct drm_device *dev, void *data,
  1322.                       struct drm_file *file_priv);
  1323. extern int drm_getctx(struct drm_device *dev, void *data,
  1324.                       struct drm_file *file_priv);
  1325. extern int drm_switchctx(struct drm_device *dev, void *data,
  1326.                          struct drm_file *file_priv);
  1327. extern int drm_newctx(struct drm_device *dev, void *data,
  1328.                       struct drm_file *file_priv);
  1329. extern int drm_rmctx(struct drm_device *dev, void *data,
  1330.                      struct drm_file *file_priv);
  1331.  
  1332. extern int drm_ctxbitmap_init(struct drm_device *dev);
  1333. extern void drm_ctxbitmap_cleanup(struct drm_device *dev);
  1334. extern void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
  1335.  
  1336. extern int drm_setsareactx(struct drm_device *dev, void *data,
  1337.                            struct drm_file *file_priv);
  1338. extern int drm_getsareactx(struct drm_device *dev, void *data,
  1339.                            struct drm_file *file_priv);
  1340.  
  1341.                                 /* Authentication IOCTL support (drm_auth.h) */
  1342. extern int drm_getmagic(struct drm_device *dev, void *data,
  1343.                         struct drm_file *file_priv);
  1344. extern int drm_authmagic(struct drm_device *dev, void *data,
  1345.                          struct drm_file *file_priv);
  1346.  
  1347. /* Cache management (drm_cache.c) */
  1348. void drm_clflush_pages(struct page *pages[], unsigned long num_pages);
  1349.  
  1350.                                 /* Locking IOCTL support (drm_lock.h) */
  1351. extern int drm_lock(struct drm_device *dev, void *data,
  1352.                     struct drm_file *file_priv);
  1353. extern int drm_unlock(struct drm_device *dev, void *data,
  1354.                       struct drm_file *file_priv);
  1355. extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context);
  1356. extern void drm_idlelock_take(struct drm_lock_data *lock_data);
  1357. extern void drm_idlelock_release(struct drm_lock_data *lock_data);
  1358.  
  1359. /*
  1360.  * These are exported to drivers so that they can implement fencing using
  1361.  * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
  1362.  */
  1363.  
  1364. extern int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv);
  1365.  
  1366.                                 /* Buffer management support (drm_bufs.h) */
  1367. extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request);
  1368. extern int drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc * request);
  1369. extern int drm_addmap(struct drm_device *dev, resource_size_t offset,
  1370.                       unsigned int size, enum drm_map_type type,
  1371.                       enum drm_map_flags flags, struct drm_local_map **map_ptr);
  1372. extern int drm_addmap_ioctl(struct drm_device *dev, void *data,
  1373.                             struct drm_file *file_priv);
  1374. extern int drm_rmmap(struct drm_device *dev, struct drm_local_map *map);
  1375. extern int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map);
  1376. extern int drm_rmmap_ioctl(struct drm_device *dev, void *data,
  1377.                            struct drm_file *file_priv);
  1378. extern int drm_addbufs(struct drm_device *dev, void *data,
  1379.                        struct drm_file *file_priv);
  1380. extern int drm_infobufs(struct drm_device *dev, void *data,
  1381.                         struct drm_file *file_priv);
  1382. extern int drm_markbufs(struct drm_device *dev, void *data,
  1383.                         struct drm_file *file_priv);
  1384. extern int drm_freebufs(struct drm_device *dev, void *data,
  1385.                         struct drm_file *file_priv);
  1386. extern int drm_mapbufs(struct drm_device *dev, void *data,
  1387.                        struct drm_file *file_priv);
  1388. extern int drm_order(unsigned long size);
  1389.  
  1390.                                 /* DMA support (drm_dma.h) */
  1391. extern int drm_dma_setup(struct drm_device *dev);
  1392. extern void drm_dma_takedown(struct drm_device *dev);
  1393. extern void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf);
  1394. extern void drm_core_reclaim_buffers(struct drm_device *dev,
  1395.                                      struct drm_file *filp);
  1396.  
  1397.                                 /* IRQ support (drm_irq.h) */
  1398. extern int drm_control(struct drm_device *dev, void *data,
  1399.                        struct drm_file *file_priv);
  1400. extern irqreturn_t drm_irq_handler(DRM_IRQ_ARGS);
  1401. extern int drm_irq_install(struct drm_device *dev);
  1402. extern int drm_irq_uninstall(struct drm_device *dev);
  1403. extern void drm_driver_irq_preinstall(struct drm_device *dev);
  1404. extern void drm_driver_irq_postinstall(struct drm_device *dev);
  1405. extern void drm_driver_irq_uninstall(struct drm_device *dev);
  1406.  
  1407. extern int drm_vblank_init(struct drm_device *dev, int num_crtcs);
  1408. extern int drm_wait_vblank(struct drm_device *dev, void *data,
  1409.                            struct drm_file *filp);
  1410. extern int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq);
  1411. extern u32 drm_vblank_count(struct drm_device *dev, int crtc);
  1412. extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc,
  1413.                                      struct timeval *vblanktime);
  1414. extern bool drm_handle_vblank(struct drm_device *dev, int crtc);
  1415. extern int drm_vblank_get(struct drm_device *dev, int crtc);
  1416. extern void drm_vblank_put(struct drm_device *dev, int crtc);
  1417. extern void drm_vblank_off(struct drm_device *dev, int crtc);
  1418. extern void drm_vblank_cleanup(struct drm_device *dev);
  1419. extern u32 drm_get_last_vbltimestamp(struct drm_device *dev, int crtc,
  1420.                                      struct timeval *tvblank, unsigned flags);
  1421. extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
  1422.                                                  int crtc, int *max_error,
  1423.                                                  struct timeval *vblank_time,
  1424.                                                  unsigned flags,
  1425.                                                  struct drm_crtc *refcrtc);
  1426. extern void drm_calc_timestamping_constants(struct drm_crtc *crtc);
  1427.  
  1428. extern bool
  1429. drm_mode_parse_command_line_for_connector(const char *mode_option,
  1430.                                           struct drm_connector *connector,
  1431.                                           struct drm_cmdline_mode *mode);
  1432.  
  1433. extern struct drm_display_mode *
  1434. drm_mode_create_from_cmdline_mode(struct drm_device *dev,
  1435.                                   struct drm_cmdline_mode *cmd);
  1436.  
  1437. /* Modesetting support */
  1438. extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc);
  1439. extern void drm_vblank_post_modeset(struct drm_device *dev, int crtc);
  1440. extern int drm_modeset_ctl(struct drm_device *dev, void *data,
  1441.                            struct drm_file *file_priv);
  1442.  
  1443.                                 /* AGP/GART support (drm_agpsupport.h) */
  1444. extern struct drm_agp_head *drm_agp_init(struct drm_device *dev);
  1445. extern int drm_agp_acquire(struct drm_device *dev);
  1446. extern int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
  1447.                                  struct drm_file *file_priv);
  1448. extern int drm_agp_release(struct drm_device *dev);
  1449. extern int drm_agp_release_ioctl(struct drm_device *dev, void *data,
  1450.                                  struct drm_file *file_priv);
  1451. extern int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode);
  1452. extern int drm_agp_enable_ioctl(struct drm_device *dev, void *data,
  1453.                                 struct drm_file *file_priv);
  1454. extern int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info);
  1455. extern int drm_agp_info_ioctl(struct drm_device *dev, void *data,
  1456.                         struct drm_file *file_priv);
  1457. extern int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request);
  1458. extern int drm_agp_alloc_ioctl(struct drm_device *dev, void *data,
  1459.                          struct drm_file *file_priv);
  1460. extern int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request);
  1461. extern int drm_agp_free_ioctl(struct drm_device *dev, void *data,
  1462.                         struct drm_file *file_priv);
  1463. extern int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request);
  1464. extern int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
  1465.                           struct drm_file *file_priv);
  1466. extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request);
  1467. extern int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
  1468.                         struct drm_file *file_priv);
  1469.  
  1470.                                 /* Stub support (drm_stub.h) */
  1471. extern int drm_setmaster_ioctl(struct drm_device *dev, void *data,
  1472.                                struct drm_file *file_priv);
  1473. extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
  1474.                                 struct drm_file *file_priv);
  1475. struct drm_master *drm_master_create(struct drm_minor *minor);
  1476. extern struct drm_master *drm_master_get(struct drm_master *master);
  1477. extern void drm_master_put(struct drm_master **master);
  1478.  
  1479. extern void drm_put_dev(struct drm_device *dev);
  1480. extern int drm_put_minor(struct drm_minor **minor);
  1481. extern unsigned int drm_debug;
  1482.  
  1483. extern unsigned int drm_vblank_offdelay;
  1484. extern unsigned int drm_timestamp_precision;
  1485.  
  1486. extern struct class *drm_class;
  1487. extern struct proc_dir_entry *drm_proc_root;
  1488. extern struct dentry *drm_debugfs_root;
  1489.  
  1490. extern struct idr drm_minors_idr;
  1491.  
  1492. extern struct drm_local_map *drm_getsarea(struct drm_device *dev);
  1493.  
  1494.                                 /* Proc support (drm_proc.h) */
  1495. extern int drm_proc_init(struct drm_minor *minor, int minor_id,
  1496.                          struct proc_dir_entry *root);
  1497. extern int drm_proc_cleanup(struct drm_minor *minor, struct proc_dir_entry *root);
  1498.  
  1499.                                 /* Debugfs support */
  1500. #if defined(CONFIG_DEBUG_FS)
  1501. extern int drm_debugfs_init(struct drm_minor *minor, int minor_id,
  1502.                             struct dentry *root);
  1503. extern int drm_debugfs_create_files(struct drm_info_list *files, int count,
  1504.                                     struct dentry *root, struct drm_minor *minor);
  1505. extern int drm_debugfs_remove_files(struct drm_info_list *files, int count,
  1506.                                     struct drm_minor *minor);
  1507. extern int drm_debugfs_cleanup(struct drm_minor *minor);
  1508. #endif
  1509.  
  1510.                                 /* Info file support */
  1511. extern int drm_name_info(struct seq_file *m, void *data);
  1512. extern int drm_vm_info(struct seq_file *m, void *data);
  1513. extern int drm_queues_info(struct seq_file *m, void *data);
  1514. extern int drm_bufs_info(struct seq_file *m, void *data);
  1515. extern int drm_vblank_info(struct seq_file *m, void *data);
  1516. extern int drm_clients_info(struct seq_file *m, void* data);
  1517. extern int drm_gem_name_info(struct seq_file *m, void *data);
  1518.  
  1519. #if DRM_DEBUG_CODE
  1520. extern int drm_vma_info(struct seq_file *m, void *data);
  1521. #endif
  1522.  
  1523.                                 /* Scatter Gather Support (drm_scatter.h) */
  1524. extern void drm_sg_cleanup(struct drm_sg_mem * entry);
  1525. extern int drm_sg_alloc_ioctl(struct drm_device *dev, void *data,
  1526.                         struct drm_file *file_priv);
  1527. extern int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request);
  1528. extern int drm_sg_free(struct drm_device *dev, void *data,
  1529.                        struct drm_file *file_priv);
  1530.  
  1531.                                /* ATI PCIGART support (ati_pcigart.h) */
  1532. extern int drm_ati_pcigart_init(struct drm_device *dev,
  1533.                                 struct drm_ati_pcigart_info * gart_info);
  1534. extern int drm_ati_pcigart_cleanup(struct drm_device *dev,
  1535.                                    struct drm_ati_pcigart_info * gart_info);
  1536.  
  1537. extern drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size,
  1538.                                        size_t align);
  1539. extern void __drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah);
  1540. extern void drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah);
  1541.  
  1542.                                /* sysfs support (drm_sysfs.c) */
  1543. struct drm_sysfs_class;
  1544. extern struct class *drm_sysfs_create(struct module *owner, char *name);
  1545. extern void drm_sysfs_destroy(void);
  1546. extern int drm_sysfs_device_add(struct drm_minor *minor);
  1547. extern void drm_sysfs_hotplug_event(struct drm_device *dev);
  1548. extern void drm_sysfs_device_remove(struct drm_minor *minor);
  1549. extern char *drm_get_connector_status_name(enum drm_connector_status status);
  1550.  
  1551. static inline int drm_sysfs_connector_add(struct drm_connector *connector)
  1552. { return 0; };
  1553.  
  1554. static inline void drm_sysfs_connector_remove(struct drm_connector *connector)
  1555. { };
  1556.  
  1557. /* Graphics Execution Manager library functions (drm_gem.c) */
  1558. int drm_gem_init(struct drm_device *dev);
  1559. void drm_gem_destroy(struct drm_device *dev);
  1560. void drm_gem_object_release(struct drm_gem_object *obj);
  1561. void drm_gem_object_free(struct kref *kref);
  1562. struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev,
  1563.                                             size_t size);
  1564. int drm_gem_object_init(struct drm_device *dev,
  1565.                         struct drm_gem_object *obj, size_t size);
  1566. void drm_gem_object_handle_free(struct drm_gem_object *obj);
  1567. void drm_gem_vm_open(struct vm_area_struct *vma);
  1568. void drm_gem_vm_close(struct vm_area_struct *vma);
  1569. int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
  1570.  
  1571. static inline void
  1572. drm_gem_object_reference(struct drm_gem_object *obj)
  1573. {
  1574.         kref_get(&obj->refcount);
  1575. }
  1576.  
  1577. static inline void
  1578. drm_gem_object_unreference(struct drm_gem_object *obj)
  1579. {
  1580.         if (obj == NULL)
  1581.                 return;
  1582.  
  1583.         kref_put(&obj->refcount, drm_gem_object_free);
  1584. }
  1585.  
  1586. int drm_gem_handle_create(struct drm_file *file_priv,
  1587.                           struct drm_gem_object *obj,
  1588.                           u32 *handlep);
  1589. int drm_gem_handle_delete(struct drm_file *filp, u32 handle);
  1590.  
  1591. static inline void
  1592. drm_gem_object_handle_reference(struct drm_gem_object *obj)
  1593. {
  1594.         drm_gem_object_reference(obj);
  1595.         atomic_inc(&obj->handle_count);
  1596. }
  1597.  
  1598. static inline void
  1599. drm_gem_object_handle_unreference(struct drm_gem_object *obj)
  1600. {
  1601.         if (obj == NULL)
  1602.                 return;
  1603.  
  1604.         if (atomic_read(&obj->handle_count) == 0)
  1605.                 return;
  1606.         /*
  1607.          * Must bump handle count first as this may be the last
  1608.          * ref, in which case the object would disappear before we
  1609.          * checked for a name
  1610.          */
  1611.         kref_put(&obj->handlecount, drm_gem_object_handle_free);
  1612.         drm_gem_object_unreference(obj);
  1613. }
  1614.  
  1615. struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev,
  1616.                                              struct drm_file *filp,
  1617.                                              u32 handle);
  1618. int drm_gem_close_ioctl(struct drm_device *dev, void *data,
  1619.                         struct drm_file *file_priv);
  1620. int drm_gem_flink_ioctl(struct drm_device *dev, void *data,
  1621.                         struct drm_file *file_priv);
  1622. int drm_gem_open_ioctl(struct drm_device *dev, void *data,
  1623.                        struct drm_file *file_priv);
  1624. void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
  1625. void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
  1626.  
  1627. extern void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev);
  1628. extern void drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev);
  1629. extern void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev);
  1630.  
  1631. static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev,
  1632.                                                          unsigned int token)
  1633. {
  1634.         struct drm_map_list *_entry;
  1635.         list_for_each_entry(_entry, &dev->maplist, head)
  1636.             if (_entry->user_token == token)
  1637.                 return _entry->map;
  1638.         return NULL;
  1639. }
  1640.  
  1641. static __inline__ void drm_core_dropmap(struct drm_local_map *map)
  1642. {
  1643. }
  1644.  
  1645.  
  1646. static __inline__ void *drm_calloc_large(size_t nmemb, size_t size)
  1647. {
  1648.         if (size * nmemb <= PAGE_SIZE)
  1649.             return kcalloc(nmemb, size, GFP_KERNEL);
  1650.  
  1651.         if (size != 0 && nmemb > ULONG_MAX / size)
  1652.                 return NULL;
  1653.  
  1654.         return __vmalloc(size * nmemb,
  1655.                          GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL);
  1656. }
  1657.  
  1658. static __inline void drm_free_large(void *ptr)
  1659. {
  1660.         if (!is_vmalloc_addr(ptr))
  1661.                 return kfree(ptr);
  1662.  
  1663.         vfree(ptr);
  1664. }
  1665. /*@}*/
  1666.  
  1667. #endif
  1668.  
  1669.    
  1670.  
  1671. #endif                          /* __KERNEL__ */
  1672. #endif
  1673.