blob: d7038230b71e7f113e8ae453bce0327528de575a [file] [log] [blame]
Dave Airlief9aa76a2012-04-17 14:12:29 +01001/*
2 * Copyright 2012 Red Hat <mjg@redhat.com>
3 *
4 * This file is subject to the terms and conditions of the GNU General
5 * Public License version 2. See the file COPYING in the main
6 * directory of this archive for more details.
7 *
8 * Authors: Matthew Garrett
9 * Dave Airlie
10 */
11#include <linux/module.h>
12#include <linux/console.h>
13#include "drmP.h"
14#include "drm.h"
15
16#include "cirrus_drv.h"
17
18int cirrus_modeset = -1;
19
20MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
21module_param_named(modeset, cirrus_modeset, int, 0400);
22
23/*
24 * This is the generic driver code. This binds the driver to the drm core,
25 * which then performs further device association and calls our graphics init
26 * functions
27 */
28
29static struct drm_driver driver;
30
31/* only bind to the cirrus chip in qemu */
32static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
33 { PCI_VENDOR_ID_CIRRUS, PCI_DEVICE_ID_CIRRUS_5446, 0x1af4, 0x1100, 0,
34 0, 0 },
35 {0,}
36};
37
38static int __devinit
39cirrus_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40{
41 return drm_get_pci_dev(pdev, ent, &driver);
42}
43
44static void cirrus_pci_remove(struct pci_dev *pdev)
45{
46 struct drm_device *dev = pci_get_drvdata(pdev);
47
48 drm_put_dev(dev);
49}
50
51static const struct file_operations cirrus_driver_fops = {
52 .owner = THIS_MODULE,
53 .open = drm_open,
54 .release = drm_release,
55 .unlocked_ioctl = drm_ioctl,
56 .mmap = cirrus_mmap,
57 .poll = drm_poll,
58 .fasync = drm_fasync,
59};
60static struct drm_driver driver = {
61 .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_USE_MTRR,
62 .load = cirrus_driver_load,
63 .unload = cirrus_driver_unload,
64 .fops = &cirrus_driver_fops,
65 .name = DRIVER_NAME,
66 .desc = DRIVER_DESC,
67 .date = DRIVER_DATE,
68 .major = DRIVER_MAJOR,
69 .minor = DRIVER_MINOR,
70 .patchlevel = DRIVER_PATCHLEVEL,
71 .gem_init_object = cirrus_gem_init_object,
72 .gem_free_object = cirrus_gem_free_object,
73 .dumb_create = cirrus_dumb_create,
74 .dumb_map_offset = cirrus_dumb_mmap_offset,
75 .dumb_destroy = cirrus_dumb_destroy,
76};
77
78static struct pci_driver cirrus_pci_driver = {
79 .name = DRIVER_NAME,
80 .id_table = pciidlist,
81 .probe = cirrus_pci_probe,
82 .remove = cirrus_pci_remove,
83};
84
85static int __init cirrus_init(void)
86{
Dave Airlie4688a692012-05-19 16:33:21 +010087#ifdef CONFIG_VGA_CONSOLE
Dave Airlief9aa76a2012-04-17 14:12:29 +010088 if (vgacon_text_force() && cirrus_modeset == -1)
89 return -EINVAL;
Dave Airlie4688a692012-05-19 16:33:21 +010090#endif
Dave Airlief9aa76a2012-04-17 14:12:29 +010091
92 if (cirrus_modeset == 0)
93 return -EINVAL;
94 return drm_pci_init(&driver, &cirrus_pci_driver);
95}
96
97static void __exit cirrus_exit(void)
98{
99 drm_pci_exit(&driver, &cirrus_pci_driver);
100}
101
102module_init(cirrus_init);
103module_exit(cirrus_exit);
104
105MODULE_DEVICE_TABLE(pci, pciidlist);
106MODULE_AUTHOR(DRIVER_AUTHOR);
107MODULE_DESCRIPTION(DRIVER_DESC);
108MODULE_LICENSE("GPL");