The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/drm/mga_drv.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* mga_drv.c -- Matrox G200/G400 driver -*- linux-c -*-
    2  * Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com
    3  */
    4 /*-
    5  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
    6  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
    7  * All Rights Reserved.
    8  *
    9  * Permission is hereby granted, free of charge, to any person obtaining a
   10  * copy of this software and associated documentation files (the "Software"),
   11  * to deal in the Software without restriction, including without limitation
   12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
   13  * and/or sell copies of the Software, and to permit persons to whom the
   14  * Software is furnished to do so, subject to the following conditions:
   15  *
   16  * The above copyright notice and this permission notice (including the next
   17  * paragraph) shall be included in all copies or substantial portions of the
   18  * Software.
   19  *
   20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   21  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   22  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
   23  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
   24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
   25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
   26  * OTHER DEALINGS IN THE SOFTWARE.
   27  *
   28  * Authors:
   29  *    Rickard E. (Rik) Faith <faith@valinux.com>
   30  *    Gareth Hughes <gareth@valinux.com>
   31  *
   32  */
   33 
   34 #include <sys/cdefs.h>
   35 __FBSDID("$FreeBSD: releng/6.4/sys/dev/drm/mga_drv.c 158686 2006-05-17 07:40:12Z anholt $");
   36 
   37 #include "dev/drm/drmP.h"
   38 #include "dev/drm/drm.h"
   39 #include "dev/drm/mga_drm.h"
   40 #include "dev/drm/mga_drv.h"
   41 #include "dev/drm/drm_pciids.h"
   42 
   43 /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
   44 static drm_pci_id_list_t mga_pciidlist[] = {
   45         mga_PCI_IDS
   46 };
   47 
   48 /**
   49  * Determine if the device really is AGP or not.
   50  *
   51  * In addition to the usual tests performed by \c drm_device_is_agp, this
   52  * function detects PCI G450 cards that appear to the system exactly like
   53  * AGP G450 cards.
   54  *
   55  * \param dev   The device to be tested.
   56  *
   57  * \returns
   58  * If the device is a PCI G450, zero is returned.  Otherwise non-zero is
   59  * returned.
   60  *
   61  * \bug
   62  * This function needs to be filled in!  The implementation in
   63  * linux-core/mga_drv.c shows what needs to be done.
   64  */
   65 static int mga_driver_device_is_agp(drm_device_t * dev)
   66 {
   67         device_t bus;
   68 
   69         /* There are PCI versions of the G450.  These cards have the
   70          * same PCI ID as the AGP G450, but have an additional PCI-to-PCI
   71          * bridge chip.  We detect these cards, which are not currently
   72          * supported by this driver, by looking at the device ID of the
   73          * bus the "card" is on.  If vendor is 0x3388 (Hint Corp) and the
   74          * device is 0x0021 (HB6 Universal PCI-PCI bridge), we reject the
   75          * device.
   76          */
   77 #if __FreeBSD_version >= 700010
   78         bus = device_get_parent(device_get_parent(dev->device));
   79 #else
   80         bus = device_get_parent(dev->device);
   81 #endif
   82         if (pci_get_device(dev->device) == 0x0525 &&
   83             pci_get_vendor(bus) == 0x3388 &&
   84             pci_get_device(bus) == 0x0021)
   85                 return DRM_IS_NOT_AGP;
   86         else
   87                 return DRM_MIGHT_BE_AGP;
   88 }
   89 
   90 static void mga_configure(drm_device_t *dev)
   91 {
   92         dev->driver.buf_priv_size       = sizeof(drm_mga_buf_priv_t);
   93         dev->driver.load                = mga_driver_load;
   94         dev->driver.unload              = mga_driver_unload;
   95         dev->driver.lastclose           = mga_driver_lastclose;
   96         dev->driver.vblank_wait         = mga_driver_vblank_wait;
   97         dev->driver.irq_preinstall      = mga_driver_irq_preinstall;
   98         dev->driver.irq_postinstall     = mga_driver_irq_postinstall;
   99         dev->driver.irq_uninstall       = mga_driver_irq_uninstall;
  100         dev->driver.irq_handler         = mga_driver_irq_handler;
  101         dev->driver.dma_ioctl           = mga_dma_buffers;
  102         dev->driver.dma_quiescent       = mga_driver_dma_quiescent;
  103         dev->driver.device_is_agp       = mga_driver_device_is_agp;
  104 
  105         dev->driver.ioctls              = mga_ioctls;
  106         dev->driver.max_ioctl           = mga_max_ioctl;
  107 
  108         dev->driver.name                = DRIVER_NAME;
  109         dev->driver.desc                = DRIVER_DESC;
  110         dev->driver.date                = DRIVER_DATE;
  111         dev->driver.major               = DRIVER_MAJOR;
  112         dev->driver.minor               = DRIVER_MINOR;
  113         dev->driver.patchlevel          = DRIVER_PATCHLEVEL;
  114 
  115         dev->driver.use_agp             = 1;
  116         dev->driver.require_agp         = 1;
  117         dev->driver.use_mtrr            = 1;
  118         dev->driver.use_dma             = 1;
  119         dev->driver.use_irq             = 1;
  120         dev->driver.use_vbl_irq         = 1;
  121 }
  122 
  123 
  124 
  125 #ifdef __FreeBSD__
  126 static int
  127 mga_probe(device_t dev)
  128 {
  129         return drm_probe(dev, mga_pciidlist);
  130 }
  131 
  132 static int
  133 mga_attach(device_t nbdev)
  134 {
  135         drm_device_t *dev = device_get_softc(nbdev);
  136 
  137         bzero(dev, sizeof(drm_device_t));
  138         mga_configure(dev);
  139         return drm_attach(nbdev, mga_pciidlist);
  140 }
  141 
  142 static device_method_t mga_methods[] = {
  143         /* Device interface */
  144         DEVMETHOD(device_probe,         mga_probe),
  145         DEVMETHOD(device_attach,        mga_attach),
  146         DEVMETHOD(device_detach,        drm_detach),
  147 
  148         { 0, 0 }
  149 };
  150 
  151 static driver_t mga_driver = {
  152         "drm",
  153         mga_methods,
  154         sizeof(drm_device_t)
  155 };
  156 
  157 extern devclass_t drm_devclass;
  158 #if __FreeBSD_version >= 700010
  159 DRIVER_MODULE(mga, vgapci, mga_driver, drm_devclass, 0, 0);
  160 #else
  161 DRIVER_MODULE(mga, pci, mga_driver, drm_devclass, 0, 0);
  162 #endif
  163 MODULE_DEPEND(mga, drm, 1, 1, 1);
  164 
  165 #elif defined(__NetBSD__) || defined(__OpenBSD__)
  166 #ifdef _LKM
  167 CFDRIVER_DECL(mga, DV_TTY, NULL);
  168 #else
  169 CFATTACH_DECL(mga, sizeof(drm_device_t), drm_probe, drm_attach, drm_detach,
  170     drm_activate);
  171 #endif
  172 #endif

Cache object: 2cc9a984b172e460ff3ce187e3f6f852


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.