11.2Sriastrad/*	$NetBSD: i810_drv.c,v 1.4 2021/12/18 23:45:27 riastradh Exp $	*/
21.2Sriastrad
31.1Sriastrad/* i810_drv.c -- I810 driver -*- linux-c -*-
41.1Sriastrad * Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com
51.1Sriastrad *
61.1Sriastrad * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
71.1Sriastrad * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
81.1Sriastrad * All Rights Reserved.
91.1Sriastrad *
101.1Sriastrad * Permission is hereby granted, free of charge, to any person obtaining a
111.1Sriastrad * copy of this software and associated documentation files (the "Software"),
121.1Sriastrad * to deal in the Software without restriction, including without limitation
131.1Sriastrad * the rights to use, copy, modify, merge, publish, distribute, sublicense,
141.1Sriastrad * and/or sell copies of the Software, and to permit persons to whom the
151.1Sriastrad * Software is furnished to do so, subject to the following conditions:
161.1Sriastrad *
171.1Sriastrad * The above copyright notice and this permission notice (including the next
181.1Sriastrad * paragraph) shall be included in all copies or substantial portions of the
191.1Sriastrad * Software.
201.1Sriastrad *
211.1Sriastrad * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
221.1Sriastrad * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
231.1Sriastrad * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
241.1Sriastrad * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
251.1Sriastrad * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
261.1Sriastrad * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
271.1Sriastrad * OTHER DEALINGS IN THE SOFTWARE.
281.1Sriastrad *
291.1Sriastrad * Authors:
301.1Sriastrad *    Rickard E. (Rik) Faith <faith@valinux.com>
311.1Sriastrad *    Jeff Hartmann <jhartmann@valinux.com>
321.1Sriastrad *    Gareth Hughes <gareth@valinux.com>
331.1Sriastrad */
341.1Sriastrad
351.2Sriastrad#include <sys/cdefs.h>
361.2Sriastrad__KERNEL_RCSID(0, "$NetBSD: i810_drv.c,v 1.4 2021/12/18 23:45:27 riastradh Exp $");
371.2Sriastrad
381.4Sriastrad#include "i810_drv.h"
391.4Sriastrad
401.1Sriastrad#include <linux/module.h>
411.4Sriastrad#include <linux/pci.h>
421.1Sriastrad
431.4Sriastrad#include <drm/drm_drv.h>
441.4Sriastrad#include <drm/drm_file.h>
451.4Sriastrad#include <drm/drm_pciids.h>
461.1Sriastrad#include <drm/i810_drm.h>
471.1Sriastrad
481.1Sriastrad
491.1Sriastradstatic struct pci_device_id pciidlist[] = {
501.1Sriastrad	i810_PCI_IDS
511.1Sriastrad};
521.1Sriastrad
531.1Sriastradstatic const struct file_operations i810_driver_fops = {
541.1Sriastrad	.owner = THIS_MODULE,
551.1Sriastrad	.open = drm_open,
561.1Sriastrad	.release = drm_release,
571.1Sriastrad	.unlocked_ioctl = drm_ioctl,
581.2Sriastrad	.mmap = drm_legacy_mmap,
591.1Sriastrad	.poll = drm_poll,
601.1Sriastrad	.compat_ioctl = drm_compat_ioctl,
611.1Sriastrad	.llseek = noop_llseek,
621.1Sriastrad};
631.1Sriastrad
641.1Sriastradstatic struct drm_driver driver = {
651.4Sriastrad	.driver_features = DRIVER_USE_AGP | DRIVER_HAVE_DMA | DRIVER_LEGACY,
661.1Sriastrad	.dev_priv_size = sizeof(drm_i810_buf_priv_t),
671.1Sriastrad	.load = i810_driver_load,
681.1Sriastrad	.lastclose = i810_driver_lastclose,
691.1Sriastrad	.preclose = i810_driver_preclose,
701.1Sriastrad	.dma_quiescent = i810_driver_dma_quiescent,
711.1Sriastrad	.ioctls = i810_ioctls,
721.1Sriastrad	.fops = &i810_driver_fops,
731.1Sriastrad	.name = DRIVER_NAME,
741.1Sriastrad	.desc = DRIVER_DESC,
751.1Sriastrad	.date = DRIVER_DATE,
761.1Sriastrad	.major = DRIVER_MAJOR,
771.1Sriastrad	.minor = DRIVER_MINOR,
781.1Sriastrad	.patchlevel = DRIVER_PATCHLEVEL,
791.1Sriastrad};
801.1Sriastrad
811.1Sriastradstatic struct pci_driver i810_pci_driver = {
821.1Sriastrad	.name = DRIVER_NAME,
831.1Sriastrad	.id_table = pciidlist,
841.1Sriastrad};
851.1Sriastrad
861.1Sriastradstatic int __init i810_init(void)
871.1Sriastrad{
881.1Sriastrad	if (num_possible_cpus() > 1) {
891.1Sriastrad		pr_err("drm/i810 does not support SMP\n");
901.1Sriastrad		return -EINVAL;
911.1Sriastrad	}
921.1Sriastrad	driver.num_ioctls = i810_max_ioctl;
931.4Sriastrad	return drm_legacy_pci_init(&driver, &i810_pci_driver);
941.1Sriastrad}
951.1Sriastrad
961.1Sriastradstatic void __exit i810_exit(void)
971.1Sriastrad{
981.4Sriastrad	drm_legacy_pci_exit(&driver, &i810_pci_driver);
991.1Sriastrad}
1001.1Sriastrad
1011.1Sriastradmodule_init(i810_init);
1021.1Sriastradmodule_exit(i810_exit);
1031.1Sriastrad
1041.1SriastradMODULE_AUTHOR(DRIVER_AUTHOR);
1051.1SriastradMODULE_DESCRIPTION(DRIVER_DESC);
1061.1SriastradMODULE_LICENSE("GPL and additional rights");
107