Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
0003  * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
0004  *
0005  * Permission is hereby granted, free of charge, to any person obtaining a
0006  * copy of this software and associated documentation files (the "Software"),
0007  * to deal in the Software without restriction, including without limitation
0008  * the rights to use, copy, modify, merge, publish, distribute, sub license,
0009  * and/or sell copies of the Software, and to permit persons to whom the
0010  * Software is furnished to do so, subject to the following conditions:
0011  *
0012  * The above copyright notice and this permission notice (including the
0013  * next paragraph) shall be included in all copies or substantial portions
0014  * of the Software.
0015  *
0016  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0017  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0018  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
0019  * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
0020  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0021  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
0022  * DEALINGS IN THE SOFTWARE.
0023  */
0024 
0025 #include <linux/module.h>
0026 #include <linux/pci.h>
0027 
0028 #include <drm/drm_drv.h>
0029 #include <drm/drm_file.h>
0030 #include <drm/drm_pciids.h>
0031 #include <drm/via_drm.h>
0032 
0033 #include "via_drv.h"
0034 
0035 
0036 static int via_driver_open(struct drm_device *dev, struct drm_file *file)
0037 {
0038     struct via_file_private *file_priv;
0039 
0040     DRM_DEBUG_DRIVER("\n");
0041     file_priv = kmalloc(sizeof(*file_priv), GFP_KERNEL);
0042     if (!file_priv)
0043         return -ENOMEM;
0044 
0045     file->driver_priv = file_priv;
0046 
0047     INIT_LIST_HEAD(&file_priv->obj_list);
0048 
0049     return 0;
0050 }
0051 
0052 static void via_driver_postclose(struct drm_device *dev, struct drm_file *file)
0053 {
0054     struct via_file_private *file_priv = file->driver_priv;
0055 
0056     kfree(file_priv);
0057 }
0058 
0059 static struct pci_device_id pciidlist[] = {
0060     viadrv_PCI_IDS
0061 };
0062 
0063 static const struct file_operations via_driver_fops = {
0064     .owner = THIS_MODULE,
0065     .open = drm_open,
0066     .release = drm_release,
0067     .unlocked_ioctl = drm_ioctl,
0068     .mmap = drm_legacy_mmap,
0069     .poll = drm_poll,
0070     .compat_ioctl = drm_compat_ioctl,
0071     .llseek = noop_llseek,
0072 };
0073 
0074 static struct drm_driver driver = {
0075     .driver_features =
0076         DRIVER_USE_AGP | DRIVER_HAVE_IRQ | DRIVER_LEGACY,
0077     .load = via_driver_load,
0078     .unload = via_driver_unload,
0079     .open = via_driver_open,
0080     .preclose = via_reclaim_buffers_locked,
0081     .postclose = via_driver_postclose,
0082     .context_dtor = via_final_context,
0083     .get_vblank_counter = via_get_vblank_counter,
0084     .enable_vblank = via_enable_vblank,
0085     .disable_vblank = via_disable_vblank,
0086     .irq_preinstall = via_driver_irq_preinstall,
0087     .irq_postinstall = via_driver_irq_postinstall,
0088     .irq_uninstall = via_driver_irq_uninstall,
0089     .irq_handler = via_driver_irq_handler,
0090     .dma_quiescent = via_driver_dma_quiescent,
0091     .lastclose = via_lastclose,
0092     .ioctls = via_ioctls,
0093     .fops = &via_driver_fops,
0094     .name = DRIVER_NAME,
0095     .desc = DRIVER_DESC,
0096     .date = DRIVER_DATE,
0097     .major = DRIVER_MAJOR,
0098     .minor = DRIVER_MINOR,
0099     .patchlevel = DRIVER_PATCHLEVEL,
0100 };
0101 
0102 static struct pci_driver via_pci_driver = {
0103     .name = DRIVER_NAME,
0104     .id_table = pciidlist,
0105 };
0106 
0107 static int __init via_init(void)
0108 {
0109     driver.num_ioctls = via_max_ioctl;
0110     via_init_command_verifier();
0111     return drm_legacy_pci_init(&driver, &via_pci_driver);
0112 }
0113 
0114 static void __exit via_exit(void)
0115 {
0116     drm_legacy_pci_exit(&driver, &via_pci_driver);
0117 }
0118 
0119 module_init(via_init);
0120 module_exit(via_exit);
0121 
0122 MODULE_AUTHOR(DRIVER_AUTHOR);
0123 MODULE_DESCRIPTION(DRIVER_DESC);
0124 MODULE_LICENSE("GPL and additional rights");