blob: 2e1f925b5caf2de542d90e12c3bde0910c7c13f2 [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{
87 if (vgacon_text_force() && cirrus_modeset == -1)
88 return -EINVAL;
89
90 if (cirrus_modeset == 0)
91 return -EINVAL;
92 return drm_pci_init(&driver, &cirrus_pci_driver);
93}
94
95static void __exit cirrus_exit(void)
96{
97 drm_pci_exit(&driver, &cirrus_pci_driver);
98}
99
100module_init(cirrus_init);
101module_exit(cirrus_exit);
102
103MODULE_DEVICE_TABLE(pci, pciidlist);
104MODULE_AUTHOR(DRIVER_AUTHOR);
105MODULE_DESCRIPTION(DRIVER_DESC);
106MODULE_LICENSE("GPL");