xref: /netbsd/sys/external/bsd/drm2/dist/drm/tdfx/tdfx_drv.c (revision 677dec6e)
1*677dec6eSriastradh /*	$NetBSD: tdfx_drv.c,v 1.4 2021/12/18 23:45:44 riastradh Exp $	*/
2d350ecf5Sriastradh 
356053ce7Sriastradh /* tdfx_drv.c -- tdfx driver -*- linux-c -*-
456053ce7Sriastradh  * Created: Thu Oct  7 10:38:32 1999 by faith@precisioninsight.com
556053ce7Sriastradh  *
656053ce7Sriastradh  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
756053ce7Sriastradh  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
856053ce7Sriastradh  * All Rights Reserved.
956053ce7Sriastradh  *
1056053ce7Sriastradh  * Permission is hereby granted, free of charge, to any person obtaining a
1156053ce7Sriastradh  * copy of this software and associated documentation files (the "Software"),
1256053ce7Sriastradh  * to deal in the Software without restriction, including without limitation
1356053ce7Sriastradh  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1456053ce7Sriastradh  * and/or sell copies of the Software, and to permit persons to whom the
1556053ce7Sriastradh  * Software is furnished to do so, subject to the following conditions:
1656053ce7Sriastradh  *
1756053ce7Sriastradh  * The above copyright notice and this permission notice (including the next
1856053ce7Sriastradh  * paragraph) shall be included in all copies or substantial portions of the
1956053ce7Sriastradh  * Software.
2056053ce7Sriastradh  *
2156053ce7Sriastradh  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2256053ce7Sriastradh  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2356053ce7Sriastradh  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
2456053ce7Sriastradh  * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
2556053ce7Sriastradh  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
2656053ce7Sriastradh  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2756053ce7Sriastradh  * DEALINGS IN THE SOFTWARE.
2856053ce7Sriastradh  *
2956053ce7Sriastradh  * Authors:
3056053ce7Sriastradh  *    Rickard E. (Rik) Faith <faith@valinux.com>
3156053ce7Sriastradh  *    Daryll Strauss <daryll@valinux.com>
3256053ce7Sriastradh  *    Gareth Hughes <gareth@valinux.com>
3356053ce7Sriastradh  */
3456053ce7Sriastradh 
35d350ecf5Sriastradh #include <sys/cdefs.h>
36*677dec6eSriastradh __KERNEL_RCSID(0, "$NetBSD: tdfx_drv.c,v 1.4 2021/12/18 23:45:44 riastradh Exp $");
37d350ecf5Sriastradh 
3856053ce7Sriastradh #include <linux/module.h>
39*677dec6eSriastradh #include <linux/pci.h>
4056053ce7Sriastradh 
41*677dec6eSriastradh #include <drm/drm_drv.h>
42*677dec6eSriastradh #include <drm/drm_file.h>
43*677dec6eSriastradh #include <drm/drm_ioctl.h>
44d350ecf5Sriastradh #include <drm/drm_legacy.h>
45*677dec6eSriastradh #include <drm/drm_pciids.h>
46*677dec6eSriastradh 
47*677dec6eSriastradh #include "tdfx_drv.h"
4856053ce7Sriastradh 
4956053ce7Sriastradh static struct pci_device_id pciidlist[] = {
5056053ce7Sriastradh 	tdfx_PCI_IDS
5156053ce7Sriastradh };
5256053ce7Sriastradh 
5356053ce7Sriastradh static const struct file_operations tdfx_driver_fops = {
5456053ce7Sriastradh 	.owner = THIS_MODULE,
5556053ce7Sriastradh 	.open = drm_open,
5656053ce7Sriastradh 	.release = drm_release,
5756053ce7Sriastradh 	.unlocked_ioctl = drm_ioctl,
58d350ecf5Sriastradh 	.mmap = drm_legacy_mmap,
5956053ce7Sriastradh 	.poll = drm_poll,
6056053ce7Sriastradh 	.compat_ioctl = drm_compat_ioctl,
6156053ce7Sriastradh 	.llseek = noop_llseek,
6256053ce7Sriastradh };
6356053ce7Sriastradh 
6456053ce7Sriastradh static struct drm_driver driver = {
65*677dec6eSriastradh 	.driver_features = DRIVER_LEGACY,
6656053ce7Sriastradh 	.fops = &tdfx_driver_fops,
6756053ce7Sriastradh 	.name = DRIVER_NAME,
6856053ce7Sriastradh 	.desc = DRIVER_DESC,
6956053ce7Sriastradh 	.date = DRIVER_DATE,
7056053ce7Sriastradh 	.major = DRIVER_MAJOR,
7156053ce7Sriastradh 	.minor = DRIVER_MINOR,
7256053ce7Sriastradh 	.patchlevel = DRIVER_PATCHLEVEL,
7356053ce7Sriastradh };
7456053ce7Sriastradh 
7556053ce7Sriastradh static struct pci_driver tdfx_pci_driver = {
7656053ce7Sriastradh 	.name = DRIVER_NAME,
7756053ce7Sriastradh 	.id_table = pciidlist,
7856053ce7Sriastradh };
7956053ce7Sriastradh 
tdfx_init(void)8056053ce7Sriastradh static int __init tdfx_init(void)
8156053ce7Sriastradh {
82*677dec6eSriastradh 	return drm_legacy_pci_init(&driver, &tdfx_pci_driver);
8356053ce7Sriastradh }
8456053ce7Sriastradh 
tdfx_exit(void)8556053ce7Sriastradh static void __exit tdfx_exit(void)
8656053ce7Sriastradh {
87*677dec6eSriastradh 	drm_legacy_pci_exit(&driver, &tdfx_pci_driver);
8856053ce7Sriastradh }
8956053ce7Sriastradh 
9056053ce7Sriastradh module_init(tdfx_init);
9156053ce7Sriastradh module_exit(tdfx_exit);
9256053ce7Sriastradh 
9356053ce7Sriastradh MODULE_AUTHOR(DRIVER_AUTHOR);
9456053ce7Sriastradh MODULE_DESCRIPTION(DRIVER_DESC);
9556053ce7Sriastradh MODULE_LICENSE("GPL and additional rights");
96