18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. 38c2ecf20Sopenharmony_ci * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 68c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 78c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation 88c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sub license, 98c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 108c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice (including the 138c2ecf20Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions 148c2ecf20Sopenharmony_ci * of the Software. 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 178c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 188c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 198c2ecf20Sopenharmony_ci * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 208c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 218c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 228c2ecf20Sopenharmony_ci * DEALINGS IN THE SOFTWARE. 238c2ecf20Sopenharmony_ci */ 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#include <linux/module.h> 268c2ecf20Sopenharmony_ci#include <linux/pci.h> 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#include <drm/drm_drv.h> 298c2ecf20Sopenharmony_ci#include <drm/drm_file.h> 308c2ecf20Sopenharmony_ci#include <drm/drm_pciids.h> 318c2ecf20Sopenharmony_ci#include <drm/via_drm.h> 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#include "via_drv.h" 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_cistatic int via_driver_open(struct drm_device *dev, struct drm_file *file) 378c2ecf20Sopenharmony_ci{ 388c2ecf20Sopenharmony_ci struct via_file_private *file_priv; 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci DRM_DEBUG_DRIVER("\n"); 418c2ecf20Sopenharmony_ci file_priv = kmalloc(sizeof(*file_priv), GFP_KERNEL); 428c2ecf20Sopenharmony_ci if (!file_priv) 438c2ecf20Sopenharmony_ci return -ENOMEM; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci file->driver_priv = file_priv; 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci INIT_LIST_HEAD(&file_priv->obj_list); 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci return 0; 508c2ecf20Sopenharmony_ci} 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_cistatic void via_driver_postclose(struct drm_device *dev, struct drm_file *file) 538c2ecf20Sopenharmony_ci{ 548c2ecf20Sopenharmony_ci struct via_file_private *file_priv = file->driver_priv; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci kfree(file_priv); 578c2ecf20Sopenharmony_ci} 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_cistatic struct pci_device_id pciidlist[] = { 608c2ecf20Sopenharmony_ci viadrv_PCI_IDS 618c2ecf20Sopenharmony_ci}; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_cistatic const struct file_operations via_driver_fops = { 648c2ecf20Sopenharmony_ci .owner = THIS_MODULE, 658c2ecf20Sopenharmony_ci .open = drm_open, 668c2ecf20Sopenharmony_ci .release = drm_release, 678c2ecf20Sopenharmony_ci .unlocked_ioctl = drm_ioctl, 688c2ecf20Sopenharmony_ci .mmap = drm_legacy_mmap, 698c2ecf20Sopenharmony_ci .poll = drm_poll, 708c2ecf20Sopenharmony_ci .compat_ioctl = drm_compat_ioctl, 718c2ecf20Sopenharmony_ci .llseek = noop_llseek, 728c2ecf20Sopenharmony_ci}; 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_cistatic struct drm_driver driver = { 758c2ecf20Sopenharmony_ci .driver_features = 768c2ecf20Sopenharmony_ci DRIVER_USE_AGP | DRIVER_HAVE_IRQ | DRIVER_LEGACY, 778c2ecf20Sopenharmony_ci .load = via_driver_load, 788c2ecf20Sopenharmony_ci .unload = via_driver_unload, 798c2ecf20Sopenharmony_ci .open = via_driver_open, 808c2ecf20Sopenharmony_ci .preclose = via_reclaim_buffers_locked, 818c2ecf20Sopenharmony_ci .postclose = via_driver_postclose, 828c2ecf20Sopenharmony_ci .context_dtor = via_final_context, 838c2ecf20Sopenharmony_ci .get_vblank_counter = via_get_vblank_counter, 848c2ecf20Sopenharmony_ci .enable_vblank = via_enable_vblank, 858c2ecf20Sopenharmony_ci .disable_vblank = via_disable_vblank, 868c2ecf20Sopenharmony_ci .irq_preinstall = via_driver_irq_preinstall, 878c2ecf20Sopenharmony_ci .irq_postinstall = via_driver_irq_postinstall, 888c2ecf20Sopenharmony_ci .irq_uninstall = via_driver_irq_uninstall, 898c2ecf20Sopenharmony_ci .irq_handler = via_driver_irq_handler, 908c2ecf20Sopenharmony_ci .dma_quiescent = via_driver_dma_quiescent, 918c2ecf20Sopenharmony_ci .lastclose = via_lastclose, 928c2ecf20Sopenharmony_ci .ioctls = via_ioctls, 938c2ecf20Sopenharmony_ci .fops = &via_driver_fops, 948c2ecf20Sopenharmony_ci .name = DRIVER_NAME, 958c2ecf20Sopenharmony_ci .desc = DRIVER_DESC, 968c2ecf20Sopenharmony_ci .date = DRIVER_DATE, 978c2ecf20Sopenharmony_ci .major = DRIVER_MAJOR, 988c2ecf20Sopenharmony_ci .minor = DRIVER_MINOR, 998c2ecf20Sopenharmony_ci .patchlevel = DRIVER_PATCHLEVEL, 1008c2ecf20Sopenharmony_ci}; 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_cistatic struct pci_driver via_pci_driver = { 1038c2ecf20Sopenharmony_ci .name = DRIVER_NAME, 1048c2ecf20Sopenharmony_ci .id_table = pciidlist, 1058c2ecf20Sopenharmony_ci}; 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_cistatic int __init via_init(void) 1088c2ecf20Sopenharmony_ci{ 1098c2ecf20Sopenharmony_ci driver.num_ioctls = via_max_ioctl; 1108c2ecf20Sopenharmony_ci via_init_command_verifier(); 1118c2ecf20Sopenharmony_ci return drm_legacy_pci_init(&driver, &via_pci_driver); 1128c2ecf20Sopenharmony_ci} 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_cistatic void __exit via_exit(void) 1158c2ecf20Sopenharmony_ci{ 1168c2ecf20Sopenharmony_ci drm_legacy_pci_exit(&driver, &via_pci_driver); 1178c2ecf20Sopenharmony_ci} 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_cimodule_init(via_init); 1208c2ecf20Sopenharmony_cimodule_exit(via_exit); 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ciMODULE_AUTHOR(DRIVER_AUTHOR); 1238c2ecf20Sopenharmony_ciMODULE_DESCRIPTION(DRIVER_DESC); 1248c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL and additional rights"); 125