Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2005 Stephane Marchesin. |
| 3 | * All Rights Reserved. |
| 4 | * |
| 5 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 6 | * copy of this software and associated documentation files (the "Software"), |
| 7 | * to deal in the Software without restriction, including without limitation |
| 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 9 | * and/or sell copies of the Software, and to permit persons to whom the |
| 10 | * Software is furnished to do so, subject to the following conditions: |
| 11 | * |
| 12 | * The above copyright notice and this permission notice (including the next |
| 13 | * paragraph) shall be included in all copies or substantial portions of the |
| 14 | * Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 22 | * OTHER DEALINGS IN THE SOFTWARE. |
| 23 | */ |
| 24 | |
| 25 | #include <linux/console.h> |
Paul Gortmaker | e0cd360 | 2011-08-30 11:04:30 -0400 | [diff] [blame] | 26 | #include <linux/module.h> |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 27 | |
| 28 | #include "drmP.h" |
| 29 | #include "drm.h" |
| 30 | #include "drm_crtc_helper.h" |
| 31 | #include "nouveau_drv.h" |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 32 | #include "nouveau_abi16.h" |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 33 | #include "nouveau_hw.h" |
| 34 | #include "nouveau_fb.h" |
| 35 | #include "nouveau_fbcon.h" |
Ben Skeggs | e193b1d | 2012-07-19 10:51:42 +1000 | [diff] [blame] | 36 | #include "nouveau_fence.h" |
Ben Skeggs | 64f1c11 | 2010-09-17 13:35:25 +1000 | [diff] [blame] | 37 | #include "nouveau_pm.h" |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 38 | #include "nv50_display.h" |
Ben Skeggs | c007706 | 2012-07-26 08:51:21 +1000 | [diff] [blame] | 39 | #include "nouveau_acpi.h" |
Ben Skeggs | fce875d | 2012-07-26 08:54:33 +1000 | [diff] [blame] | 40 | #include "nouveau_ioctl.h" |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 41 | |
| 42 | #include "drm_pciids.h" |
| 43 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 44 | MODULE_PARM_DESC(modeset, "Enable kernel modesetting"); |
Ben Skeggs | 03bc967 | 2011-07-04 13:14:05 +1000 | [diff] [blame] | 45 | int nouveau_modeset = -1; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 46 | module_param_named(modeset, nouveau_modeset, int, 0400); |
| 47 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 48 | MODULE_PARM_DESC(vram_notify, "Force DMA notifiers to be in VRAM"); |
Ben Skeggs | 2dfe36b | 2010-06-01 09:47:43 +1000 | [diff] [blame] | 49 | int nouveau_vram_notify = 0; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 50 | module_param_named(vram_notify, nouveau_vram_notify, int, 0400); |
| 51 | |
Ben Skeggs | 7ad2d31 | 2011-12-11 00:30:05 +1000 | [diff] [blame] | 52 | MODULE_PARM_DESC(vram_type, "Override detected VRAM type"); |
| 53 | char *nouveau_vram_type; |
| 54 | module_param_named(vram_type, nouveau_vram_type, charp, 0400); |
| 55 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 56 | MODULE_PARM_DESC(duallink, "Allow dual-link TMDS (>=GeForce 8)"); |
| 57 | int nouveau_duallink = 1; |
| 58 | module_param_named(duallink, nouveau_duallink, int, 0400); |
| 59 | |
| 60 | MODULE_PARM_DESC(uscript_lvds, "LVDS output script table ID (>=GeForce 8)"); |
| 61 | int nouveau_uscript_lvds = -1; |
| 62 | module_param_named(uscript_lvds, nouveau_uscript_lvds, int, 0400); |
| 63 | |
| 64 | MODULE_PARM_DESC(uscript_tmds, "TMDS output script table ID (>=GeForce 8)"); |
| 65 | int nouveau_uscript_tmds = -1; |
| 66 | module_param_named(uscript_tmds, nouveau_uscript_tmds, int, 0400); |
| 67 | |
Ben Skeggs | a147089 | 2010-01-18 11:42:37 +1000 | [diff] [blame] | 68 | MODULE_PARM_DESC(ignorelid, "Ignore ACPI lid status"); |
| 69 | int nouveau_ignorelid = 0; |
| 70 | module_param_named(ignorelid, nouveau_ignorelid, int, 0400); |
| 71 | |
Marcin KoĆcielnicki | 0cba1b7 | 2010-09-29 11:15:01 +0000 | [diff] [blame] | 72 | MODULE_PARM_DESC(force_post, "Force POST"); |
| 73 | int nouveau_force_post = 0; |
| 74 | module_param_named(force_post, nouveau_force_post, int, 0400); |
| 75 | |
Ben Skeggs | da647d5 | 2010-03-04 12:00:39 +1000 | [diff] [blame] | 76 | MODULE_PARM_DESC(override_conntype, "Ignore DCB connector type"); |
| 77 | int nouveau_override_conntype = 0; |
| 78 | module_param_named(override_conntype, nouveau_override_conntype, int, 0400); |
| 79 | |
Jean Delvare | 1a5f985 | 2011-11-30 17:23:55 +0100 | [diff] [blame] | 80 | MODULE_PARM_DESC(tv_disable, "Disable TV-out detection"); |
Ben Skeggs | f405350 | 2010-03-15 09:43:51 +1000 | [diff] [blame] | 81 | int nouveau_tv_disable = 0; |
| 82 | module_param_named(tv_disable, nouveau_tv_disable, int, 0400); |
| 83 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 84 | MODULE_PARM_DESC(tv_norm, "Default TV norm.\n" |
| 85 | "\t\tSupported: PAL, PAL-M, PAL-N, PAL-Nc, NTSC-M, NTSC-J,\n" |
| 86 | "\t\t\thd480i, hd480p, hd576i, hd576p, hd720p, hd1080i.\n" |
| 87 | "\t\tDefault: PAL\n" |
| 88 | "\t\t*NOTE* Ignored for cards with external TV encoders."); |
| 89 | char *nouveau_tv_norm; |
| 90 | module_param_named(tv_norm, nouveau_tv_norm, charp, 0400); |
| 91 | |
Jean Delvare | 1a5f985 | 2011-11-30 17:23:55 +0100 | [diff] [blame] | 92 | MODULE_PARM_DESC(perflvl, "Performance level (default: boot)"); |
Ben Skeggs | 6f87698 | 2010-09-16 16:47:14 +1000 | [diff] [blame] | 93 | char *nouveau_perflvl; |
| 94 | module_param_named(perflvl, nouveau_perflvl, charp, 0400); |
| 95 | |
Jean Delvare | 1a5f985 | 2011-11-30 17:23:55 +0100 | [diff] [blame] | 96 | MODULE_PARM_DESC(perflvl_wr, "Allow perflvl changes (warning: dangerous!)"); |
Ben Skeggs | 6f87698 | 2010-09-16 16:47:14 +1000 | [diff] [blame] | 97 | int nouveau_perflvl_wr; |
| 98 | module_param_named(perflvl_wr, nouveau_perflvl_wr, int, 0400); |
| 99 | |
Jean Delvare | 1a5f985 | 2011-11-30 17:23:55 +0100 | [diff] [blame] | 100 | MODULE_PARM_DESC(msi, "Enable MSI (default: off)"); |
Ben Skeggs | 35fa2f2 | 2010-10-21 14:07:03 +1000 | [diff] [blame] | 101 | int nouveau_msi; |
| 102 | module_param_named(msi, nouveau_msi, int, 0400); |
| 103 | |
Jean Delvare | 1a5f985 | 2011-11-30 17:23:55 +0100 | [diff] [blame] | 104 | MODULE_PARM_DESC(ctxfw, "Use external HUB/GPC ucode (fermi)"); |
Ben Skeggs | 0411de8 | 2011-05-25 18:32:44 +1000 | [diff] [blame] | 105 | int nouveau_ctxfw; |
| 106 | module_param_named(ctxfw, nouveau_ctxfw, int, 0400); |
| 107 | |
Jean Delvare | 1a5f985 | 2011-11-30 17:23:55 +0100 | [diff] [blame] | 108 | MODULE_PARM_DESC(mxmdcb, "Santise DCB table according to MXM-SIS"); |
Ben Skeggs | b4c2681 | 2011-10-12 16:36:42 +1000 | [diff] [blame] | 109 | int nouveau_mxmdcb = 1; |
| 110 | module_param_named(mxmdcb, nouveau_mxmdcb, int, 0400); |
| 111 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 112 | int nouveau_fbpercrtc; |
| 113 | #if 0 |
| 114 | module_param_named(fbpercrtc, nouveau_fbpercrtc, int, 0400); |
| 115 | #endif |
| 116 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 117 | static struct drm_driver driver; |
| 118 | |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 119 | int __devinit |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 120 | nouveau_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
| 121 | { |
Jordan Crouse | dcdb167 | 2010-05-27 13:40:25 -0600 | [diff] [blame] | 122 | return drm_get_pci_dev(pdev, ent, &driver); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 123 | } |
| 124 | |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 125 | void |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 126 | nouveau_pci_remove(struct pci_dev *pdev) |
| 127 | { |
| 128 | struct drm_device *dev = pci_get_drvdata(pdev); |
| 129 | |
| 130 | drm_put_dev(dev); |
| 131 | } |
| 132 | |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 133 | int |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 134 | nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state) |
| 135 | { |
| 136 | struct drm_device *dev = pci_get_drvdata(pdev); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 137 | struct drm_crtc *crtc; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 138 | |
Ben Skeggs | f62b27d | 2011-11-09 15:18:47 +1000 | [diff] [blame] | 139 | NV_INFO(dev, "Disabling display...\n"); |
| 140 | nouveau_display_fini(dev); |
Maxim Levitsky | 4bfb94a | 2011-10-09 22:58:33 +0200 | [diff] [blame] | 141 | |
Maarten Maathuis | 81441570 | 2010-02-21 13:28:35 +0100 | [diff] [blame] | 142 | NV_INFO(dev, "Unpinning framebuffer(s)...\n"); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 143 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
| 144 | struct nouveau_framebuffer *nouveau_fb; |
| 145 | |
| 146 | nouveau_fb = nouveau_framebuffer(crtc->fb); |
| 147 | if (!nouveau_fb || !nouveau_fb->nvbo) |
| 148 | continue; |
| 149 | |
| 150 | nouveau_bo_unpin(nouveau_fb->nvbo); |
| 151 | } |
| 152 | |
Maarten Maathuis | b334f2b | 2010-05-09 14:49:52 +0200 | [diff] [blame] | 153 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
| 154 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
| 155 | |
| 156 | nouveau_bo_unmap(nv_crtc->cursor.nvbo); |
| 157 | nouveau_bo_unpin(nv_crtc->cursor.nvbo); |
| 158 | } |
| 159 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 160 | return 0; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 161 | } |
| 162 | |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 163 | int |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 164 | nouveau_pci_resume(struct pci_dev *pdev) |
| 165 | { |
| 166 | struct drm_device *dev = pci_get_drvdata(pdev); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 167 | struct drm_crtc *crtc; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 168 | int ret; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 169 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 170 | ret = nouveau_run_vbios_init(dev); |
| 171 | if (ret) |
| 172 | return ret; |
| 173 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 174 | nouveau_irq_postinstall(dev); |
| 175 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 176 | #if 0 |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 177 | /* Re-write SKIPS, they'll have been lost over the suspend */ |
| 178 | if (nouveau_vram_pushbuf) { |
| 179 | struct nouveau_channel *chan; |
| 180 | int j; |
| 181 | |
Ben Skeggs | c420b2d | 2012-05-01 20:48:08 +1000 | [diff] [blame] | 182 | for (i = 0; i < (pfifo ? pfifo->channels : 0); i++) { |
Ben Skeggs | cff5c13 | 2010-10-06 16:16:59 +1000 | [diff] [blame] | 183 | chan = dev_priv->channels.ptr[i]; |
Ben Skeggs | 3c8868d | 2009-12-16 14:51:13 +1000 | [diff] [blame] | 184 | if (!chan || !chan->pushbuf_bo) |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 185 | continue; |
| 186 | |
| 187 | for (j = 0; j < NOUVEAU_DMA_SKIPS; j++) |
| 188 | nouveau_bo_wr32(chan->pushbuf_bo, i, 0); |
| 189 | } |
| 190 | } |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 191 | #endif |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 192 | |
Maxim Levitsky | 71d91f6 | 2011-10-09 22:58:35 +0200 | [diff] [blame] | 193 | nouveau_pm_resume(dev); |
| 194 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 195 | NV_INFO(dev, "Restoring mode...\n"); |
| 196 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
| 197 | struct nouveau_framebuffer *nouveau_fb; |
| 198 | |
| 199 | nouveau_fb = nouveau_framebuffer(crtc->fb); |
| 200 | if (!nouveau_fb || !nouveau_fb->nvbo) |
| 201 | continue; |
| 202 | |
| 203 | nouveau_bo_pin(nouveau_fb->nvbo, TTM_PL_FLAG_VRAM); |
| 204 | } |
| 205 | |
Maarten Maathuis | b334f2b | 2010-05-09 14:49:52 +0200 | [diff] [blame] | 206 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
| 207 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
Maarten Maathuis | b334f2b | 2010-05-09 14:49:52 +0200 | [diff] [blame] | 208 | |
| 209 | ret = nouveau_bo_pin(nv_crtc->cursor.nvbo, TTM_PL_FLAG_VRAM); |
| 210 | if (!ret) |
| 211 | ret = nouveau_bo_map(nv_crtc->cursor.nvbo); |
| 212 | if (ret) |
| 213 | NV_ERROR(dev, "Could not pin/map cursor.\n"); |
| 214 | } |
| 215 | |
Ben Skeggs | cf41d53 | 2011-11-09 14:31:16 +1000 | [diff] [blame] | 216 | nouveau_fbcon_set_suspend(dev, 0); |
| 217 | nouveau_fbcon_zfill_all(dev); |
| 218 | |
Ben Skeggs | f62b27d | 2011-11-09 15:18:47 +1000 | [diff] [blame] | 219 | nouveau_display_init(dev); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 220 | |
| 221 | /* Force CLUT to get re-loaded during modeset */ |
| 222 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
| 223 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
| 224 | |
| 225 | nv_crtc->lut.depth = 0; |
| 226 | } |
| 227 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 228 | drm_helper_resume_force_mode(dev); |
Dave Airlie | 3865167 | 2010-03-30 05:34:13 +0000 | [diff] [blame] | 229 | |
Maxim Levitsky | a4eaa0a | 2011-10-09 22:58:34 +0200 | [diff] [blame] | 230 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
| 231 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
| 232 | u32 offset = nv_crtc->cursor.nvbo->bo.offset; |
| 233 | |
| 234 | nv_crtc->cursor.set_offset(nv_crtc, offset); |
| 235 | nv_crtc->cursor.set_pos(nv_crtc, nv_crtc->cursor_saved_x, |
| 236 | nv_crtc->cursor_saved_y); |
| 237 | } |
| 238 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 239 | return 0; |
| 240 | } |
| 241 | |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 242 | static struct drm_ioctl_desc nouveau_ioctls[] = { |
| 243 | DRM_IOCTL_DEF_DRV(NOUVEAU_GETPARAM, nouveau_abi16_ioctl_getparam, DRM_UNLOCKED|DRM_AUTH), |
| 244 | DRM_IOCTL_DEF_DRV(NOUVEAU_SETPARAM, nouveau_abi16_ioctl_setparam, DRM_UNLOCKED|DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 245 | DRM_IOCTL_DEF_DRV(NOUVEAU_CHANNEL_ALLOC, nouveau_abi16_ioctl_channel_alloc, DRM_UNLOCKED|DRM_AUTH), |
| 246 | DRM_IOCTL_DEF_DRV(NOUVEAU_CHANNEL_FREE, nouveau_abi16_ioctl_channel_free, DRM_UNLOCKED|DRM_AUTH), |
| 247 | DRM_IOCTL_DEF_DRV(NOUVEAU_GROBJ_ALLOC, nouveau_abi16_ioctl_grobj_alloc, DRM_UNLOCKED|DRM_AUTH), |
| 248 | DRM_IOCTL_DEF_DRV(NOUVEAU_NOTIFIEROBJ_ALLOC, nouveau_abi16_ioctl_notifierobj_alloc, DRM_UNLOCKED|DRM_AUTH), |
| 249 | DRM_IOCTL_DEF_DRV(NOUVEAU_GPUOBJ_FREE, nouveau_abi16_ioctl_gpuobj_free, DRM_UNLOCKED|DRM_AUTH), |
| 250 | DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_NEW, nouveau_gem_ioctl_new, DRM_UNLOCKED|DRM_AUTH), |
| 251 | DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_PUSHBUF, nouveau_gem_ioctl_pushbuf, DRM_UNLOCKED|DRM_AUTH), |
| 252 | DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_CPU_PREP, nouveau_gem_ioctl_cpu_prep, DRM_UNLOCKED|DRM_AUTH), |
| 253 | DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_CPU_FINI, nouveau_gem_ioctl_cpu_fini, DRM_UNLOCKED|DRM_AUTH), |
| 254 | DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_INFO, nouveau_gem_ioctl_info, DRM_UNLOCKED|DRM_AUTH), |
| 255 | }; |
| 256 | |
Arjan van de Ven | e08e96d | 2011-10-31 07:28:57 -0700 | [diff] [blame] | 257 | static const struct file_operations nouveau_driver_fops = { |
| 258 | .owner = THIS_MODULE, |
| 259 | .open = drm_open, |
| 260 | .release = drm_release, |
| 261 | .unlocked_ioctl = drm_ioctl, |
| 262 | .mmap = nouveau_ttm_mmap, |
| 263 | .poll = drm_poll, |
| 264 | .fasync = drm_fasync, |
| 265 | .read = drm_read, |
| 266 | #if defined(CONFIG_COMPAT) |
| 267 | .compat_ioctl = nouveau_compat_ioctl, |
| 268 | #endif |
| 269 | .llseek = noop_llseek, |
| 270 | }; |
| 271 | |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 272 | int nouveau_drm_load(struct drm_device *, unsigned long); |
| 273 | int nouveau_drm_unload(struct drm_device *); |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 274 | int nouveau_drm_open(struct drm_device *, struct drm_file *); |
| 275 | void nouveau_drm_preclose(struct drm_device *dev, struct drm_file *); |
| 276 | void nouveau_drm_postclose(struct drm_device *, struct drm_file *); |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 277 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 278 | static struct drm_driver driver = { |
| 279 | .driver_features = |
| 280 | DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG | |
Ben Skeggs | cd0b072 | 2010-06-01 15:56:22 +1000 | [diff] [blame] | 281 | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_GEM | |
Dave Airlie | 22b33e8 | 2012-04-02 11:53:06 +0100 | [diff] [blame] | 282 | DRIVER_MODESET | DRIVER_PRIME, |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 283 | .load = nouveau_drm_load, |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 284 | .firstopen = nouveau_firstopen, |
| 285 | .lastclose = nouveau_lastclose, |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 286 | .unload = nouveau_drm_unload, |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 287 | .open = nouveau_drm_open, |
| 288 | .preclose = nouveau_drm_preclose, |
| 289 | .postclose = nouveau_drm_postclose, |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 290 | .irq_preinstall = nouveau_irq_preinstall, |
| 291 | .irq_postinstall = nouveau_irq_postinstall, |
| 292 | .irq_uninstall = nouveau_irq_uninstall, |
| 293 | .irq_handler = nouveau_irq_handler, |
Francisco Jerez | 042206c | 2010-10-21 18:19:29 +0200 | [diff] [blame] | 294 | .get_vblank_counter = drm_vblank_count, |
| 295 | .enable_vblank = nouveau_vblank_enable, |
| 296 | .disable_vblank = nouveau_vblank_disable, |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 297 | .ioctls = nouveau_ioctls, |
Arjan van de Ven | e08e96d | 2011-10-31 07:28:57 -0700 | [diff] [blame] | 298 | .fops = &nouveau_driver_fops, |
Dave Airlie | 22b33e8 | 2012-04-02 11:53:06 +0100 | [diff] [blame] | 299 | |
| 300 | .prime_handle_to_fd = drm_gem_prime_handle_to_fd, |
| 301 | .prime_fd_to_handle = drm_gem_prime_fd_to_handle, |
| 302 | .gem_prime_export = nouveau_gem_prime_export, |
| 303 | .gem_prime_import = nouveau_gem_prime_import, |
| 304 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 305 | .gem_init_object = nouveau_gem_object_new, |
| 306 | .gem_free_object = nouveau_gem_object_del, |
Ben Skeggs | 639212d | 2011-06-03 16:18:26 +1000 | [diff] [blame] | 307 | .gem_open_object = nouveau_gem_object_open, |
| 308 | .gem_close_object = nouveau_gem_object_close, |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 309 | |
Ben Skeggs | 33dbc27 | 2011-09-30 08:55:50 +1000 | [diff] [blame] | 310 | .dumb_create = nouveau_display_dumb_create, |
| 311 | .dumb_map_offset = nouveau_display_dumb_map_offset, |
| 312 | .dumb_destroy = nouveau_display_dumb_destroy, |
| 313 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 314 | .name = DRIVER_NAME, |
| 315 | .desc = DRIVER_DESC, |
| 316 | #ifdef GIT_REVISION |
| 317 | .date = GIT_REVISION, |
| 318 | #else |
| 319 | .date = DRIVER_DATE, |
| 320 | #endif |
| 321 | .major = DRIVER_MAJOR, |
| 322 | .minor = DRIVER_MINOR, |
| 323 | .patchlevel = DRIVER_PATCHLEVEL, |
| 324 | }; |
| 325 | |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 326 | int __init nouveau_init(struct pci_driver *pdrv) |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 327 | { |
Ben Skeggs | 2a259a3 | 2012-05-08 10:24:27 +1000 | [diff] [blame] | 328 | driver.num_ioctls = ARRAY_SIZE(nouveau_ioctls); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 329 | |
| 330 | if (nouveau_modeset == -1) { |
| 331 | #ifdef CONFIG_VGA_CONSOLE |
| 332 | if (vgacon_text_force()) |
| 333 | nouveau_modeset = 0; |
| 334 | else |
| 335 | #endif |
| 336 | nouveau_modeset = 1; |
| 337 | } |
| 338 | |
Ben Skeggs | cd0b072 | 2010-06-01 15:56:22 +1000 | [diff] [blame] | 339 | if (!nouveau_modeset) |
| 340 | return 0; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 341 | |
Ben Skeggs | cd0b072 | 2010-06-01 15:56:22 +1000 | [diff] [blame] | 342 | nouveau_register_dsm_handler(); |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 343 | return drm_pci_init(&driver, pdrv); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 344 | } |
| 345 | |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 346 | void __exit nouveau_exit(struct pci_driver *pdrv) |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 347 | { |
Ben Skeggs | cd0b072 | 2010-06-01 15:56:22 +1000 | [diff] [blame] | 348 | if (!nouveau_modeset) |
| 349 | return; |
| 350 | |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 351 | drm_pci_exit(&driver, pdrv); |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 352 | nouveau_unregister_dsm_handler(); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 353 | } |