/* mga_drv.c -- Matrox G200/G400 driver -*- linux-c -*-1* Created: Mon Dec 13 01:56:22 1999 by [email protected]2*3* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.4* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.5* All Rights Reserved.6*7* Permission is hereby granted, free of charge, to any person obtaining a8* copy of this software and associated documentation files (the "Software"),9* to deal in the Software without restriction, including without limitation10* the rights to use, copy, modify, merge, publish, distribute, sublicense,11* and/or sell copies of the Software, and to permit persons to whom the12* Software is furnished to do so, subject to the following conditions:13*14* The above copyright notice and this permission notice (including the next15* paragraph) shall be included in all copies or substantial portions of the16* Software.17*18* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR19* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,20* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL21* VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR22* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,23* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR24* OTHER DEALINGS IN THE SOFTWARE.25*26* Authors:27* Rickard E. (Rik) Faith <[email protected]>28* Gareth Hughes <[email protected]>29*/3031#include "drmP.h"32#include "drm.h"33#include "mga_drm.h"34#include "mga_drv.h"3536#include "drm_pciids.h"3738static int mga_driver_device_is_agp(struct drm_device *dev);3940static struct pci_device_id pciidlist[] = {41mga_PCI_IDS42};4344static struct drm_driver driver = {45.driver_features =46DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA |47DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,48.dev_priv_size = sizeof(drm_mga_buf_priv_t),49.load = mga_driver_load,50.unload = mga_driver_unload,51.lastclose = mga_driver_lastclose,52.dma_quiescent = mga_driver_dma_quiescent,53.device_is_agp = mga_driver_device_is_agp,54.get_vblank_counter = mga_get_vblank_counter,55.enable_vblank = mga_enable_vblank,56.disable_vblank = mga_disable_vblank,57.irq_preinstall = mga_driver_irq_preinstall,58.irq_postinstall = mga_driver_irq_postinstall,59.irq_uninstall = mga_driver_irq_uninstall,60.irq_handler = mga_driver_irq_handler,61.reclaim_buffers = drm_core_reclaim_buffers,62.ioctls = mga_ioctls,63.dma_ioctl = mga_dma_buffers,64.fops = {65.owner = THIS_MODULE,66.open = drm_open,67.release = drm_release,68.unlocked_ioctl = drm_ioctl,69.mmap = drm_mmap,70.poll = drm_poll,71.fasync = drm_fasync,72#ifdef CONFIG_COMPAT73.compat_ioctl = mga_compat_ioctl,74#endif75.llseek = noop_llseek,76},7778.name = DRIVER_NAME,79.desc = DRIVER_DESC,80.date = DRIVER_DATE,81.major = DRIVER_MAJOR,82.minor = DRIVER_MINOR,83.patchlevel = DRIVER_PATCHLEVEL,84};8586static struct pci_driver mga_pci_driver = {87.name = DRIVER_NAME,88.id_table = pciidlist,89};9091static int __init mga_init(void)92{93driver.num_ioctls = mga_max_ioctl;94return drm_pci_init(&driver, &mga_pci_driver);95}9697static void __exit mga_exit(void)98{99drm_pci_exit(&driver, &mga_pci_driver);100}101102module_init(mga_init);103module_exit(mga_exit);104105MODULE_AUTHOR(DRIVER_AUTHOR);106MODULE_DESCRIPTION(DRIVER_DESC);107MODULE_LICENSE("GPL and additional rights");108109/**110* Determine if the device really is AGP or not.111*112* In addition to the usual tests performed by \c drm_device_is_agp, this113* function detects PCI G450 cards that appear to the system exactly like114* AGP G450 cards.115*116* \param dev The device to be tested.117*118* \returns119* If the device is a PCI G450, zero is returned. Otherwise 2 is returned.120*/121static int mga_driver_device_is_agp(struct drm_device *dev)122{123const struct pci_dev *const pdev = dev->pdev;124125/* There are PCI versions of the G450. These cards have the126* same PCI ID as the AGP G450, but have an additional PCI-to-PCI127* bridge chip. We detect these cards, which are not currently128* supported by this driver, by looking at the device ID of the129* bus the "card" is on. If vendor is 0x3388 (Hint Corp) and the130* device is 0x0021 (HB6 Universal PCI-PCI bridge), we reject the131* device.132*/133134if ((pdev->device == 0x0525) && pdev->bus->self135&& (pdev->bus->self->vendor == 0x3388)136&& (pdev->bus->self->device == 0x0021)) {137return 0;138}139140return 2;141}142143144