Author: rnoland
Date: Sat Jan 10 14:53:47 2009
New Revision: 187021
URL: http://svn.freebsd.org/changeset/base/187021

Log:
  MFC most all of drm from HEAD.
  
  This brings in the following:
     Merged /head/sys:r182080,182467-182469,182883-182884,183573,
        183603-183605,183828,183830-183834,184212-184213,184263,
        184373-184375
  
        - Support for latest Intel chips
        - Support and fixes for many AMD/ATI chips r500 and below
        - Support AMD/ATI IGP based chips (rs690/rs485)
        - Lots of code cleanups
        - Lots of other fixes and changes since the existing drm
          is 2+ years old
  
  Approved by:  kib

Added:
  stable/7/sys/dev/drm/drm_internal.h
     - copied unchanged from r182080, head/sys/dev/drm/drm_internal.h
  stable/7/sys/dev/drm/i915_suspend.c
     - copied, changed from r182080, head/sys/dev/drm/i915_suspend.c
  stable/7/sys/dev/drm/radeon_microcode.h
     - copied unchanged from r182080, head/sys/dev/drm/radeon_microcode.h
Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/conf/files
  stable/7/sys/dev/drm/ati_pcigart.c
  stable/7/sys/dev/drm/drm-subprocess.pl
  stable/7/sys/dev/drm/drm.h
  stable/7/sys/dev/drm/drmP.h
  stable/7/sys/dev/drm/drm_agpsupport.c
  stable/7/sys/dev/drm/drm_atomic.h
  stable/7/sys/dev/drm/drm_auth.c
  stable/7/sys/dev/drm/drm_bufs.c
  stable/7/sys/dev/drm/drm_context.c
  stable/7/sys/dev/drm/drm_dma.c
  stable/7/sys/dev/drm/drm_drawable.c
  stable/7/sys/dev/drm/drm_drv.c
  stable/7/sys/dev/drm/drm_fops.c
  stable/7/sys/dev/drm/drm_ioctl.c
  stable/7/sys/dev/drm/drm_irq.c
  stable/7/sys/dev/drm/drm_linux_list.h
  stable/7/sys/dev/drm/drm_lock.c
  stable/7/sys/dev/drm/drm_memory.c
  stable/7/sys/dev/drm/drm_pci.c
  stable/7/sys/dev/drm/drm_pciids.h
  stable/7/sys/dev/drm/drm_sarea.h
  stable/7/sys/dev/drm/drm_scatter.c
  stable/7/sys/dev/drm/drm_sysctl.c
  stable/7/sys/dev/drm/drm_vm.c
  stable/7/sys/dev/drm/i915_dma.c
  stable/7/sys/dev/drm/i915_drm.h
  stable/7/sys/dev/drm/i915_drv.c
  stable/7/sys/dev/drm/i915_drv.h
  stable/7/sys/dev/drm/i915_irq.c
  stable/7/sys/dev/drm/i915_mem.c
  stable/7/sys/dev/drm/mach64_dma.c
  stable/7/sys/dev/drm/mach64_drm.h
  stable/7/sys/dev/drm/mach64_drv.c
  stable/7/sys/dev/drm/mach64_drv.h
  stable/7/sys/dev/drm/mach64_irq.c
  stable/7/sys/dev/drm/mach64_state.c
  stable/7/sys/dev/drm/mga_dma.c
  stable/7/sys/dev/drm/mga_drm.h
  stable/7/sys/dev/drm/mga_drv.c
  stable/7/sys/dev/drm/mga_drv.h
  stable/7/sys/dev/drm/mga_irq.c
  stable/7/sys/dev/drm/mga_state.c
  stable/7/sys/dev/drm/mga_warp.c
  stable/7/sys/dev/drm/r128_cce.c
  stable/7/sys/dev/drm/r128_drm.h
  stable/7/sys/dev/drm/r128_drv.c
  stable/7/sys/dev/drm/r128_drv.h
  stable/7/sys/dev/drm/r128_irq.c
  stable/7/sys/dev/drm/r128_state.c
  stable/7/sys/dev/drm/r300_cmdbuf.c
  stable/7/sys/dev/drm/r300_reg.h
  stable/7/sys/dev/drm/radeon_cp.c
  stable/7/sys/dev/drm/radeon_drm.h
  stable/7/sys/dev/drm/radeon_drv.c
  stable/7/sys/dev/drm/radeon_drv.h
  stable/7/sys/dev/drm/radeon_irq.c
  stable/7/sys/dev/drm/radeon_mem.c
  stable/7/sys/dev/drm/radeon_state.c
  stable/7/sys/dev/drm/savage_bci.c
  stable/7/sys/dev/drm/savage_drm.h
  stable/7/sys/dev/drm/savage_drv.c
  stable/7/sys/dev/drm/savage_drv.h
  stable/7/sys/dev/drm/savage_state.c
  stable/7/sys/dev/drm/sis_drv.c
  stable/7/sys/dev/drm/sis_drv.h
  stable/7/sys/dev/drm/sis_mm.c
  stable/7/sys/dev/drm/tdfx_drv.c
  stable/7/sys/modules/drm/i915/Makefile

Modified: stable/7/sys/conf/files
==============================================================================
--- stable/7/sys/conf/files     Sat Jan 10 14:14:00 2009        (r187020)
+++ stable/7/sys/conf/files     Sat Jan 10 14:53:47 2009        (r187021)
@@ -576,6 +576,7 @@ dev/drm/i915_dma.c          optional i915drm
 dev/drm/i915_drv.c             optional i915drm
 dev/drm/i915_irq.c             optional i915drm
 dev/drm/i915_mem.c             optional i915drm
+dev/drm/i915_suspend.c         optional i915drm
 dev/drm/mach64_dma.c           optional mach64drm
 dev/drm/mach64_drv.c           optional mach64drm
 dev/drm/mach64_irq.c           optional mach64drm

Modified: stable/7/sys/dev/drm/ati_pcigart.c
==============================================================================
--- stable/7/sys/dev/drm/ati_pcigart.c  Sat Jan 10 14:14:00 2009        
(r187020)
+++ stable/7/sys/dev/drm/ati_pcigart.c  Sat Jan 10 14:53:47 2009        
(r187021)
@@ -1,6 +1,3 @@
-/* ati_pcigart.h -- ATI PCI GART support -*- linux-c -*-
- * Created: Wed Dec 13 21:52:19 2000 by gar...@valinux.com
- */
 /*-
  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
  * All Rights Reserved.
@@ -32,72 +29,194 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+/** @file ati_pcigart.c
+ * Implementation of ATI's PCIGART, which provides an aperture in card virtual
+ * address space with addresses remapped to system memory.
+ */
+
 #include "dev/drm/drmP.h"
 
 #define ATI_PCIGART_PAGE_SIZE          4096    /* PCI GART page size */
-#define ATI_MAX_PCIGART_PAGES          8192    /* 32 MB aperture, 4K pages */
-#define ATI_PCIGART_TABLE_SIZE         32768
+#define ATI_PCIGART_PAGE_MASK          (~(ATI_PCIGART_PAGE_SIZE-1))
+
+#define ATI_PCIE_WRITE 0x4
+#define ATI_PCIE_READ 0x8
 
-int drm_ati_pcigart_init(drm_device_t *dev, drm_ati_pcigart_info *gart_info)
+static void
+drm_ati_alloc_pcigart_table_cb(void *arg, bus_dma_segment_t *segs,
+                              int nsegs, int error)
 {
-       unsigned long pages;
-       u32 *pci_gart = NULL, page_base;
-       int i, j;
+       struct drm_dma_handle *dmah = arg;
 
-       if (dev->sg == NULL) {
-               DRM_ERROR( "no scatter/gather memory!\n" );
-               return 0;
+       if (error != 0)
+               return;
+
+       KASSERT(nsegs == 1,
+           ("drm_ati_alloc_pcigart_table_cb: bad dma segment count"));
+
+       dmah->busaddr = segs[0].ds_addr;
+}
+
+static int
+drm_ati_alloc_pcigart_table(struct drm_device *dev,
+                           struct drm_ati_pcigart_info *gart_info)
+{
+       struct drm_dma_handle *dmah;
+       int flags, ret;
+
+       dmah = malloc(sizeof(struct drm_dma_handle), DRM_MEM_DMA,
+           M_ZERO | M_NOWAIT);
+       if (dmah == NULL)
+               return ENOMEM;
+
+       DRM_UNLOCK();
+       ret = bus_dma_tag_create(NULL, PAGE_SIZE, 0, /* tag, align, boundary */
+           gart_info->table_mask, BUS_SPACE_MAXADDR, /* lowaddr, highaddr */
+           NULL, NULL, /* filtfunc, filtfuncargs */
+           gart_info->table_size, 1, /* maxsize, nsegs */
+           gart_info->table_size, /* maxsegsize */
+           BUS_DMA_ALLOCNOW, NULL, NULL, /* flags, lockfunc, lockfuncargs */
+           &dmah->tag);
+       if (ret != 0) {
+               free(dmah, DRM_MEM_DMA);
+               return ENOMEM;
        }
 
-       if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) {
-               /* GART table in system memory */
-               dev->sg->dmah = drm_pci_alloc(dev, ATI_PCIGART_TABLE_SIZE, 0,
-                   0xfffffffful);
-               if (dev->sg->dmah == NULL) {
-                       DRM_ERROR("cannot allocate PCI GART table!\n");
-                       return 0;
-               }
+       flags = BUS_DMA_NOWAIT | BUS_DMA_ZERO;
+       if (gart_info->gart_reg_if == DRM_ATI_GART_IGP)
+           flags |= BUS_DMA_NOCACHE;
        
-               gart_info->addr = (void *)dev->sg->dmah->vaddr;
-               gart_info->bus_addr = dev->sg->dmah->busaddr;
-               pci_gart = (u32 *)dev->sg->dmah->vaddr;
-       } else {
-               /* GART table in framebuffer memory */
-               pci_gart = gart_info->addr;
+       ret = bus_dmamem_alloc(dmah->tag, &dmah->vaddr, flags, &dmah->map);
+       if (ret != 0) {
+               bus_dma_tag_destroy(dmah->tag);
+               free(dmah, DRM_MEM_DMA);
+               return ENOMEM;
        }
-       
-       pages = DRM_MIN(dev->sg->pages, ATI_MAX_PCIGART_PAGES);
+       DRM_LOCK();
 
-       bzero(pci_gart, ATI_PCIGART_TABLE_SIZE);
+       ret = bus_dmamap_load(dmah->tag, dmah->map, dmah->vaddr,
+           gart_info->table_size, drm_ati_alloc_pcigart_table_cb, dmah, 0);
+       if (ret != 0) {
+               bus_dmamem_free(dmah->tag, dmah->vaddr, dmah->map);
+               bus_dma_tag_destroy(dmah->tag);
+               free(dmah, DRM_MEM_DMA);
+               return ENOMEM;
+       }
 
-       KASSERT(PAGE_SIZE >= ATI_PCIGART_PAGE_SIZE, ("page size too small"));
+       dev->sg->dmah = dmah;
 
-       for ( i = 0 ; i < pages ; i++ ) {
-               page_base = (u32) dev->sg->busaddr[i];
+       return 0;
+}
 
-               for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) {
-                       if (gart_info->is_pcie)
-                               *pci_gart = (cpu_to_le32(page_base) >> 8) | 0xc;
-                       else
-                               *pci_gart = cpu_to_le32(page_base);
-                       pci_gart++;
-                       page_base += ATI_PCIGART_PAGE_SIZE;
-               }
+static void
+drm_ati_free_pcigart_table(struct drm_device *dev,
+                          struct drm_ati_pcigart_info *gart_info)
+{
+       struct drm_dma_handle *dmah = dev->sg->dmah;
+
+       bus_dmamem_free(dmah->tag, dmah->vaddr, dmah->map);
+       bus_dma_tag_destroy(dmah->tag);
+       free(dmah, DRM_MEM_DMA);
+       dev->sg->dmah = NULL;
+}
+
+int
+drm_ati_pcigart_cleanup(struct drm_device *dev,
+                       struct drm_ati_pcigart_info *gart_info)
+{
+       /* we need to support large memory configurations */
+       if (dev->sg == NULL) {
+               DRM_ERROR("no scatter/gather memory!\n");
+               return 0;
        }
 
-       DRM_MEMORYBARRIER();
+       if (gart_info->bus_addr) {
+               if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) {
+                       gart_info->bus_addr = 0;
+                       if (dev->sg->dmah)
+                               drm_ati_free_pcigart_table(dev, gart_info);
+               }
+       }
 
        return 1;
 }
 
-int drm_ati_pcigart_cleanup(drm_device_t *dev, drm_ati_pcigart_info *gart_info)
+int
+drm_ati_pcigart_init(struct drm_device *dev,
+                    struct drm_ati_pcigart_info *gart_info)
 {
+       void *address = NULL;
+       unsigned long pages;
+       u32 *pci_gart, page_base;
+       dma_addr_t bus_address = 0;
+       dma_addr_t entry_addr;
+       int i, j, ret = 0;
+       int max_pages;
+
+       /* we need to support large memory configurations */
        if (dev->sg == NULL) {
-               DRM_ERROR( "no scatter/gather memory!\n" );
-               return 0;
+               DRM_ERROR("no scatter/gather memory!\n");
+               goto done;
        }
 
-       drm_pci_free(dev, dev->sg->dmah);
+       if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) {
+               DRM_DEBUG("PCI: no table in VRAM: using normal RAM\n");
 
-       return 1;
+               ret = drm_ati_alloc_pcigart_table(dev, gart_info);
+               if (ret) {
+                       DRM_ERROR("cannot allocate PCI GART page!\n");
+                       goto done;
+               }
+
+               address = (void *)dev->sg->dmah->vaddr;
+               bus_address = dev->sg->dmah->busaddr;
+       } else {
+               address = gart_info->addr;
+               bus_address = gart_info->bus_addr;
+               DRM_DEBUG("PCI: Gart Table: VRAM %08X mapped at %08lX\n",
+                         (unsigned int)bus_address, (unsigned long)address);
+       }
+
+       pci_gart = (u32 *) address;
+
+       max_pages = (gart_info->table_size / sizeof(u32));
+       pages = (dev->sg->pages <= max_pages)
+           ? dev->sg->pages : max_pages;
+
+       memset(pci_gart, 0, max_pages * sizeof(u32));
+
+       KASSERT(PAGE_SIZE >= ATI_PCIGART_PAGE_SIZE, ("page size too small"));
+
+       for (i = 0; i < pages; i++) {
+               entry_addr = dev->sg->busaddr[i];
+               for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) {
+                       page_base = (u32) entry_addr & ATI_PCIGART_PAGE_MASK;
+                       switch(gart_info->gart_reg_if) {
+                       case DRM_ATI_GART_IGP:
+                               page_base |=
+                                   (upper_32_bits(entry_addr) & 0xff) << 4;
+                               page_base |= 0xc;
+                               break;
+                       case DRM_ATI_GART_PCIE:
+                               page_base >>= 8;
+                               page_base |=
+                                   (upper_32_bits(entry_addr) & 0xff) << 24;
+                               page_base |= ATI_PCIE_READ | ATI_PCIE_WRITE;
+                               break;
+                       default:
+                       case DRM_ATI_GART_PCI:
+                               break;
+                       }
+                       *pci_gart = cpu_to_le32(page_base);
+                       pci_gart++;
+                       entry_addr += ATI_PCIGART_PAGE_SIZE;
+               }
+       }
+
+       ret = 1;
+
+    done:
+       gart_info->addr = address;
+       gart_info->bus_addr = bus_address;
+       return ret;
 }

Modified: stable/7/sys/dev/drm/drm-subprocess.pl
==============================================================================
--- stable/7/sys/dev/drm/drm-subprocess.pl      Sat Jan 10 14:14:00 2009        
(r187020)
+++ stable/7/sys/dev/drm/drm-subprocess.pl      Sat Jan 10 14:53:47 2009        
(r187021)
@@ -37,6 +37,7 @@ while (<>) {
                s/#include "(.*)_drm.h/#include "dev\/drm\/\1_drm.h/;
                s/#include "mga_ucode.h/#include "dev\/drm\/mga_ucode.h/;
                s/#include "r300_reg.h/#include "dev\/drm\/r300_reg.h/;
+               s/#include "radeon_microcode.h/#include 
"dev\/drm\/radeon_microcode.h/;
                s/#include "sis_ds.h/#include "dev\/drm\/sis_ds.h/;
                s/#include "drm/#include "dev\/drm\/drm/;
                print;
@@ -47,4 +48,4 @@ while (<>) {
 # if we never found the copyright header, then we're still a line behind.
 if (!$foundopening) {
        print $lastline;
-}
\ No newline at end of file
+}

Modified: stable/7/sys/dev/drm/drm.h
==============================================================================
--- stable/7/sys/dev/drm/drm.h  Sat Jan 10 14:14:00 2009        (r187020)
+++ stable/7/sys/dev/drm/drm.h  Sat Jan 10 14:53:47 2009        (r187021)
@@ -64,6 +64,9 @@ __FBSDID("$FreeBSD$");
 #ifndef __user
 #define __user
 #endif
+#ifndef __iomem
+#define __iomem
+#endif
 
 #ifdef __GNUC__
 # define DEPRECATED  __attribute__ ((deprecated))
@@ -72,9 +75,6 @@ __FBSDID("$FreeBSD$");
 #endif
 
 #if defined(__linux__)
-#if defined(__KERNEL__)
-#include <linux/config.h>
-#endif
 #include <asm/ioctl.h>         /* For _IO* macros */
 #define DRM_IOCTL_NR(n)                _IOC_NR(n)
 #define DRM_IOC_VOID           _IOC_NONE
@@ -83,14 +83,7 @@ __FBSDID("$FreeBSD$");
 #define DRM_IOC_READWRITE      _IOC_READ|_IOC_WRITE
 #define DRM_IOC(dir, group, nr, size) _IOC(dir, group, nr, size)
 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || 
defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
-#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && defined(IN_MODULE)
-/* Prevent name collision when including sys/ioccom.h */
-#undef ioctl
-#include <sys/ioccom.h>
-#define ioctl(a,b,c)           xf86ioctl(a,b,c)
-#else
 #include <sys/ioccom.h>
-#endif                         /* __FreeBSD__ && xf86ioctl */
 #define DRM_IOCTL_NR(n)                ((n) & 0xff)
 #define DRM_IOC_VOID           IOC_VOID
 #define DRM_IOC_READ           IOC_OUT
@@ -99,24 +92,6 @@ __FBSDID("$FreeBSD$");
 #define DRM_IOC(dir, group, nr, size) _IOC(dir, group, nr, size)
 #endif
 
-#define XFREE86_VERSION(major,minor,patch,snap) \
-               ((major << 16) | (minor << 8) | patch)
-
-#ifndef CONFIG_XFREE86_VERSION
-#define CONFIG_XFREE86_VERSION XFREE86_VERSION(4,1,0,0)
-#endif
-
-#if CONFIG_XFREE86_VERSION < XFREE86_VERSION(4,1,0,0)
-#define DRM_PROC_DEVICES "/proc/devices"
-#define DRM_PROC_MISC   "/proc/misc"
-#define DRM_PROC_DRM    "/proc/drm"
-#define DRM_DEV_DRM     "/dev/drm"
-#define DRM_DEV_MODE    (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
-#define DRM_DEV_UID     0
-#define DRM_DEV_GID     0
-#endif
-
-#if CONFIG_XFREE86_VERSION >= XFREE86_VERSION(4,1,0,0)
 #ifdef __OpenBSD__
 #define DRM_MAJOR       81
 #endif
@@ -124,7 +99,7 @@ __FBSDID("$FreeBSD$");
 #define DRM_MAJOR       226
 #endif
 #define DRM_MAX_MINOR   15
-#endif
+
 #define DRM_NAME       "drm"     /**< Name in kernel, /dev, and /proc */
 #define DRM_MIN_ORDER  5         /**< At least 2^5 bytes = 32 bytes */
 #define DRM_MAX_ORDER  22        /**< Up to 2^22 bytes = 4MB */
@@ -139,6 +114,7 @@ __FBSDID("$FreeBSD$");
 #if defined(__linux__)
 typedef unsigned int drm_handle_t;
 #else
+#include <sys/types.h>
 typedef unsigned long drm_handle_t;    /**< To mapped regions */
 #endif
 typedef unsigned int drm_context_t;    /**< GLXContext handle */
@@ -154,23 +130,23 @@ typedef unsigned int drm_magic_t; /**< M
  * \note KW: Actually it's illegal to change either for
  * backwards-compatibility reasons.
  */
-typedef struct drm_clip_rect {
+struct drm_clip_rect {
        unsigned short x1;
        unsigned short y1;
        unsigned short x2;
        unsigned short y2;
-} drm_clip_rect_t;
+};
 
 /**
  * Texture region,
  */
-typedef struct drm_tex_region {
+struct drm_tex_region {
        unsigned char next;
        unsigned char prev;
        unsigned char in_use;
        unsigned char padding;
        unsigned int age;
-} drm_tex_region_t;
+};
 
 /**
  * Hardware lock.
@@ -179,10 +155,10 @@ typedef struct drm_tex_region {
  * processor bus contention on a multiprocessor system, there should not be any
  * other data stored in the same cache line.
  */
-typedef struct drm_hw_lock {
+struct drm_hw_lock {
        __volatile__ unsigned int lock;         /**< lock variable */
        char padding[60];                       /**< Pad to cache line */
-} drm_hw_lock_t;
+};
 
 /* This is beyond ugly, and only works on GCC.  However, it allows me to use
  * drm.h in places (i.e., in the X-server) where I can't use size_t.  The real
@@ -205,7 +181,7 @@ typedef struct drm_hw_lock {
  *
  * \sa drmGetVersion().
  */
-typedef struct drm_version {
+struct drm_version {
        int version_major;        /**< Major version */
        int version_minor;        /**< Minor version */
        int version_patchlevel;   /**< Patch level */
@@ -215,35 +191,35 @@ typedef struct drm_version {
        char __user *date;                /**< User-space buffer to hold date */
        DRM_SIZE_T desc_len;      /**< Length of desc buffer */
        char __user *desc;                /**< User-space buffer to hold desc */
-} drm_version_t;
+};
 
 /**
  * DRM_IOCTL_GET_UNIQUE ioctl argument type.
  *
  * \sa drmGetBusid() and drmSetBusId().
  */
-typedef struct drm_unique {
+struct drm_unique {
        DRM_SIZE_T unique_len;    /**< Length of unique */
        char __user *unique;              /**< Unique name for driver 
instantiation */
-} drm_unique_t;
+};
 
 #undef DRM_SIZE_T
 
-typedef struct drm_list {
+struct drm_list {
        int count;                /**< Length of user-space structures */
-       drm_version_t __user *version;
-} drm_list_t;
+       struct drm_version __user *version;
+};
 
-typedef struct drm_block {
+struct drm_block {
        int unused;
-} drm_block_t;
+};
 
 /**
  * DRM_IOCTL_CONTROL ioctl argument type.
  *
  * \sa drmCtlInstHandler() and drmCtlUninstHandler().
  */
-typedef struct drm_control {
+struct drm_control {
        enum {
                DRM_ADD_COMMAND,
                DRM_RM_COMMAND,
@@ -251,37 +227,39 @@ typedef struct drm_control {
                DRM_UNINST_HANDLER
        } func;
        int irq;
-} drm_control_t;
+};
 
 /**
  * Type of memory to map.
  */
-typedef enum drm_map_type {
+enum drm_map_type {
        _DRM_FRAME_BUFFER = 0,    /**< WC (no caching), no core dump */
        _DRM_REGISTERS = 1,       /**< no caching, no core dump */
        _DRM_SHM = 2,             /**< shared, cached */
        _DRM_AGP = 3,             /**< AGP/GART */
        _DRM_SCATTER_GATHER = 4,  /**< Scatter/gather memory for PCI DMA */
-       _DRM_CONSISTENT = 5       /**< Consistent memory for PCI DMA */
-} drm_map_type_t;
+       _DRM_CONSISTENT = 5,      /**< Consistent memory for PCI DMA */
+       _DRM_TTM = 6
+};
 
 /**
  * Memory mapping flags.
  */
-typedef enum drm_map_flags {
+enum drm_map_flags {
        _DRM_RESTRICTED = 0x01,      /**< Cannot be mapped to user-virtual */
        _DRM_READ_ONLY = 0x02,
        _DRM_LOCKED = 0x04,          /**< shared, cached, locked */
        _DRM_KERNEL = 0x08,          /**< kernel requires access */
        _DRM_WRITE_COMBINING = 0x10, /**< use write-combining if available */
        _DRM_CONTAINS_LOCK = 0x20,   /**< SHM page that contains lock */
-       _DRM_REMOVABLE = 0x40        /**< Removable mapping */
-} drm_map_flags_t;
+       _DRM_REMOVABLE = 0x40,       /**< Removable mapping */
+       _DRM_DRIVER = 0x80           /**< Managed by driver */
+};
 
-typedef struct drm_ctx_priv_map {
+struct drm_ctx_priv_map {
        unsigned int ctx_id;     /**< Context requesting private mapping */
        void *handle;            /**< Handle of map */
-} drm_ctx_priv_map_t;
+};
 
 /**
  * DRM_IOCTL_GET_MAP, DRM_IOCTL_ADD_MAP and DRM_IOCTL_RM_MAP ioctls
@@ -289,30 +267,30 @@ typedef struct drm_ctx_priv_map {
  *
  * \sa drmAddMap().
  */
-typedef struct drm_map {
+struct drm_map {
        unsigned long offset;    /**< Requested physical address (0 for SAREA)*/
        unsigned long size;      /**< Requested physical size (bytes) */
-       drm_map_type_t type;     /**< Type of memory to map */
-       drm_map_flags_t flags;   /**< Flags */
+       enum drm_map_type type;  /**< Type of memory to map */
+       enum drm_map_flags flags;        /**< Flags */
        void *handle;            /**< User-space: "Handle" to pass to mmap() */
                                 /**< Kernel-space: kernel-virtual address */
        int mtrr;                /**< MTRR slot used */
        /*   Private data */
-} drm_map_t;
+};
 
 /**
  * DRM_IOCTL_GET_CLIENT ioctl argument type.
  */
-typedef struct drm_client {
+struct drm_client {
        int idx;                /**< Which client desired? */
        int auth;               /**< Is client authenticated? */
        unsigned long pid;      /**< Process ID */
        unsigned long uid;      /**< User ID */
        unsigned long magic;    /**< Magic */
        unsigned long iocs;     /**< Ioctl count */
-} drm_client_t;
+};
 
-typedef enum {
+enum drm_stat_type {
        _DRM_STAT_LOCK,
        _DRM_STAT_OPENS,
        _DRM_STAT_CLOSES,
@@ -330,23 +308,23 @@ typedef enum {
        _DRM_STAT_SPECIAL,      /**< Special DMA (e.g., priority or polled) */
        _DRM_STAT_MISSED        /**< Missed DMA opportunity */
            /* Add to the *END* of the list */
-} drm_stat_type_t;
+};
 
 /**
  * DRM_IOCTL_GET_STATS ioctl argument type.
  */
-typedef struct drm_stats {
+struct drm_stats {
        unsigned long count;
        struct {
                unsigned long value;
-               drm_stat_type_t type;
+               enum drm_stat_type type;
        } data[15];
-} drm_stats_t;
+};
 
 /**
  * Hardware locking flags.
  */
-typedef enum drm_lock_flags {
+enum drm_lock_flags {
        _DRM_LOCK_READY = 0x01,      /**< Wait until hardware is ready for DMA 
*/
        _DRM_LOCK_QUIESCENT = 0x02,  /**< Wait until hardware quiescent */
        _DRM_LOCK_FLUSH = 0x04,      /**< Flush this context's DMA queue first 
*/
@@ -356,17 +334,17 @@ typedef enum drm_lock_flags {
           full-screen DGA-like mode. */
        _DRM_HALT_ALL_QUEUES = 0x10, /**< Halt all current and future queues */
        _DRM_HALT_CUR_QUEUES = 0x20  /**< Halt all current queues */
-} drm_lock_flags_t;
+};
 
 /**
  * DRM_IOCTL_LOCK, DRM_IOCTL_UNLOCK and DRM_IOCTL_FINISH ioctl argument type.
  *
  * \sa drmGetLock() and drmUnlock().
  */
-typedef struct drm_lock {
+struct drm_lock {
        int context;
-       drm_lock_flags_t flags;
-} drm_lock_t;
+       enum drm_lock_flags flags;
+};
 
 /**
  * DMA flags
@@ -376,7 +354,7 @@ typedef struct drm_lock {
  *
  * \sa drm_dma.
  */
-typedef enum drm_dma_flags {
+enum drm_dma_flags {
        /* Flags for DMA buffer dispatch */
        _DRM_DMA_BLOCK = 0x01,        /**<
                                       * Block until buffer dispatched.
@@ -395,14 +373,14 @@ typedef enum drm_dma_flags {
        _DRM_DMA_WAIT = 0x10,         /**< Wait for free buffers */
        _DRM_DMA_SMALLER_OK = 0x20,   /**< Smaller-than-requested buffers OK */
        _DRM_DMA_LARGER_OK = 0x40     /**< Larger-than-requested buffers OK */
-} drm_dma_flags_t;
+};
 
 /**
  * DRM_IOCTL_ADD_BUFS and DRM_IOCTL_MARK_BUFS ioctl argument type.
  *
  * \sa drmAddBufs().
  */
-typedef struct drm_buf_desc {
+struct drm_buf_desc {
        int count;               /**< Number of buffers of this size */
        int size;                /**< Size in bytes */
        int low_mark;            /**< Low water mark */
@@ -411,54 +389,55 @@ typedef struct drm_buf_desc {
                _DRM_PAGE_ALIGN = 0x01, /**< Align on page boundaries for DMA */
                _DRM_AGP_BUFFER = 0x02, /**< Buffer is in AGP space */
                _DRM_SG_BUFFER  = 0x04, /**< Scatter/gather memory buffer */
-               _DRM_FB_BUFFER  = 0x08  /**< Buffer is in frame buffer */
+               _DRM_FB_BUFFER  = 0x08, /**< Buffer is in frame buffer */
+               _DRM_PCI_BUFFER_RO = 0x10 /**< Map PCI DMA buffer read-only */
        } flags;
        unsigned long agp_start; /**<
                                  * Start address of where the AGP buffers are
                                  * in the AGP aperture
                                  */
-} drm_buf_desc_t;
+};
 
 /**
  * DRM_IOCTL_INFO_BUFS ioctl argument type.
  */
-typedef struct drm_buf_info {
+struct drm_buf_info {
        int count;                /**< Number of buffers described in list */
-       drm_buf_desc_t __user *list;      /**< List of buffer descriptions */
-} drm_buf_info_t;
+       struct drm_buf_desc __user *list; /**< List of buffer descriptions */
+};
 
 /**
  * DRM_IOCTL_FREE_BUFS ioctl argument type.
  */
-typedef struct drm_buf_free {
+struct drm_buf_free {
        int count;
        int __user *list;
-} drm_buf_free_t;
+};
 
 /**
  * Buffer information
  *
  * \sa drm_buf_map.
  */
-typedef struct drm_buf_pub {
+struct drm_buf_pub {
        int idx;                       /**< Index into the master buffer list */
        int total;                     /**< Buffer size */
        int used;                      /**< Amount of buffer in use (for DMA) */
        void __user *address;          /**< Address of buffer */
-} drm_buf_pub_t;
+};
 
 /**
  * DRM_IOCTL_MAP_BUFS ioctl argument type.
  */
-typedef struct drm_buf_map {
+struct drm_buf_map {
        int count;              /**< Length of the buffer list */
 #if defined(__cplusplus)
        void __user *c_virtual;
 #else
        void __user *virtual;           /**< Mmap'd area in user-virtual */
 #endif
-       drm_buf_pub_t __user *list;     /**< Buffer information */
-} drm_buf_map_t;
+       struct drm_buf_pub __user *list;        /**< Buffer information */
+};
 
 /**
  * DRM_IOCTL_DMA ioctl argument type.
@@ -467,84 +446,103 @@ typedef struct drm_buf_map {
  *
  * \sa drmDMA().
  */
-typedef struct drm_dma {
+struct drm_dma {
        int context;                      /**< Context handle */
        int send_count;                   /**< Number of buffers to send */
        int __user *send_indices;         /**< List of handles to buffers */
        int __user *send_sizes;           /**< Lengths of data to send */
-       drm_dma_flags_t flags;            /**< Flags */
+       enum drm_dma_flags flags;         /**< Flags */
        int request_count;                /**< Number of buffers requested */
        int request_size;                 /**< Desired size for buffers */
        int __user *request_indices;     /**< Buffer information */
        int __user *request_sizes;
        int granted_count;                /**< Number of buffers granted */
-} drm_dma_t;
+};
 
-typedef enum {
+enum drm_ctx_flags {
        _DRM_CONTEXT_PRESERVED = 0x01,
        _DRM_CONTEXT_2DONLY = 0x02
-} drm_ctx_flags_t;
+};
 
 /**
  * DRM_IOCTL_ADD_CTX ioctl argument type.
  *
  * \sa drmCreateContext() and drmDestroyContext().
  */
-typedef struct drm_ctx {
+struct drm_ctx {
        drm_context_t handle;
-       drm_ctx_flags_t flags;
-} drm_ctx_t;
+       enum drm_ctx_flags flags;
+};
 
 /**
  * DRM_IOCTL_RES_CTX ioctl argument type.
  */
-typedef struct drm_ctx_res {
+struct drm_ctx_res {
        int count;
-       drm_ctx_t __user *contexts;
-} drm_ctx_res_t;
+       struct drm_ctx __user *contexts;
+};
 
 /**
  * DRM_IOCTL_ADD_DRAW and DRM_IOCTL_RM_DRAW ioctl argument type.
  */
-typedef struct drm_draw {
+struct drm_draw {
        drm_drawable_t handle;
-} drm_draw_t;
+};
+
+/**
+ * DRM_IOCTL_UPDATE_DRAW ioctl argument type.
+ */
+typedef enum {
+       DRM_DRAWABLE_CLIPRECTS,
+} drm_drawable_info_type_t;
+
+struct drm_update_draw {
+       drm_drawable_t handle;
+       unsigned int type;
+       unsigned int num;
+       unsigned long long data;
+};
 
 /**
  * DRM_IOCTL_GET_MAGIC and DRM_IOCTL_AUTH_MAGIC ioctl argument type.
  */
-typedef struct drm_auth {
+struct drm_auth {
        drm_magic_t magic;
-} drm_auth_t;
+};
 
 /**
  * DRM_IOCTL_IRQ_BUSID ioctl argument type.
  *
  * \sa drmGetInterruptFromBusID().
  */
-typedef struct drm_irq_busid {
+struct drm_irq_busid {
        int irq;        /**< IRQ number */
        int busnum;     /**< bus number */
        int devnum;     /**< device number */
        int funcnum;    /**< function number */
-} drm_irq_busid_t;
+};
 
-typedef enum {
+enum drm_vblank_seq_type {
        _DRM_VBLANK_ABSOLUTE = 0x0,     /**< Wait for specific vblank sequence 
number */
        _DRM_VBLANK_RELATIVE = 0x1,     /**< Wait for given number of vblanks */
+       _DRM_VBLANK_FLIP = 0x8000000,   /**< Scheduled buffer swap should flip 
*/
+       _DRM_VBLANK_NEXTONMISS = 0x10000000,    /**< If missed, wait for next 
vblank */
+       _DRM_VBLANK_SECONDARY = 0x20000000,     /**< Secondary display 
controller */
        _DRM_VBLANK_SIGNAL = 0x40000000 /**< Send signal instead of blocking */
-} drm_vblank_seq_type_t;
+};
 
-#define _DRM_VBLANK_FLAGS_MASK _DRM_VBLANK_SIGNAL
+#define _DRM_VBLANK_TYPES_MASK (_DRM_VBLANK_ABSOLUTE | _DRM_VBLANK_RELATIVE)
+#define _DRM_VBLANK_FLAGS_MASK (_DRM_VBLANK_SIGNAL | _DRM_VBLANK_SECONDARY | \
+                               _DRM_VBLANK_NEXTONMISS)
 
 struct drm_wait_vblank_request {
-       drm_vblank_seq_type_t type;
+       enum drm_vblank_seq_type type;
        unsigned int sequence;
        unsigned long signal;
 };
 
 struct drm_wait_vblank_reply {
-       drm_vblank_seq_type_t type;
+       enum drm_vblank_seq_type type;
        unsigned int sequence;
        long tval_sec;
        long tval_usec;
@@ -555,41 +553,55 @@ struct drm_wait_vblank_reply {
  *
  * \sa drmWaitVBlank().
  */
-typedef union drm_wait_vblank {
+union drm_wait_vblank {
        struct drm_wait_vblank_request request;
        struct drm_wait_vblank_reply reply;
-} drm_wait_vblank_t;
+};
+
+
+#define _DRM_PRE_MODESET 1
+#define _DRM_POST_MODESET 2
+
+/**
+ * DRM_IOCTL_MODESET_CTL ioctl argument type
+ *
+ * \sa drmModesetCtl().
+ */
+struct drm_modeset_ctl {
+       uint32_t crtc;
+       uint32_t cmd;
+};
 
 /**
  * DRM_IOCTL_AGP_ENABLE ioctl argument type.
  *
  * \sa drmAgpEnable().
  */
-typedef struct drm_agp_mode {
+struct drm_agp_mode {
        unsigned long mode;     /**< AGP mode */
-} drm_agp_mode_t;
+};
 
 /**
  * DRM_IOCTL_AGP_ALLOC and DRM_IOCTL_AGP_FREE ioctls argument type.
  *
  * \sa drmAgpAlloc() and drmAgpFree().
  */
-typedef struct drm_agp_buffer {
+struct drm_agp_buffer {
        unsigned long size;     /**< In bytes -- will round to page boundary */
        unsigned long handle;   /**< Used for binding / unbinding */
        unsigned long type;     /**< Type of memory to allocate */
        unsigned long physical; /**< Physical used by i810 */
-} drm_agp_buffer_t;
+};
 
 /**
  * DRM_IOCTL_AGP_BIND and DRM_IOCTL_AGP_UNBIND ioctls argument type.
  *
  * \sa drmAgpBind() and drmAgpUnbind().
  */
-typedef struct drm_agp_binding {
+struct drm_agp_binding {
        unsigned long handle;   /**< From drm_agp_buffer */
        unsigned long offset;   /**< In bytes -- will round to page boundary */
-} drm_agp_binding_t;
+};
 
 /**
  * DRM_IOCTL_AGP_INFO ioctl argument type.
@@ -598,7 +610,7 @@ typedef struct drm_agp_binding {
  * drmAgpBase(), drmAgpSize(), drmAgpMemoryUsed(), drmAgpMemoryAvail(),
  * drmAgpVendorId() and drmAgpDeviceId().
  */
-typedef struct drm_agp_info {
+struct drm_agp_info {
        int agp_version_major;
        int agp_version_minor;
        unsigned long mode;
@@ -612,25 +624,368 @@ typedef struct drm_agp_info {
        unsigned short id_vendor;
        unsigned short id_device;
        /*...@} */
-} drm_agp_info_t;
+};
 
 /**
  * DRM_IOCTL_SG_ALLOC ioctl argument type.
  */
-typedef struct drm_scatter_gather {
+struct drm_scatter_gather {
        unsigned long size;     /**< In bytes -- will round to page boundary */
        unsigned long handle;   /**< Used for mapping / unmapping */
-} drm_scatter_gather_t;
+};
 
 /**
  * DRM_IOCTL_SET_VERSION ioctl argument type.
  */
-typedef struct drm_set_version {
+struct drm_set_version {
        int drm_di_major;
        int drm_di_minor;
        int drm_dd_major;
        int drm_dd_minor;
-} drm_set_version_t;
+};
+
+
+#define DRM_FENCE_FLAG_EMIT                0x00000001
+#define DRM_FENCE_FLAG_SHAREABLE           0x00000002
+/**
+ * On hardware with no interrupt events for operation completion,
+ * indicates that the kernel should sleep while waiting for any blocking
+ * operation to complete rather than spinning.
+ *
+ * Has no effect otherwise.
+ */
+#define DRM_FENCE_FLAG_WAIT_LAZY           0x00000004
+#define DRM_FENCE_FLAG_NO_USER             0x00000010
+
+/* Reserved for driver use */
+#define DRM_FENCE_MASK_DRIVER              0xFF000000
+
+#define DRM_FENCE_TYPE_EXE                 0x00000001
+
+struct drm_fence_arg {
+       unsigned int handle;
+       unsigned int fence_class;
+       unsigned int type;
+       unsigned int flags;
+       unsigned int signaled;
+       unsigned int error;
+       unsigned int sequence;
+       unsigned int pad64;
+       uint64_t expand_pad[2]; /*Future expansion */
+};
+
+/* Buffer permissions, referring to how the GPU uses the buffers.
+ * these translate to fence types used for the buffers.
+ * Typically a texture buffer is read, A destination buffer is write and
+ *  a command (batch-) buffer is exe. Can be or-ed together.
+ */
+
+#define DRM_BO_FLAG_READ        (1ULL << 0)
+#define DRM_BO_FLAG_WRITE       (1ULL << 1)
+#define DRM_BO_FLAG_EXE         (1ULL << 2)
+
+/*
+ * All of the bits related to access mode
+ */
+#define DRM_BO_MASK_ACCESS     (DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE | 
DRM_BO_FLAG_EXE)
+/*
+ * Status flags. Can be read to determine the actual state of a buffer.
+ * Can also be set in the buffer mask before validation.
+ */
+
+/*
+ * Mask: Never evict this buffer. Not even with force. This type of buffer is 
only
+ * available to root and must be manually removed before buffer manager 
shutdown
+ * or lock.
+ * Flags: Acknowledge
+ */
+#define DRM_BO_FLAG_NO_EVICT    (1ULL << 4)
+
+/*
+ * Mask: Require that the buffer is placed in mappable memory when validated.
+ *       If not set the buffer may or may not be in mappable memory when 
validated.
+ * Flags: If set, the buffer is in mappable memory.
+ */
+#define DRM_BO_FLAG_MAPPABLE    (1ULL << 5)
+
+/* Mask: The buffer should be shareable with other processes.
+ * Flags: The buffer is shareable with other processes.
+ */
+#define DRM_BO_FLAG_SHAREABLE   (1ULL << 6)
+
+/* Mask: If set, place the buffer in cache-coherent memory if available.
+ *       If clear, never place the buffer in cache coherent memory if 
validated.
+ * Flags: The buffer is currently in cache-coherent memory.
+ */
+#define DRM_BO_FLAG_CACHED      (1ULL << 7)
+
+/* Mask: Make sure that every time this buffer is validated,
+ *       it ends up on the same location provided that the memory mask is the 
same.
+ *       The buffer will also not be evicted when claiming space for
+ *       other buffers. Basically a pinned buffer but it may be thrown out as
+ *       part of buffer manager shutdown or locking.
+ * Flags: Acknowledge.
+ */
+#define DRM_BO_FLAG_NO_MOVE     (1ULL << 8)
+
+/* Mask: Make sure the buffer is in cached memory when mapped.  In conjunction
+ * with DRM_BO_FLAG_CACHED it also allows the buffer to be bound into the GART
+ * with unsnooped PTEs instead of snooped, by using chipset-specific cache
+ * flushing at bind time.  A better name might be DRM_BO_FLAG_TT_UNSNOOPED,
+ * as the eviction to local memory (TTM unbind) on map is just a side effect
+ * to prevent aggressive cache prefetch from the GPU disturbing the cache
+ * management that the DRM is doing.
+ *

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to