1 /* vim: set ts=8 sw=8 tw=78 ai noexpandtab */
2 /* qxl_drv.c -- QXL driver -*- linux-c -*-
4 * Copyright 2011 Red Hat, Inc.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice (including the next
15 * paragraph) shall be included in all copies or substantial portions of the
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * OTHER DEALINGS IN THE SOFTWARE.
27 * Dave Airlie <airlie@redhat.com>
28 * Alon Levy <alevy@redhat.com>
31 #include <linux/module.h>
32 #include <linux/console.h>
39 extern int qxl_max_ioctls;
40 static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
41 { 0x1b36, 0x100, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8,
43 { 0x1b36, 0x100, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_OTHER << 8,
47 MODULE_DEVICE_TABLE(pci, pciidlist);
49 static int qxl_modeset = -1;
52 MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
53 module_param_named(modeset, qxl_modeset, int, 0400);
55 MODULE_PARM_DESC(num_heads, "Number of virtual crtcs to expose (default 4)");
56 module_param_named(num_heads, qxl_num_crtc, int, 0400);
58 static struct drm_driver qxl_driver;
59 static struct pci_driver qxl_pci_driver;
62 qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
64 if (pdev->revision < 4) {
65 DRM_ERROR("qxl too old, doesn't support client_monitors_config,"
66 " use xf86-video-qxl in user mode");
67 return -EINVAL; /* TODO: ENODEV ? */
69 return drm_get_pci_dev(pdev, ent, &qxl_driver);
73 qxl_pci_remove(struct pci_dev *pdev)
75 struct drm_device *dev = pci_get_drvdata(pdev);
80 static struct pci_driver qxl_pci_driver = {
82 .id_table = pciidlist,
83 .probe = qxl_pci_probe,
84 .remove = qxl_pci_remove,
87 static const struct file_operations qxl_fops = {
90 .release = drm_release,
91 .unlocked_ioctl = drm_ioctl,
97 static struct drm_driver qxl_driver = {
98 .driver_features = DRIVER_GEM | DRIVER_MODESET |
99 DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
101 .load = qxl_driver_load,
102 .unload = qxl_driver_unload,
104 .dumb_create = qxl_mode_dumb_create,
105 .dumb_map_offset = qxl_mode_dumb_mmap,
106 .dumb_destroy = qxl_mode_dumb_destroy,
107 #if defined(CONFIG_DEBUG_FS)
108 .debugfs_init = qxl_debugfs_init,
109 .debugfs_cleanup = qxl_debugfs_takedown,
111 .gem_init_object = qxl_gem_object_init,
112 .gem_free_object = qxl_gem_object_free,
113 .gem_open_object = qxl_gem_object_open,
114 .gem_close_object = qxl_gem_object_close,
116 .ioctls = qxl_ioctls,
117 .irq_handler = qxl_irq_handler,
126 static int __init qxl_init(void)
128 #ifdef CONFIG_VGA_CONSOLE
129 if (vgacon_text_force() && qxl_modeset == -1)
133 if (qxl_modeset == 0)
135 qxl_driver.num_ioctls = qxl_max_ioctls;
136 return drm_pci_init(&qxl_driver, &qxl_pci_driver);
139 static void __exit qxl_exit(void)
141 drm_pci_exit(&qxl_driver, &qxl_pci_driver);
144 module_init(qxl_init);
145 module_exit(qxl_exit);
147 MODULE_AUTHOR(DRIVER_AUTHOR);
148 MODULE_DESCRIPTION(DRIVER_DESC);
149 MODULE_LICENSE("GPL and additional rights");