Add skeletal imagine driver (but don't build it yet).
[platform/upstream/libdrm.git] / linux-core / imagine_drv.c
1 /*
2  * Copyright 2005 Adam Jackson.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * on the rights to use, copy, modify, merge, publish, distribute, sub
8  * license, and/or sell copies of the Software, and to permit persons to whom
9  * the Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
18  * ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22
23 /* derived from tdfx_drv.c */
24
25 #include <linux/config.h>
26 #include "drmP.h"
27 #include "imagine_drv.h"
28
29 #include "drm_pciids.h"
30
31 static struct drm_driver driver;
32
33 static int postinit(struct drm_device *dev, unsigned long flags)
34 {
35     DRM_INFO("Initialized %s %d.%d.%d %s on minor %d: %s\n",
36              DRIVER_NAME, DRIVER_MAJOR, DRIVER_MINOR, DRIVER_PATCHLEVEL,
37              DRIVER_DATE, dev->primary.minor, pci_pretty_name(dev->pdev));
38     return 0;
39 }
40
41 static int version(drm_version_t *version)
42 {
43     int len;
44
45     version->version_major = DRIVER_MAJOR;
46     version->version_minor = DRIVER_MINOR;
47     version->version_patchlevel = DRIVER_PATCHLEVEL;
48     DRM_COPY(version->name, DRIVER_NAME);
49     DRM_COPY(version->date, DRIVER_DATE);
50     DRM_COPY(version->desc, DRIVER_DESC);
51     return 0;
52 }
53
54 static struct pci_device_id pciidlist[] = {
55     imagine_PCI_IDS
56 };
57
58 static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
59 {
60     return drm_get_dev(pdev, ent, &driver);
61 }
62
63 static struct drm_driver driver = {
64     .driver_features = DRIVER_USE_MTRR,
65     .reclaim_buffers = drm_core_reclaim_buffers,
66     .get_map_ofs = drm_core_get_map_ofs,
67     .get_reg_ofs = drm_core_get_reg_ofs,
68     .postinit = postinit,
69     .version = version,
70     .fops = {
71         .owner = THIS_MODULE,
72         .open = drm_open,
73         .release = drm_release,
74         .ioctl = drm_ioctl,
75         .mmap = drm_mmap,
76         .poll = drm_poll,
77         .fasync = drm_fasync,
78     },
79     .pci_driver = {
80         .name = DRIVER_NAME,
81         .id_table = pciidlist,
82         .probe = probe,
83         .remove = __devexit_p(drm_cleanup_pci),
84     },
85 };
86
87 static int __init imagine_init(void)
88 {
89     return drm_init(&driver, pciidlist);
90 }
91
92 static void __exit imagine_exit(void)
93 {
94     drm_exit(&driver);
95 }
96
97 module_init(imagine_init);
98 module_exit(imagine_exit);
99
100 MODULE_AUTHOR(DRIVER_AUTHOR);
101 MODULE_DESCRIPTION(DRIVER_DESC);
102 MODULE_LICENSE("GPL and additional rights");