Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 Maarten Maathuis. |
| 3 | * All Rights Reserved. |
| 4 | * |
| 5 | * Permission is hereby granted, free of charge, to any person obtaining |
| 6 | * a copy of this software and associated documentation files (the |
| 7 | * "Software"), to deal in the Software without restriction, including |
| 8 | * without limitation the rights to use, copy, modify, merge, publish, |
| 9 | * distribute, sublicense, and/or sell copies of the Software, and to |
| 10 | * permit persons to whom the Software is furnished to do so, subject to |
| 11 | * the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice (including the |
| 14 | * next paragraph) shall be included in all copies or substantial |
| 15 | * portions of the Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE |
| 21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 24 | * |
| 25 | */ |
| 26 | |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 27 | #include <drm/drmP.h> |
| 28 | #include <drm/drm_crtc_helper.h> |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 29 | |
Ben Skeggs | fdb751e | 2014-08-10 04:10:23 +1000 | [diff] [blame] | 30 | #include <nvif/class.h> |
| 31 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 32 | #include "nouveau_fbcon.h" |
Ben Skeggs | 1a64634 | 2013-03-21 15:45:11 +1000 | [diff] [blame] | 33 | #include "dispnv04/hw.h" |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 34 | #include "nouveau_crtc.h" |
| 35 | #include "nouveau_dma.h" |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 36 | #include "nouveau_gem.h" |
Ben Skeggs | de69185 | 2011-10-17 12:23:41 +1000 | [diff] [blame] | 37 | #include "nouveau_connector.h" |
Ben Skeggs | 45c4e0a | 2011-02-09 11:57:45 +1000 | [diff] [blame] | 38 | #include "nv50_display.h" |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 39 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 40 | #include "nouveau_fence.h" |
| 41 | |
Ben Skeggs | 79ca277 | 2014-08-10 04:10:20 +1000 | [diff] [blame] | 42 | #include <nvif/event.h> |
Ben Skeggs | 1d7c71a | 2013-01-31 09:23:34 +1000 | [diff] [blame] | 43 | |
Ben Skeggs | 51cb4b3 | 2013-10-03 07:02:29 +1000 | [diff] [blame] | 44 | static int |
Ben Skeggs | 80bc340 | 2014-08-10 04:10:28 +1000 | [diff] [blame] | 45 | nouveau_display_vblank_handler(struct nvif_notify *notify) |
Ben Skeggs | 51cb4b3 | 2013-10-03 07:02:29 +1000 | [diff] [blame] | 46 | { |
Ben Skeggs | 79ca277 | 2014-08-10 04:10:20 +1000 | [diff] [blame] | 47 | struct nouveau_crtc *nv_crtc = |
| 48 | container_of(notify, typeof(*nv_crtc), vblank); |
Ben Skeggs | b12f0ae | 2014-08-10 04:10:19 +1000 | [diff] [blame] | 49 | drm_handle_vblank(nv_crtc->base.dev, nv_crtc->index); |
Ben Skeggs | 80bc340 | 2014-08-10 04:10:28 +1000 | [diff] [blame] | 50 | return NVIF_NOTIFY_KEEP; |
Ben Skeggs | 51cb4b3 | 2013-10-03 07:02:29 +1000 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | int |
| 54 | nouveau_display_vblank_enable(struct drm_device *dev, int head) |
| 55 | { |
Ben Skeggs | b12f0ae | 2014-08-10 04:10:19 +1000 | [diff] [blame] | 56 | struct drm_crtc *crtc; |
| 57 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
| 58 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
| 59 | if (nv_crtc->index == head) { |
Ben Skeggs | 80bc340 | 2014-08-10 04:10:28 +1000 | [diff] [blame] | 60 | nvif_notify_get(&nv_crtc->vblank); |
Ben Skeggs | b12f0ae | 2014-08-10 04:10:19 +1000 | [diff] [blame] | 61 | return 0; |
| 62 | } |
Ben Skeggs | 51cb4b3 | 2013-10-03 07:02:29 +1000 | [diff] [blame] | 63 | } |
Ben Skeggs | b12f0ae | 2014-08-10 04:10:19 +1000 | [diff] [blame] | 64 | return -EINVAL; |
Ben Skeggs | 51cb4b3 | 2013-10-03 07:02:29 +1000 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | void |
| 68 | nouveau_display_vblank_disable(struct drm_device *dev, int head) |
| 69 | { |
Ben Skeggs | b12f0ae | 2014-08-10 04:10:19 +1000 | [diff] [blame] | 70 | struct drm_crtc *crtc; |
| 71 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
| 72 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
| 73 | if (nv_crtc->index == head) { |
Ben Skeggs | 80bc340 | 2014-08-10 04:10:28 +1000 | [diff] [blame] | 74 | nvif_notify_put(&nv_crtc->vblank); |
Ben Skeggs | b12f0ae | 2014-08-10 04:10:19 +1000 | [diff] [blame] | 75 | return; |
| 76 | } |
| 77 | } |
Ben Skeggs | 51cb4b3 | 2013-10-03 07:02:29 +1000 | [diff] [blame] | 78 | } |
| 79 | |
Ben Skeggs | d83ef85 | 2013-11-14 13:37:49 +1000 | [diff] [blame] | 80 | static inline int |
| 81 | calc(int blanks, int blanke, int total, int line) |
| 82 | { |
| 83 | if (blanke >= blanks) { |
| 84 | if (line >= blanks) |
| 85 | line -= total; |
| 86 | } else { |
| 87 | if (line >= blanks) |
| 88 | line -= total; |
| 89 | line -= blanke + 1; |
| 90 | } |
| 91 | return line; |
| 92 | } |
| 93 | |
| 94 | int |
| 95 | nouveau_display_scanoutpos_head(struct drm_crtc *crtc, int *vpos, int *hpos, |
| 96 | ktime_t *stime, ktime_t *etime) |
| 97 | { |
Ben Skeggs | 4952b4d | 2014-08-10 04:10:27 +1000 | [diff] [blame] | 98 | struct { |
| 99 | struct nv04_disp_mthd_v0 base; |
| 100 | struct nv04_disp_scanoutpos_v0 scan; |
| 101 | } args = { |
| 102 | .base.method = NV04_DISP_SCANOUTPOS, |
| 103 | .base.head = nouveau_crtc(crtc)->index, |
| 104 | }; |
Ben Skeggs | d83ef85 | 2013-11-14 13:37:49 +1000 | [diff] [blame] | 105 | struct nouveau_display *disp = nouveau_display(crtc->dev); |
Ben Skeggs | d83ef85 | 2013-11-14 13:37:49 +1000 | [diff] [blame] | 106 | int ret, retry = 1; |
| 107 | |
| 108 | do { |
Ben Skeggs | 4952b4d | 2014-08-10 04:10:27 +1000 | [diff] [blame] | 109 | ret = nvif_mthd(&disp->disp, 0, &args, sizeof(args)); |
Ben Skeggs | d83ef85 | 2013-11-14 13:37:49 +1000 | [diff] [blame] | 110 | if (ret != 0) |
| 111 | return 0; |
| 112 | |
Ben Skeggs | 4952b4d | 2014-08-10 04:10:27 +1000 | [diff] [blame] | 113 | if (args.scan.vline) { |
Ben Skeggs | d83ef85 | 2013-11-14 13:37:49 +1000 | [diff] [blame] | 114 | ret |= DRM_SCANOUTPOS_ACCURATE; |
| 115 | ret |= DRM_SCANOUTPOS_VALID; |
| 116 | break; |
| 117 | } |
| 118 | |
| 119 | if (retry) ndelay(crtc->linedur_ns); |
| 120 | } while (retry--); |
| 121 | |
Ben Skeggs | 4952b4d | 2014-08-10 04:10:27 +1000 | [diff] [blame] | 122 | *hpos = args.scan.hline; |
| 123 | *vpos = calc(args.scan.vblanks, args.scan.vblanke, |
| 124 | args.scan.vtotal, args.scan.vline); |
| 125 | if (stime) *stime = ns_to_ktime(args.scan.time[0]); |
| 126 | if (etime) *etime = ns_to_ktime(args.scan.time[1]); |
Ben Skeggs | d83ef85 | 2013-11-14 13:37:49 +1000 | [diff] [blame] | 127 | |
| 128 | if (*vpos < 0) |
Daniel Vetter | 3d3cbd8 | 2014-09-10 17:36:11 +0200 | [diff] [blame] | 129 | ret |= DRM_SCANOUTPOS_IN_VBLANK; |
Ben Skeggs | d83ef85 | 2013-11-14 13:37:49 +1000 | [diff] [blame] | 130 | return ret; |
| 131 | } |
| 132 | |
| 133 | int |
| 134 | nouveau_display_scanoutpos(struct drm_device *dev, int head, unsigned int flags, |
| 135 | int *vpos, int *hpos, ktime_t *stime, ktime_t *etime) |
| 136 | { |
| 137 | struct drm_crtc *crtc; |
| 138 | |
| 139 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
| 140 | if (nouveau_crtc(crtc)->index == head) { |
| 141 | return nouveau_display_scanoutpos_head(crtc, vpos, hpos, |
| 142 | stime, etime); |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | return 0; |
| 147 | } |
| 148 | |
| 149 | int |
| 150 | nouveau_display_vblstamp(struct drm_device *dev, int head, int *max_error, |
| 151 | struct timeval *time, unsigned flags) |
| 152 | { |
| 153 | struct drm_crtc *crtc; |
| 154 | |
| 155 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
| 156 | if (nouveau_crtc(crtc)->index == head) { |
| 157 | return drm_calc_vbltimestamp_from_scanoutpos(dev, |
| 158 | head, max_error, time, flags, crtc, |
| 159 | &crtc->hwmode); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | return -EINVAL; |
| 164 | } |
| 165 | |
Ben Skeggs | 51cb4b3 | 2013-10-03 07:02:29 +1000 | [diff] [blame] | 166 | static void |
| 167 | nouveau_display_vblank_fini(struct drm_device *dev) |
| 168 | { |
Ben Skeggs | b12f0ae | 2014-08-10 04:10:19 +1000 | [diff] [blame] | 169 | struct drm_crtc *crtc; |
Ben Skeggs | 51cb4b3 | 2013-10-03 07:02:29 +1000 | [diff] [blame] | 170 | |
Ben Skeggs | 1139ffb | 2014-01-23 10:49:47 +1000 | [diff] [blame] | 171 | drm_vblank_cleanup(dev); |
| 172 | |
Ben Skeggs | b12f0ae | 2014-08-10 04:10:19 +1000 | [diff] [blame] | 173 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
| 174 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
Ben Skeggs | 80bc340 | 2014-08-10 04:10:28 +1000 | [diff] [blame] | 175 | nvif_notify_fini(&nv_crtc->vblank); |
Ben Skeggs | 51cb4b3 | 2013-10-03 07:02:29 +1000 | [diff] [blame] | 176 | } |
Ben Skeggs | 51cb4b3 | 2013-10-03 07:02:29 +1000 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | static int |
| 180 | nouveau_display_vblank_init(struct drm_device *dev) |
| 181 | { |
| 182 | struct nouveau_display *disp = nouveau_display(dev); |
Ben Skeggs | b12f0ae | 2014-08-10 04:10:19 +1000 | [diff] [blame] | 183 | struct drm_crtc *crtc; |
| 184 | int ret; |
Ben Skeggs | 51cb4b3 | 2013-10-03 07:02:29 +1000 | [diff] [blame] | 185 | |
Ben Skeggs | b12f0ae | 2014-08-10 04:10:19 +1000 | [diff] [blame] | 186 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
| 187 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
Ben Skeggs | 80bc340 | 2014-08-10 04:10:28 +1000 | [diff] [blame] | 188 | ret = nvif_notify_init(&disp->disp, NULL, |
Ben Skeggs | 79ca277 | 2014-08-10 04:10:20 +1000 | [diff] [blame] | 189 | nouveau_display_vblank_handler, false, |
Ben Skeggs | 80bc340 | 2014-08-10 04:10:28 +1000 | [diff] [blame] | 190 | NV04_DISP_NTFY_VBLANK, |
Ben Skeggs | 79ca277 | 2014-08-10 04:10:20 +1000 | [diff] [blame] | 191 | &(struct nvif_notify_head_req_v0) { |
| 192 | .head = nv_crtc->index, |
| 193 | }, |
| 194 | sizeof(struct nvif_notify_head_req_v0), |
| 195 | sizeof(struct nvif_notify_head_rep_v0), |
| 196 | &nv_crtc->vblank); |
Ben Skeggs | 51cb4b3 | 2013-10-03 07:02:29 +1000 | [diff] [blame] | 197 | if (ret) { |
| 198 | nouveau_display_vblank_fini(dev); |
| 199 | return ret; |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | ret = drm_vblank_init(dev, dev->mode_config.num_crtc); |
| 204 | if (ret) { |
| 205 | nouveau_display_vblank_fini(dev); |
| 206 | return ret; |
| 207 | } |
| 208 | |
| 209 | return 0; |
| 210 | } |
| 211 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 212 | static void |
| 213 | nouveau_user_framebuffer_destroy(struct drm_framebuffer *drm_fb) |
| 214 | { |
| 215 | struct nouveau_framebuffer *fb = nouveau_framebuffer(drm_fb); |
Ben Skeggs | ab0af55 | 2014-08-10 04:10:19 +1000 | [diff] [blame] | 216 | struct nouveau_display *disp = nouveau_display(drm_fb->dev); |
| 217 | |
| 218 | if (disp->fb_dtor) |
| 219 | disp->fb_dtor(drm_fb); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 220 | |
Luca Barbieri | bc9025b | 2010-02-09 05:49:12 +0000 | [diff] [blame] | 221 | if (fb->nvbo) |
David Herrmann | 55fb74a | 2013-10-02 10:15:17 +0200 | [diff] [blame] | 222 | drm_gem_object_unreference_unlocked(&fb->nvbo->gem); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 223 | |
| 224 | drm_framebuffer_cleanup(drm_fb); |
| 225 | kfree(fb); |
| 226 | } |
| 227 | |
| 228 | static int |
| 229 | nouveau_user_framebuffer_create_handle(struct drm_framebuffer *drm_fb, |
| 230 | struct drm_file *file_priv, |
| 231 | unsigned int *handle) |
| 232 | { |
| 233 | struct nouveau_framebuffer *fb = nouveau_framebuffer(drm_fb); |
| 234 | |
David Herrmann | 55fb74a | 2013-10-02 10:15:17 +0200 | [diff] [blame] | 235 | return drm_gem_handle_create(file_priv, &fb->nvbo->gem, handle); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | static const struct drm_framebuffer_funcs nouveau_framebuffer_funcs = { |
| 239 | .destroy = nouveau_user_framebuffer_destroy, |
| 240 | .create_handle = nouveau_user_framebuffer_create_handle, |
| 241 | }; |
| 242 | |
Dave Airlie | 3865167 | 2010-03-30 05:34:13 +0000 | [diff] [blame] | 243 | int |
Ben Skeggs | 45c4e0a | 2011-02-09 11:57:45 +1000 | [diff] [blame] | 244 | nouveau_framebuffer_init(struct drm_device *dev, |
| 245 | struct nouveau_framebuffer *nv_fb, |
Jesse Barnes | 308e5bc | 2011-11-14 14:51:28 -0800 | [diff] [blame] | 246 | struct drm_mode_fb_cmd2 *mode_cmd, |
Ben Skeggs | 45c4e0a | 2011-02-09 11:57:45 +1000 | [diff] [blame] | 247 | struct nouveau_bo *nvbo) |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 248 | { |
Ben Skeggs | ab0af55 | 2014-08-10 04:10:19 +1000 | [diff] [blame] | 249 | struct nouveau_display *disp = nouveau_display(dev); |
Ben Skeggs | 45c4e0a | 2011-02-09 11:57:45 +1000 | [diff] [blame] | 250 | struct drm_framebuffer *fb = &nv_fb->base; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 251 | int ret; |
| 252 | |
Ben Skeggs | 45c4e0a | 2011-02-09 11:57:45 +1000 | [diff] [blame] | 253 | drm_helper_mode_fill_fb_struct(fb, mode_cmd); |
| 254 | nv_fb->nvbo = nvbo; |
| 255 | |
Daniel Vetter | c7d73f6 | 2012-12-13 23:38:38 +0100 | [diff] [blame] | 256 | ret = drm_framebuffer_init(dev, fb, &nouveau_framebuffer_funcs); |
Ben Skeggs | ab0af55 | 2014-08-10 04:10:19 +1000 | [diff] [blame] | 257 | if (ret) |
Daniel Vetter | c7d73f6 | 2012-12-13 23:38:38 +0100 | [diff] [blame] | 258 | return ret; |
Ben Skeggs | ab0af55 | 2014-08-10 04:10:19 +1000 | [diff] [blame] | 259 | |
| 260 | if (disp->fb_ctor) { |
| 261 | ret = disp->fb_ctor(fb); |
| 262 | if (ret) |
| 263 | disp->fb_dtor(fb); |
Daniel Vetter | c7d73f6 | 2012-12-13 23:38:38 +0100 | [diff] [blame] | 264 | } |
| 265 | |
Ben Skeggs | ab0af55 | 2014-08-10 04:10:19 +1000 | [diff] [blame] | 266 | return ret; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | static struct drm_framebuffer * |
| 270 | nouveau_user_framebuffer_create(struct drm_device *dev, |
| 271 | struct drm_file *file_priv, |
Jesse Barnes | 308e5bc | 2011-11-14 14:51:28 -0800 | [diff] [blame] | 272 | struct drm_mode_fb_cmd2 *mode_cmd) |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 273 | { |
Dave Airlie | 3865167 | 2010-03-30 05:34:13 +0000 | [diff] [blame] | 274 | struct nouveau_framebuffer *nouveau_fb; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 275 | struct drm_gem_object *gem; |
Maarten Lankhorst | fdfb833 | 2013-07-08 14:50:54 +1000 | [diff] [blame] | 276 | int ret = -ENOMEM; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 277 | |
Jesse Barnes | 308e5bc | 2011-11-14 14:51:28 -0800 | [diff] [blame] | 278 | gem = drm_gem_object_lookup(dev, file_priv, mode_cmd->handles[0]); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 279 | if (!gem) |
Chris Wilson | cce13ff | 2010-08-08 13:36:38 +0100 | [diff] [blame] | 280 | return ERR_PTR(-ENOENT); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 281 | |
Dave Airlie | 3865167 | 2010-03-30 05:34:13 +0000 | [diff] [blame] | 282 | nouveau_fb = kzalloc(sizeof(struct nouveau_framebuffer), GFP_KERNEL); |
| 283 | if (!nouveau_fb) |
Maarten Lankhorst | fdfb833 | 2013-07-08 14:50:54 +1000 | [diff] [blame] | 284 | goto err_unref; |
Dave Airlie | 3865167 | 2010-03-30 05:34:13 +0000 | [diff] [blame] | 285 | |
| 286 | ret = nouveau_framebuffer_init(dev, nouveau_fb, mode_cmd, nouveau_gem_object(gem)); |
Maarten Lankhorst | fdfb833 | 2013-07-08 14:50:54 +1000 | [diff] [blame] | 287 | if (ret) |
| 288 | goto err; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 289 | |
Dave Airlie | 3865167 | 2010-03-30 05:34:13 +0000 | [diff] [blame] | 290 | return &nouveau_fb->base; |
Maarten Lankhorst | fdfb833 | 2013-07-08 14:50:54 +1000 | [diff] [blame] | 291 | |
| 292 | err: |
| 293 | kfree(nouveau_fb); |
| 294 | err_unref: |
| 295 | drm_gem_object_unreference(gem); |
| 296 | return ERR_PTR(ret); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 297 | } |
| 298 | |
Ben Skeggs | 27d5030 | 2011-10-06 12:46:40 +1000 | [diff] [blame] | 299 | static const struct drm_mode_config_funcs nouveau_mode_config_funcs = { |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 300 | .fb_create = nouveau_user_framebuffer_create, |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 301 | .output_poll_changed = nouveau_fbcon_output_poll_changed, |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 302 | }; |
| 303 | |
Ben Skeggs | b29caa5 | 2011-10-06 13:29:05 +1000 | [diff] [blame] | 304 | |
Sascha Hauer | 4a67d39 | 2012-02-06 10:58:17 +0100 | [diff] [blame] | 305 | struct nouveau_drm_prop_enum_list { |
Ben Skeggs | de69185 | 2011-10-17 12:23:41 +1000 | [diff] [blame] | 306 | u8 gen_mask; |
Ben Skeggs | b29caa5 | 2011-10-06 13:29:05 +1000 | [diff] [blame] | 307 | int type; |
| 308 | char *name; |
| 309 | }; |
| 310 | |
Sascha Hauer | 4a67d39 | 2012-02-06 10:58:17 +0100 | [diff] [blame] | 311 | static struct nouveau_drm_prop_enum_list underscan[] = { |
Ben Skeggs | 9285462 | 2011-11-11 23:49:06 +1000 | [diff] [blame] | 312 | { 6, UNDERSCAN_AUTO, "auto" }, |
| 313 | { 6, UNDERSCAN_OFF, "off" }, |
| 314 | { 6, UNDERSCAN_ON, "on" }, |
Ben Skeggs | de69185 | 2011-10-17 12:23:41 +1000 | [diff] [blame] | 315 | {} |
Ben Skeggs | b29caa5 | 2011-10-06 13:29:05 +1000 | [diff] [blame] | 316 | }; |
| 317 | |
Sascha Hauer | 4a67d39 | 2012-02-06 10:58:17 +0100 | [diff] [blame] | 318 | static struct nouveau_drm_prop_enum_list dither_mode[] = { |
Ben Skeggs | de69185 | 2011-10-17 12:23:41 +1000 | [diff] [blame] | 319 | { 7, DITHERING_MODE_AUTO, "auto" }, |
| 320 | { 7, DITHERING_MODE_OFF, "off" }, |
| 321 | { 1, DITHERING_MODE_ON, "on" }, |
| 322 | { 6, DITHERING_MODE_STATIC2X2, "static 2x2" }, |
| 323 | { 6, DITHERING_MODE_DYNAMIC2X2, "dynamic 2x2" }, |
| 324 | { 4, DITHERING_MODE_TEMPORAL, "temporal" }, |
| 325 | {} |
| 326 | }; |
| 327 | |
Sascha Hauer | 4a67d39 | 2012-02-06 10:58:17 +0100 | [diff] [blame] | 328 | static struct nouveau_drm_prop_enum_list dither_depth[] = { |
Ben Skeggs | de69185 | 2011-10-17 12:23:41 +1000 | [diff] [blame] | 329 | { 6, DITHERING_DEPTH_AUTO, "auto" }, |
| 330 | { 6, DITHERING_DEPTH_6BPC, "6 bpc" }, |
| 331 | { 6, DITHERING_DEPTH_8BPC, "8 bpc" }, |
| 332 | {} |
| 333 | }; |
| 334 | |
| 335 | #define PROP_ENUM(p,gen,n,list) do { \ |
Sascha Hauer | 4a67d39 | 2012-02-06 10:58:17 +0100 | [diff] [blame] | 336 | struct nouveau_drm_prop_enum_list *l = (list); \ |
Ben Skeggs | de69185 | 2011-10-17 12:23:41 +1000 | [diff] [blame] | 337 | int c = 0; \ |
| 338 | while (l->gen_mask) { \ |
| 339 | if (l->gen_mask & (1 << (gen))) \ |
| 340 | c++; \ |
| 341 | l++; \ |
| 342 | } \ |
| 343 | if (c) { \ |
| 344 | p = drm_property_create(dev, DRM_MODE_PROP_ENUM, n, c); \ |
| 345 | l = (list); \ |
| 346 | c = 0; \ |
| 347 | while (p && l->gen_mask) { \ |
| 348 | if (l->gen_mask & (1 << (gen))) { \ |
| 349 | drm_property_add_enum(p, c, l->type, l->name); \ |
| 350 | c++; \ |
| 351 | } \ |
| 352 | l++; \ |
| 353 | } \ |
| 354 | } \ |
| 355 | } while(0) |
| 356 | |
Francisco Jerez | 042206c | 2010-10-21 18:19:29 +0200 | [diff] [blame] | 357 | int |
Ben Skeggs | f62b27d | 2011-11-09 15:18:47 +1000 | [diff] [blame] | 358 | nouveau_display_init(struct drm_device *dev) |
| 359 | { |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 360 | struct nouveau_display *disp = nouveau_display(dev); |
Ben Skeggs | 52c4d76 | 2011-11-24 12:59:44 +1000 | [diff] [blame] | 361 | struct drm_connector *connector; |
Ben Skeggs | f62b27d | 2011-11-09 15:18:47 +1000 | [diff] [blame] | 362 | int ret; |
| 363 | |
| 364 | ret = disp->init(dev); |
Ben Skeggs | 52c4d76 | 2011-11-24 12:59:44 +1000 | [diff] [blame] | 365 | if (ret) |
| 366 | return ret; |
| 367 | |
Ben Skeggs | 7df898b | 2012-01-31 09:16:59 +1000 | [diff] [blame] | 368 | /* enable polling for external displays */ |
Ben Skeggs | 52c4d76 | 2011-11-24 12:59:44 +1000 | [diff] [blame] | 369 | drm_kms_helper_poll_enable(dev); |
| 370 | |
| 371 | /* enable hotplug interrupts */ |
| 372 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 373 | struct nouveau_connector *conn = nouveau_connector(connector); |
Ben Skeggs | 80bc340 | 2014-08-10 04:10:28 +1000 | [diff] [blame] | 374 | nvif_notify_get(&conn->hpd); |
Ben Skeggs | f62b27d | 2011-11-09 15:18:47 +1000 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | return ret; |
| 378 | } |
| 379 | |
| 380 | void |
| 381 | nouveau_display_fini(struct drm_device *dev) |
| 382 | { |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 383 | struct nouveau_display *disp = nouveau_display(dev); |
Ben Skeggs | 52c4d76 | 2011-11-24 12:59:44 +1000 | [diff] [blame] | 384 | struct drm_connector *connector; |
Mario Kleiner | 9cba5ef | 2014-07-29 02:36:44 +0200 | [diff] [blame] | 385 | int head; |
| 386 | |
| 387 | /* Make sure that drm and hw vblank irqs get properly disabled. */ |
| 388 | for (head = 0; head < dev->mode_config.num_crtc; head++) |
| 389 | drm_vblank_off(dev, head); |
Ben Skeggs | 52c4d76 | 2011-11-24 12:59:44 +1000 | [diff] [blame] | 390 | |
| 391 | /* disable hotplug interrupts */ |
| 392 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
| 393 | struct nouveau_connector *conn = nouveau_connector(connector); |
Ben Skeggs | 80bc340 | 2014-08-10 04:10:28 +1000 | [diff] [blame] | 394 | nvif_notify_put(&conn->hpd); |
Ben Skeggs | 52c4d76 | 2011-11-24 12:59:44 +1000 | [diff] [blame] | 395 | } |
Ben Skeggs | f62b27d | 2011-11-09 15:18:47 +1000 | [diff] [blame] | 396 | |
| 397 | drm_kms_helper_poll_disable(dev); |
| 398 | disp->fini(dev); |
| 399 | } |
| 400 | |
Ben Skeggs | 9c210f3 | 2014-08-10 04:10:21 +1000 | [diff] [blame] | 401 | static void |
| 402 | nouveau_display_create_properties(struct drm_device *dev) |
Ben Skeggs | 27d5030 | 2011-10-06 12:46:40 +1000 | [diff] [blame] | 403 | { |
Ben Skeggs | 9c210f3 | 2014-08-10 04:10:21 +1000 | [diff] [blame] | 404 | struct nouveau_display *disp = nouveau_display(dev); |
| 405 | int gen; |
Ben Skeggs | 27d5030 | 2011-10-06 12:46:40 +1000 | [diff] [blame] | 406 | |
Ben Skeggs | 648d4df | 2014-08-10 04:10:27 +1000 | [diff] [blame] | 407 | if (disp->disp.oclass < NV50_DISP) |
Ben Skeggs | de69185 | 2011-10-17 12:23:41 +1000 | [diff] [blame] | 408 | gen = 0; |
| 409 | else |
Ben Skeggs | 648d4df | 2014-08-10 04:10:27 +1000 | [diff] [blame] | 410 | if (disp->disp.oclass < GF110_DISP) |
Ben Skeggs | de69185 | 2011-10-17 12:23:41 +1000 | [diff] [blame] | 411 | gen = 1; |
| 412 | else |
| 413 | gen = 2; |
| 414 | |
| 415 | PROP_ENUM(disp->dithering_mode, gen, "dithering mode", dither_mode); |
| 416 | PROP_ENUM(disp->dithering_depth, gen, "dithering depth", dither_depth); |
| 417 | PROP_ENUM(disp->underscan_property, gen, "underscan", underscan); |
Ben Skeggs | b29caa5 | 2011-10-06 13:29:05 +1000 | [diff] [blame] | 418 | |
| 419 | disp->underscan_hborder_property = |
Sascha Hauer | d9bc3c0 | 2012-02-06 10:58:18 +0100 | [diff] [blame] | 420 | drm_property_create_range(dev, 0, "underscan hborder", 0, 128); |
Ben Skeggs | b29caa5 | 2011-10-06 13:29:05 +1000 | [diff] [blame] | 421 | |
| 422 | disp->underscan_vborder_property = |
Sascha Hauer | d9bc3c0 | 2012-02-06 10:58:18 +0100 | [diff] [blame] | 423 | drm_property_create_range(dev, 0, "underscan vborder", 0, 128); |
Ben Skeggs | b29caa5 | 2011-10-06 13:29:05 +1000 | [diff] [blame] | 424 | |
Ben Skeggs | 9c210f3 | 2014-08-10 04:10:21 +1000 | [diff] [blame] | 425 | if (gen < 1) |
| 426 | return; |
Christoph Bumiller | df26bc9 | 2012-01-21 23:13:26 +0100 | [diff] [blame] | 427 | |
Ben Skeggs | 9c210f3 | 2014-08-10 04:10:21 +1000 | [diff] [blame] | 428 | /* -90..+90 */ |
| 429 | disp->vibrant_hue_property = |
| 430 | drm_property_create_range(dev, 0, "vibrant hue", 0, 180); |
| 431 | |
| 432 | /* -100..+100 */ |
| 433 | disp->color_vibrance_property = |
| 434 | drm_property_create_range(dev, 0, "color vibrance", 0, 200); |
| 435 | } |
| 436 | |
| 437 | int |
| 438 | nouveau_display_create(struct drm_device *dev) |
| 439 | { |
| 440 | struct nouveau_drm *drm = nouveau_drm(dev); |
Ben Skeggs | 9c210f3 | 2014-08-10 04:10:21 +1000 | [diff] [blame] | 441 | struct nouveau_display *disp; |
| 442 | int ret; |
| 443 | |
| 444 | disp = drm->display = kzalloc(sizeof(*disp), GFP_KERNEL); |
| 445 | if (!disp) |
| 446 | return -ENOMEM; |
| 447 | |
| 448 | drm_mode_config_init(dev); |
| 449 | drm_mode_create_scaling_mode_property(dev); |
| 450 | drm_mode_create_dvi_i_properties(dev); |
Christoph Bumiller | df26bc9 | 2012-01-21 23:13:26 +0100 | [diff] [blame] | 451 | |
Laurent Pinchart | e6ecefa | 2012-05-17 13:27:23 +0200 | [diff] [blame] | 452 | dev->mode_config.funcs = &nouveau_mode_config_funcs; |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 453 | dev->mode_config.fb_base = nv_device_resource_start(nvkm_device(&drm->device), 1); |
Ben Skeggs | 27d5030 | 2011-10-06 12:46:40 +1000 | [diff] [blame] | 454 | |
| 455 | dev->mode_config.min_width = 0; |
| 456 | dev->mode_config.min_height = 0; |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 457 | if (drm->device.info.family < NV_DEVICE_INFO_V0_CELSIUS) { |
Ben Skeggs | 27d5030 | 2011-10-06 12:46:40 +1000 | [diff] [blame] | 458 | dev->mode_config.max_width = 2048; |
| 459 | dev->mode_config.max_height = 2048; |
| 460 | } else |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 461 | if (drm->device.info.family < NV_DEVICE_INFO_V0_TESLA) { |
Ben Skeggs | 27d5030 | 2011-10-06 12:46:40 +1000 | [diff] [blame] | 462 | dev->mode_config.max_width = 4096; |
| 463 | dev->mode_config.max_height = 4096; |
| 464 | } else { |
| 465 | dev->mode_config.max_width = 8192; |
| 466 | dev->mode_config.max_height = 8192; |
| 467 | } |
| 468 | |
Dave Airlie | f137799 | 2012-02-20 14:39:11 +0000 | [diff] [blame] | 469 | dev->mode_config.preferred_depth = 24; |
| 470 | dev->mode_config.prefer_shadow = 1; |
| 471 | |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 472 | if (drm->device.info.chipset < 0x11) |
Ben Skeggs | b9d9dcd | 2013-11-11 13:59:40 +1000 | [diff] [blame] | 473 | dev->mode_config.async_page_flip = false; |
| 474 | else |
| 475 | dev->mode_config.async_page_flip = true; |
| 476 | |
Ben Skeggs | f62b27d | 2011-11-09 15:18:47 +1000 | [diff] [blame] | 477 | drm_kms_helper_poll_init(dev); |
| 478 | drm_kms_helper_poll_disable(dev); |
| 479 | |
Ben Skeggs | 771fa0e | 2014-08-10 04:10:31 +1000 | [diff] [blame] | 480 | if (nouveau_modeset != 2 && drm->vbios.dcb.entries) { |
Ben Skeggs | 2332b31 | 2014-01-22 12:58:12 +1000 | [diff] [blame] | 481 | static const u16 oclass[] = { |
Ben Skeggs | 648d4df | 2014-08-10 04:10:27 +1000 | [diff] [blame] | 482 | GM107_DISP, |
| 483 | GK110_DISP, |
| 484 | GK104_DISP, |
| 485 | GF110_DISP, |
| 486 | GT214_DISP, |
| 487 | GT206_DISP, |
| 488 | GT200_DISP, |
| 489 | G82_DISP, |
| 490 | NV50_DISP, |
| 491 | NV04_DISP, |
Ben Skeggs | 2332b31 | 2014-01-22 12:58:12 +1000 | [diff] [blame] | 492 | }; |
| 493 | int i; |
| 494 | |
| 495 | for (i = 0, ret = -ENODEV; ret && i < ARRAY_SIZE(oclass); i++) { |
Ben Skeggs | 0ad7286 | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 496 | ret = nvif_object_init(nvif_object(&drm->device), NULL, |
| 497 | NVDRM_DISPLAY, oclass[i], |
| 498 | NULL, 0, &disp->disp); |
Ben Skeggs | 2332b31 | 2014-01-22 12:58:12 +1000 | [diff] [blame] | 499 | } |
| 500 | |
| 501 | if (ret == 0) { |
Ben Skeggs | 9c210f3 | 2014-08-10 04:10:21 +1000 | [diff] [blame] | 502 | nouveau_display_create_properties(dev); |
Ben Skeggs | 648d4df | 2014-08-10 04:10:27 +1000 | [diff] [blame] | 503 | if (disp->disp.oclass < NV50_DISP) |
Ben Skeggs | 2332b31 | 2014-01-22 12:58:12 +1000 | [diff] [blame] | 504 | ret = nv04_display_create(dev); |
| 505 | else |
| 506 | ret = nv50_display_create(dev); |
| 507 | } |
Ben Skeggs | fc16208 | 2013-09-10 13:20:34 +1000 | [diff] [blame] | 508 | } else { |
| 509 | ret = 0; |
Ben Skeggs | f62b27d | 2011-11-09 15:18:47 +1000 | [diff] [blame] | 510 | } |
| 511 | |
Ben Skeggs | fc16208 | 2013-09-10 13:20:34 +1000 | [diff] [blame] | 512 | if (ret) |
| 513 | goto disp_create_err; |
| 514 | |
| 515 | if (dev->mode_config.num_crtc) { |
Ben Skeggs | 51cb4b3 | 2013-10-03 07:02:29 +1000 | [diff] [blame] | 516 | ret = nouveau_display_vblank_init(dev); |
Ben Skeggs | fc16208 | 2013-09-10 13:20:34 +1000 | [diff] [blame] | 517 | if (ret) |
| 518 | goto vblank_err; |
| 519 | } |
| 520 | |
| 521 | nouveau_backlight_init(dev); |
Marcin Slusarz | 5ace2c9 | 2012-04-15 14:36:08 +0200 | [diff] [blame] | 522 | return 0; |
| 523 | |
| 524 | vblank_err: |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 525 | disp->dtor(dev); |
Marcin Slusarz | 5ace2c9 | 2012-04-15 14:36:08 +0200 | [diff] [blame] | 526 | disp_create_err: |
| 527 | drm_kms_helper_poll_fini(dev); |
| 528 | drm_mode_config_cleanup(dev); |
Ben Skeggs | 2a44e49 | 2011-11-09 11:36:33 +1000 | [diff] [blame] | 529 | return ret; |
Ben Skeggs | 27d5030 | 2011-10-06 12:46:40 +1000 | [diff] [blame] | 530 | } |
| 531 | |
| 532 | void |
| 533 | nouveau_display_destroy(struct drm_device *dev) |
| 534 | { |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 535 | struct nouveau_display *disp = nouveau_display(dev); |
Ben Skeggs | 27d5030 | 2011-10-06 12:46:40 +1000 | [diff] [blame] | 536 | |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 537 | nouveau_backlight_exit(dev); |
Ben Skeggs | 51cb4b3 | 2013-10-03 07:02:29 +1000 | [diff] [blame] | 538 | nouveau_display_vblank_fini(dev); |
Ben Skeggs | f62b27d | 2011-11-09 15:18:47 +1000 | [diff] [blame] | 539 | |
Ben Skeggs | d6bf2f3 | 2012-10-30 10:59:12 +1000 | [diff] [blame] | 540 | drm_kms_helper_poll_fini(dev); |
| 541 | drm_mode_config_cleanup(dev); |
| 542 | |
Ben Skeggs | 9430738 | 2012-10-31 12:11:15 +1000 | [diff] [blame] | 543 | if (disp->dtor) |
| 544 | disp->dtor(dev); |
Ben Skeggs | f62b27d | 2011-11-09 15:18:47 +1000 | [diff] [blame] | 545 | |
Ben Skeggs | 0ad7286 | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 546 | nvif_object_fini(&disp->disp); |
Ben Skeggs | 2332b31 | 2014-01-22 12:58:12 +1000 | [diff] [blame] | 547 | |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 548 | nouveau_drm(dev)->display = NULL; |
| 549 | kfree(disp); |
| 550 | } |
| 551 | |
| 552 | int |
| 553 | nouveau_display_suspend(struct drm_device *dev) |
| 554 | { |
| 555 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 556 | struct drm_crtc *crtc; |
| 557 | |
| 558 | nouveau_display_fini(dev); |
| 559 | |
Ben Skeggs | c52f4fa | 2013-11-08 14:38:40 +1000 | [diff] [blame] | 560 | NV_INFO(drm, "unpinning framebuffer(s)...\n"); |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 561 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
| 562 | struct nouveau_framebuffer *nouveau_fb; |
| 563 | |
Matt Roper | f4510a2 | 2014-04-01 15:22:40 -0700 | [diff] [blame] | 564 | nouveau_fb = nouveau_framebuffer(crtc->primary->fb); |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 565 | if (!nouveau_fb || !nouveau_fb->nvbo) |
| 566 | continue; |
| 567 | |
| 568 | nouveau_bo_unpin(nouveau_fb->nvbo); |
| 569 | } |
| 570 | |
| 571 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
| 572 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
| 573 | |
| 574 | nouveau_bo_unmap(nv_crtc->cursor.nvbo); |
| 575 | nouveau_bo_unpin(nv_crtc->cursor.nvbo); |
| 576 | } |
| 577 | |
| 578 | return 0; |
| 579 | } |
| 580 | |
| 581 | void |
Dave Airlie | 5addcf0 | 2012-09-10 14:20:51 +1000 | [diff] [blame] | 582 | nouveau_display_repin(struct drm_device *dev) |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 583 | { |
| 584 | struct nouveau_drm *drm = nouveau_drm(dev); |
| 585 | struct drm_crtc *crtc; |
| 586 | int ret; |
| 587 | |
| 588 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
| 589 | struct nouveau_framebuffer *nouveau_fb; |
| 590 | |
Matt Roper | f4510a2 | 2014-04-01 15:22:40 -0700 | [diff] [blame] | 591 | nouveau_fb = nouveau_framebuffer(crtc->primary->fb); |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 592 | if (!nouveau_fb || !nouveau_fb->nvbo) |
| 593 | continue; |
| 594 | |
Ben Skeggs | c9a6fd9 | 2014-08-12 23:35:35 +1000 | [diff] [blame] | 595 | ret = nouveau_bo_pin(nouveau_fb->nvbo, TTM_PL_FLAG_VRAM); |
| 596 | if (ret) |
| 597 | NV_ERROR(drm, "Could not pin framebuffer\n"); |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 598 | } |
| 599 | |
| 600 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
| 601 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
| 602 | |
| 603 | ret = nouveau_bo_pin(nv_crtc->cursor.nvbo, TTM_PL_FLAG_VRAM); |
| 604 | if (!ret) |
| 605 | ret = nouveau_bo_map(nv_crtc->cursor.nvbo); |
| 606 | if (ret) |
| 607 | NV_ERROR(drm, "Could not pin/map cursor.\n"); |
| 608 | } |
Dave Airlie | 5addcf0 | 2012-09-10 14:20:51 +1000 | [diff] [blame] | 609 | } |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 610 | |
Dave Airlie | 5addcf0 | 2012-09-10 14:20:51 +1000 | [diff] [blame] | 611 | void |
| 612 | nouveau_display_resume(struct drm_device *dev) |
| 613 | { |
| 614 | struct drm_crtc *crtc; |
Mario Kleiner | 9cba5ef | 2014-07-29 02:36:44 +0200 | [diff] [blame] | 615 | int head; |
| 616 | |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 617 | nouveau_display_init(dev); |
| 618 | |
| 619 | /* Force CLUT to get re-loaded during modeset */ |
| 620 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
| 621 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
| 622 | |
| 623 | nv_crtc->lut.depth = 0; |
| 624 | } |
| 625 | |
Mario Kleiner | 9cba5ef | 2014-07-29 02:36:44 +0200 | [diff] [blame] | 626 | /* Make sure that drm and hw vblank irqs get resumed if needed. */ |
| 627 | for (head = 0; head < dev->mode_config.num_crtc; head++) |
| 628 | drm_vblank_on(dev, head); |
| 629 | |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 630 | drm_helper_resume_force_mode(dev); |
| 631 | |
| 632 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
| 633 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
| 634 | u32 offset = nv_crtc->cursor.nvbo->bo.offset; |
| 635 | |
| 636 | nv_crtc->cursor.set_offset(nv_crtc, offset); |
| 637 | nv_crtc->cursor.set_pos(nv_crtc, nv_crtc->cursor_saved_x, |
| 638 | nv_crtc->cursor_saved_y); |
| 639 | } |
Ben Skeggs | 27d5030 | 2011-10-06 12:46:40 +1000 | [diff] [blame] | 640 | } |
| 641 | |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 642 | static int |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 643 | nouveau_page_flip_emit(struct nouveau_channel *chan, |
| 644 | struct nouveau_bo *old_bo, |
| 645 | struct nouveau_bo *new_bo, |
| 646 | struct nouveau_page_flip_state *s, |
| 647 | struct nouveau_fence **pfence) |
| 648 | { |
Ben Skeggs | f589be8 | 2012-07-22 11:55:54 +1000 | [diff] [blame] | 649 | struct nouveau_fence_chan *fctx = chan->fence; |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 650 | struct nouveau_drm *drm = chan->drm; |
| 651 | struct drm_device *dev = drm->dev; |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 652 | unsigned long flags; |
| 653 | int ret; |
| 654 | |
| 655 | /* Queue it to the pending list */ |
| 656 | spin_lock_irqsave(&dev->event_lock, flags); |
Ben Skeggs | f589be8 | 2012-07-22 11:55:54 +1000 | [diff] [blame] | 657 | list_add_tail(&s->head, &fctx->flip); |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 658 | spin_unlock_irqrestore(&dev->event_lock, flags); |
| 659 | |
| 660 | /* Synchronize with the old framebuffer */ |
Maarten Lankhorst | e3be4c2 | 2014-09-16 11:15:07 +0200 | [diff] [blame^] | 661 | ret = nouveau_fence_sync(old_bo, chan, false, false); |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 662 | if (ret) |
| 663 | goto fail; |
| 664 | |
| 665 | /* Emit the pageflip */ |
Ben Skeggs | 1e303c0 | 2013-11-13 10:49:46 +1000 | [diff] [blame] | 666 | ret = RING_SPACE(chan, 2); |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 667 | if (ret) |
| 668 | goto fail; |
| 669 | |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 670 | if (drm->device.info.family < NV_DEVICE_INFO_V0_FERMI) |
Ben Skeggs | 6d59702 | 2012-04-01 21:09:13 +1000 | [diff] [blame] | 671 | BEGIN_NV04(chan, NvSubSw, NV_SW_PAGE_FLIP, 1); |
Ben Skeggs | 1e303c0 | 2013-11-13 10:49:46 +1000 | [diff] [blame] | 672 | else |
| 673 | BEGIN_NVC0(chan, FermiSw, NV_SW_PAGE_FLIP, 1); |
| 674 | OUT_RING (chan, 0x00000000); |
Ben Skeggs | bd2f203 | 2011-02-08 15:16:23 +1000 | [diff] [blame] | 675 | FIRE_RING (chan); |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 676 | |
Ben Skeggs | 264ce19 | 2013-02-14 13:43:21 +1000 | [diff] [blame] | 677 | ret = nouveau_fence_new(chan, false, pfence); |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 678 | if (ret) |
| 679 | goto fail; |
| 680 | |
| 681 | return 0; |
| 682 | fail: |
| 683 | spin_lock_irqsave(&dev->event_lock, flags); |
| 684 | list_del(&s->head); |
| 685 | spin_unlock_irqrestore(&dev->event_lock, flags); |
| 686 | return ret; |
| 687 | } |
| 688 | |
| 689 | int |
| 690 | nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb, |
Ben Skeggs | b9d9dcd | 2013-11-11 13:59:40 +1000 | [diff] [blame] | 691 | struct drm_pending_vblank_event *event, u32 flags) |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 692 | { |
Ben Skeggs | b9d9dcd | 2013-11-11 13:59:40 +1000 | [diff] [blame] | 693 | const int swap_interval = (flags & DRM_MODE_PAGE_FLIP_ASYNC) ? 0 : 1; |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 694 | struct drm_device *dev = crtc->dev; |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 695 | struct nouveau_drm *drm = nouveau_drm(dev); |
Matt Roper | f4510a2 | 2014-04-01 15:22:40 -0700 | [diff] [blame] | 696 | struct nouveau_bo *old_bo = nouveau_framebuffer(crtc->primary->fb)->nvbo; |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 697 | struct nouveau_bo *new_bo = nouveau_framebuffer(fb)->nvbo; |
| 698 | struct nouveau_page_flip_state *s; |
Ben Skeggs | 0ad7286 | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 699 | struct nouveau_channel *chan; |
| 700 | struct nouveau_cli *cli; |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 701 | struct nouveau_fence *fence; |
| 702 | int ret; |
| 703 | |
Ben Skeggs | 0ad7286 | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 704 | chan = drm->channel; |
| 705 | if (!chan) |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 706 | return -ENODEV; |
Ben Skeggs | 0ad7286 | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 707 | cli = (void *)nvif_client(&chan->device->base); |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 708 | |
| 709 | s = kzalloc(sizeof(*s), GFP_KERNEL); |
| 710 | if (!s) |
| 711 | return -ENOMEM; |
| 712 | |
Maarten Lankhorst | d5c1e84 | 2014-01-14 16:48:58 +0100 | [diff] [blame] | 713 | if (new_bo != old_bo) { |
| 714 | ret = nouveau_bo_pin(new_bo, TTM_PL_FLAG_VRAM); |
| 715 | if (ret) |
| 716 | goto fail_free; |
| 717 | } |
| 718 | |
Ben Skeggs | 0ad7286 | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 719 | mutex_lock(&cli->mutex); |
Maarten Lankhorst | bdaf7dd | 2014-01-21 13:02:14 +0100 | [diff] [blame] | 720 | ret = ttm_bo_reserve(&new_bo->bo, true, false, false, NULL); |
| 721 | if (ret) |
| 722 | goto fail_unpin; |
Maarten Lankhorst | d5c1e84 | 2014-01-14 16:48:58 +0100 | [diff] [blame] | 723 | |
Ben Skeggs | eae389f | 2013-11-13 10:17:17 +1000 | [diff] [blame] | 724 | /* synchronise rendering channel with the kernel's channel */ |
Maarten Lankhorst | e3be4c2 | 2014-09-16 11:15:07 +0200 | [diff] [blame^] | 725 | ret = nouveau_fence_sync(new_bo, chan, false, true); |
Maarten Lankhorst | bdaf7dd | 2014-01-21 13:02:14 +0100 | [diff] [blame] | 726 | if (ret) { |
| 727 | ttm_bo_unreserve(&new_bo->bo); |
Maarten Lankhorst | 09c3de1 | 2014-01-29 11:05:09 +0100 | [diff] [blame] | 728 | goto fail_unpin; |
Maarten Lankhorst | bdaf7dd | 2014-01-21 13:02:14 +0100 | [diff] [blame] | 729 | } |
Maarten Lankhorst | b580c9e | 2013-06-27 13:48:18 +0200 | [diff] [blame] | 730 | |
Maarten Lankhorst | bdaf7dd | 2014-01-21 13:02:14 +0100 | [diff] [blame] | 731 | if (new_bo != old_bo) { |
| 732 | ttm_bo_unreserve(&new_bo->bo); |
| 733 | |
| 734 | ret = ttm_bo_reserve(&old_bo->bo, true, false, false, NULL); |
| 735 | if (ret) |
| 736 | goto fail_unpin; |
| 737 | } |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 738 | |
| 739 | /* Initialize a page flip struct */ |
| 740 | *s = (struct nouveau_page_flip_state) |
Benjamin Franzke | 2503c6f | 2011-02-16 10:04:48 +0100 | [diff] [blame] | 741 | { { }, event, nouveau_crtc(crtc)->index, |
Ville Syrjälä | 01f2c77 | 2011-12-20 00:06:49 +0200 | [diff] [blame] | 742 | fb->bits_per_pixel, fb->pitches[0], crtc->x, crtc->y, |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 743 | new_bo->bo.offset }; |
| 744 | |
Mario Kleiner | ba124a4 | 2014-06-11 09:51:23 +0200 | [diff] [blame] | 745 | /* Keep vblanks on during flip, for the target crtc of this flip */ |
| 746 | drm_vblank_get(dev, nouveau_crtc(crtc)->index); |
| 747 | |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 748 | /* Emit a page flip */ |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 749 | if (drm->device.info.family >= NV_DEVICE_INFO_V0_TESLA) { |
Ben Skeggs | b9d9dcd | 2013-11-11 13:59:40 +1000 | [diff] [blame] | 750 | ret = nv50_display_flip_next(crtc, fb, chan, swap_interval); |
Ben Skeggs | 060810d | 2013-07-08 14:15:51 +1000 | [diff] [blame] | 751 | if (ret) |
Ben Skeggs | d7117e0 | 2011-02-07 14:27:04 +1000 | [diff] [blame] | 752 | goto fail_unreserve; |
Ben Skeggs | 78ae0ad | 2013-08-21 11:30:36 +1000 | [diff] [blame] | 753 | } else { |
| 754 | struct nv04_display *dispnv04 = nv04_display(dev); |
Ben Skeggs | b9d9dcd | 2013-11-11 13:59:40 +1000 | [diff] [blame] | 755 | int head = nouveau_crtc(crtc)->index; |
| 756 | |
| 757 | if (swap_interval) { |
| 758 | ret = RING_SPACE(chan, 8); |
| 759 | if (ret) |
| 760 | goto fail_unreserve; |
| 761 | |
| 762 | BEGIN_NV04(chan, NvSubImageBlit, 0x012c, 1); |
| 763 | OUT_RING (chan, 0); |
| 764 | BEGIN_NV04(chan, NvSubImageBlit, 0x0134, 1); |
| 765 | OUT_RING (chan, head); |
| 766 | BEGIN_NV04(chan, NvSubImageBlit, 0x0100, 1); |
| 767 | OUT_RING (chan, 0); |
| 768 | BEGIN_NV04(chan, NvSubImageBlit, 0x0130, 1); |
| 769 | OUT_RING (chan, 0); |
| 770 | } |
| 771 | |
| 772 | nouveau_bo_ref(new_bo, &dispnv04->image[head]); |
Ben Skeggs | d7117e0 | 2011-02-07 14:27:04 +1000 | [diff] [blame] | 773 | } |
| 774 | |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 775 | ret = nouveau_page_flip_emit(chan, old_bo, new_bo, s, &fence); |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 776 | if (ret) |
| 777 | goto fail_unreserve; |
Ben Skeggs | 0ad7286 | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 778 | mutex_unlock(&cli->mutex); |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 779 | |
| 780 | /* Update the crtc struct and cleanup */ |
Matt Roper | f4510a2 | 2014-04-01 15:22:40 -0700 | [diff] [blame] | 781 | crtc->primary->fb = fb; |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 782 | |
Maarten Lankhorst | 809e944 | 2014-04-09 16:19:30 +0200 | [diff] [blame] | 783 | nouveau_bo_fence(old_bo, fence, false); |
Ben Skeggs | 07ad6ca | 2013-11-13 10:00:32 +1000 | [diff] [blame] | 784 | ttm_bo_unreserve(&old_bo->bo); |
Ben Skeggs | 060810d | 2013-07-08 14:15:51 +1000 | [diff] [blame] | 785 | if (old_bo != new_bo) |
Maarten Lankhorst | b580c9e | 2013-06-27 13:48:18 +0200 | [diff] [blame] | 786 | nouveau_bo_unpin(old_bo); |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 787 | nouveau_fence_unref(&fence); |
| 788 | return 0; |
| 789 | |
| 790 | fail_unreserve: |
Mario Kleiner | ba124a4 | 2014-06-11 09:51:23 +0200 | [diff] [blame] | 791 | drm_vblank_put(dev, nouveau_crtc(crtc)->index); |
Ben Skeggs | 07ad6ca | 2013-11-13 10:00:32 +1000 | [diff] [blame] | 792 | ttm_bo_unreserve(&old_bo->bo); |
Ben Skeggs | 060810d | 2013-07-08 14:15:51 +1000 | [diff] [blame] | 793 | fail_unpin: |
Ben Skeggs | 0ad7286 | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 794 | mutex_unlock(&cli->mutex); |
Ben Skeggs | 060810d | 2013-07-08 14:15:51 +1000 | [diff] [blame] | 795 | if (old_bo != new_bo) |
Maarten Lankhorst | b580c9e | 2013-06-27 13:48:18 +0200 | [diff] [blame] | 796 | nouveau_bo_unpin(new_bo); |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 797 | fail_free: |
| 798 | kfree(s); |
| 799 | return ret; |
| 800 | } |
| 801 | |
| 802 | int |
| 803 | nouveau_finish_page_flip(struct nouveau_channel *chan, |
| 804 | struct nouveau_page_flip_state *ps) |
| 805 | { |
Ben Skeggs | f589be8 | 2012-07-22 11:55:54 +1000 | [diff] [blame] | 806 | struct nouveau_fence_chan *fctx = chan->fence; |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 807 | struct nouveau_drm *drm = chan->drm; |
| 808 | struct drm_device *dev = drm->dev; |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 809 | struct nouveau_page_flip_state *s; |
| 810 | unsigned long flags; |
Mario Kleiner | af4870e | 2014-05-13 00:42:08 +0200 | [diff] [blame] | 811 | int crtcid = -1; |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 812 | |
| 813 | spin_lock_irqsave(&dev->event_lock, flags); |
| 814 | |
Ben Skeggs | f589be8 | 2012-07-22 11:55:54 +1000 | [diff] [blame] | 815 | if (list_empty(&fctx->flip)) { |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 816 | NV_ERROR(drm, "unexpected pageflip\n"); |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 817 | spin_unlock_irqrestore(&dev->event_lock, flags); |
| 818 | return -EINVAL; |
| 819 | } |
| 820 | |
Ben Skeggs | f589be8 | 2012-07-22 11:55:54 +1000 | [diff] [blame] | 821 | s = list_first_entry(&fctx->flip, struct nouveau_page_flip_state, head); |
Mario Kleiner | af4870e | 2014-05-13 00:42:08 +0200 | [diff] [blame] | 822 | if (s->event) { |
| 823 | /* Vblank timestamps/counts are only correct on >= NV-50 */ |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 824 | if (drm->device.info.family >= NV_DEVICE_INFO_V0_TESLA) |
Mario Kleiner | af4870e | 2014-05-13 00:42:08 +0200 | [diff] [blame] | 825 | crtcid = s->crtc; |
| 826 | |
| 827 | drm_send_vblank_event(dev, crtcid, s->event); |
| 828 | } |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 829 | |
Mario Kleiner | ba124a4 | 2014-06-11 09:51:23 +0200 | [diff] [blame] | 830 | /* Give up ownership of vblank for page-flipped crtc */ |
| 831 | drm_vblank_put(dev, s->crtc); |
| 832 | |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 833 | list_del(&s->head); |
Ben Skeggs | d7117e0 | 2011-02-07 14:27:04 +1000 | [diff] [blame] | 834 | if (ps) |
| 835 | *ps = *s; |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 836 | kfree(s); |
| 837 | |
| 838 | spin_unlock_irqrestore(&dev->event_lock, flags); |
| 839 | return 0; |
| 840 | } |
Ben Skeggs | 33dbc27 | 2011-09-30 08:55:50 +1000 | [diff] [blame] | 841 | |
| 842 | int |
Ben Skeggs | f589be8 | 2012-07-22 11:55:54 +1000 | [diff] [blame] | 843 | nouveau_flip_complete(void *data) |
| 844 | { |
| 845 | struct nouveau_channel *chan = data; |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 846 | struct nouveau_drm *drm = chan->drm; |
Ben Skeggs | f589be8 | 2012-07-22 11:55:54 +1000 | [diff] [blame] | 847 | struct nouveau_page_flip_state state; |
| 848 | |
| 849 | if (!nouveau_finish_page_flip(chan, &state)) { |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 850 | if (drm->device.info.family < NV_DEVICE_INFO_V0_TESLA) { |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 851 | nv_set_crtc_base(drm->dev, state.crtc, state.offset + |
Ben Skeggs | f589be8 | 2012-07-22 11:55:54 +1000 | [diff] [blame] | 852 | state.y * state.pitch + |
| 853 | state.x * state.bpp / 8); |
| 854 | } |
| 855 | } |
| 856 | |
| 857 | return 0; |
| 858 | } |
| 859 | |
| 860 | int |
Ben Skeggs | 33dbc27 | 2011-09-30 08:55:50 +1000 | [diff] [blame] | 861 | nouveau_display_dumb_create(struct drm_file *file_priv, struct drm_device *dev, |
| 862 | struct drm_mode_create_dumb *args) |
| 863 | { |
| 864 | struct nouveau_bo *bo; |
| 865 | int ret; |
| 866 | |
| 867 | args->pitch = roundup(args->width * (args->bpp / 8), 256); |
| 868 | args->size = args->pitch * args->height; |
| 869 | args->size = roundup(args->size, PAGE_SIZE); |
| 870 | |
Dave Airlie | 610bd7d | 2012-09-14 13:28:23 +1000 | [diff] [blame] | 871 | ret = nouveau_gem_new(dev, args->size, 0, NOUVEAU_GEM_DOMAIN_VRAM, 0, 0, &bo); |
Ben Skeggs | 33dbc27 | 2011-09-30 08:55:50 +1000 | [diff] [blame] | 872 | if (ret) |
| 873 | return ret; |
| 874 | |
David Herrmann | 55fb74a | 2013-10-02 10:15:17 +0200 | [diff] [blame] | 875 | ret = drm_gem_handle_create(file_priv, &bo->gem, &args->handle); |
| 876 | drm_gem_object_unreference_unlocked(&bo->gem); |
Ben Skeggs | 33dbc27 | 2011-09-30 08:55:50 +1000 | [diff] [blame] | 877 | return ret; |
| 878 | } |
| 879 | |
| 880 | int |
Ben Skeggs | 33dbc27 | 2011-09-30 08:55:50 +1000 | [diff] [blame] | 881 | nouveau_display_dumb_map_offset(struct drm_file *file_priv, |
| 882 | struct drm_device *dev, |
| 883 | uint32_t handle, uint64_t *poffset) |
| 884 | { |
| 885 | struct drm_gem_object *gem; |
| 886 | |
| 887 | gem = drm_gem_object_lookup(dev, file_priv, handle); |
| 888 | if (gem) { |
David Herrmann | 55fb74a | 2013-10-02 10:15:17 +0200 | [diff] [blame] | 889 | struct nouveau_bo *bo = nouveau_gem_object(gem); |
David Herrmann | 72525b3 | 2013-07-24 21:08:53 +0200 | [diff] [blame] | 890 | *poffset = drm_vma_node_offset_addr(&bo->bo.vma_node); |
Ben Skeggs | 33dbc27 | 2011-09-30 08:55:50 +1000 | [diff] [blame] | 891 | drm_gem_object_unreference_unlocked(gem); |
| 892 | return 0; |
| 893 | } |
| 894 | |
| 895 | return -ENOENT; |
| 896 | } |