sis_drv.c revision 183604
1/* sis.c -- sis driver -*- linux-c -*- 2 */ 3/*- 4 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. 5 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. 6 * All Rights Reserved. 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining a 9 * copy of this software and associated documentation files (the "Software"), 10 * to deal in the Software without restriction, including without limitation 11 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 * and/or sell copies of the Software, and to permit persons to whom the 13 * Software is furnished to do so, subject to the following conditions: 14 * 15 * The above copyright notice and this permission notice (including the next 16 * paragraph) shall be included in all copies or substantial portions of the 17 * Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22 * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 23 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 24 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 * DEALINGS IN THE SOFTWARE. 26 * 27 */ 28 29#include <sys/cdefs.h> 30__FBSDID("$FreeBSD: head/sys/dev/drm/sis_drv.c 183604 2008-10-04 14:48:40Z rnoland $"); 31 32#include "dev/drm/drmP.h" 33#include "dev/drm/sis_drm.h" 34#include "dev/drm/sis_drv.h" 35#include "dev/drm/drm_pciids.h" 36 37/* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ 38static drm_pci_id_list_t sis_pciidlist[] = { 39 sis_PCI_IDS 40}; 41 42static void sis_configure(struct drm_device *dev) 43{ 44 dev->driver->driver_features = 45 DRIVER_USE_AGP | DRIVER_USE_MTRR; 46 47 dev->driver->buf_priv_size = 1; /* No dev_priv */ 48 dev->driver->context_ctor = sis_init_context; 49 dev->driver->context_dtor = sis_final_context; 50 51 dev->driver->ioctls = sis_ioctls; 52 dev->driver->max_ioctl = sis_max_ioctl; 53 54 dev->driver->name = DRIVER_NAME; 55 dev->driver->desc = DRIVER_DESC; 56 dev->driver->date = DRIVER_DATE; 57 dev->driver->major = DRIVER_MAJOR; 58 dev->driver->minor = DRIVER_MINOR; 59 dev->driver->patchlevel = DRIVER_PATCHLEVEL; 60} 61 62static int 63sis_probe(device_t dev) 64{ 65 return drm_probe(dev, sis_pciidlist); 66} 67 68static int 69sis_attach(device_t nbdev) 70{ 71 struct drm_device *dev = device_get_softc(nbdev); 72 73 bzero(dev, sizeof(struct drm_device)); 74 75 dev->driver = malloc(sizeof(struct drm_driver_info), M_DRM, 76 M_WAITOK | M_ZERO); 77 78 sis_configure(dev); 79 80 return drm_attach(nbdev, sis_pciidlist); 81} 82 83static int 84sis_detach(device_t nbdev) 85{ 86 struct drm_device *dev = device_get_softc(nbdev); 87 int ret; 88 89 ret = drm_detach(nbdev); 90 91 free(dev->driver, M_DRM); 92 93 return ret; 94} 95 96static device_method_t sis_methods[] = { 97 /* Device interface */ 98 DEVMETHOD(device_probe, sis_probe), 99 DEVMETHOD(device_attach, sis_attach), 100 DEVMETHOD(device_detach, sis_detach), 101 102 { 0, 0 } 103}; 104 105static driver_t sis_driver = { 106 "drm", 107 sis_methods, 108 sizeof(struct drm_device) 109}; 110 111extern devclass_t drm_devclass; 112#if __FreeBSD_version >= 700010 113DRIVER_MODULE(sisdrm, vgapci, sis_driver, drm_devclass, 0, 0); 114#else 115DRIVER_MODULE(sisdrm, pci, sis_driver, drm_devclass, 0, 0); 116#endif 117MODULE_DEPEND(sisdrm, drm, 1, 1, 1); 118