1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * Copyright 2012 Red Hat 4 * 5 * Authors: Matthew Garrett 6 * Dave Airlie 7 */ 8 #include <linux/module.h> 9 #include <linux/console.h> 10 #include <drm/drmP.h> 11 12 #include "mgag200_drv.h" 13 14 #include <drm/drm_pciids.h> 15 16 /* 17 * This is the generic driver code. This binds the driver to the drm core, 18 * which then performs further device association and calls our graphics init 19 * functions 20 */ 21 int mgag200_modeset = -1; 22 23 MODULE_PARM_DESC(modeset, "Disable/Enable modesetting"); 24 module_param_named(modeset, mgag200_modeset, int, 0400); 25 26 static struct drm_driver driver; 27 28 static const struct pci_device_id pciidlist[] = { 29 { PCI_VENDOR_ID_MATROX, 0x522, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_SE_A }, 30 { PCI_VENDOR_ID_MATROX, 0x524, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_SE_B }, 31 { PCI_VENDOR_ID_MATROX, 0x530, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_EV }, 32 { PCI_VENDOR_ID_MATROX, 0x532, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_WB }, 33 { PCI_VENDOR_ID_MATROX, 0x533, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_EH }, 34 { PCI_VENDOR_ID_MATROX, 0x534, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_ER }, 35 { PCI_VENDOR_ID_MATROX, 0x536, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_EW3 }, 36 { PCI_VENDOR_ID_MATROX, 0x538, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_EH3 }, 37 {0,} 38 }; 39 40 MODULE_DEVICE_TABLE(pci, pciidlist); 41 42 43 static int mga_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 44 { 45 drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 0, "mgag200drmfb"); 46 47 return drm_get_pci_dev(pdev, ent, &driver); 48 } 49 50 static void mga_pci_remove(struct pci_dev *pdev) 51 { 52 struct drm_device *dev = pci_get_drvdata(pdev); 53 54 drm_put_dev(dev); 55 } 56 57 static const struct file_operations mgag200_driver_fops = { 58 .owner = THIS_MODULE, 59 DRM_VRAM_MM_FILE_OPERATIONS 60 }; 61 62 static struct drm_driver driver = { 63 .driver_features = DRIVER_GEM | DRIVER_MODESET, 64 .load = mgag200_driver_load, 65 .unload = mgag200_driver_unload, 66 .fops = &mgag200_driver_fops, 67 .name = DRIVER_NAME, 68 .desc = DRIVER_DESC, 69 .date = DRIVER_DATE, 70 .major = DRIVER_MAJOR, 71 .minor = DRIVER_MINOR, 72 .patchlevel = DRIVER_PATCHLEVEL, 73 DRM_GEM_VRAM_DRIVER 74 }; 75 76 static struct pci_driver mgag200_pci_driver = { 77 .name = DRIVER_NAME, 78 .id_table = pciidlist, 79 .probe = mga_pci_probe, 80 .remove = mga_pci_remove, 81 }; 82 83 static int __init mgag200_init(void) 84 { 85 if (vgacon_text_force() && mgag200_modeset == -1) 86 return -EINVAL; 87 88 if (mgag200_modeset == 0) 89 return -EINVAL; 90 91 return pci_register_driver(&mgag200_pci_driver); 92 } 93 94 static void __exit mgag200_exit(void) 95 { 96 pci_unregister_driver(&mgag200_pci_driver); 97 } 98 99 module_init(mgag200_init); 100 module_exit(mgag200_exit); 101 102 MODULE_AUTHOR(DRIVER_AUTHOR); 103 MODULE_DESCRIPTION(DRIVER_DESC); 104 MODULE_LICENSE("GPL"); 105