nouveau_display.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  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. #include "drmP.h"
  27. #include "drm_crtc_helper.h"
  28. #include "nouveau_drv.h"
  29. #include "nouveau_fb.h"
  30. #include "nouveau_fbcon.h"
  31. #include "nouveau_hw.h"
  32. #include "nouveau_crtc.h"
  33. #include "nouveau_dma.h"
  34. #include "nouveau_connector.h"
  35. #include "nouveau_gpio.h"
  36. #include "nv50_display.h"
  37. static void
  38. nouveau_user_framebuffer_destroy(struct drm_framebuffer *drm_fb)
  39. {
  40. struct nouveau_framebuffer *fb = nouveau_framebuffer(drm_fb);
  41. if (fb->nvbo)
  42. drm_gem_object_unreference_unlocked(fb->nvbo->gem);
  43. drm_framebuffer_cleanup(drm_fb);
  44. kfree(fb);
  45. }
  46. static int
  47. nouveau_user_framebuffer_create_handle(struct drm_framebuffer *drm_fb,
  48. struct drm_file *file_priv,
  49. unsigned int *handle)
  50. {
  51. struct nouveau_framebuffer *fb = nouveau_framebuffer(drm_fb);
  52. return drm_gem_handle_create(file_priv, fb->nvbo->gem, handle);
  53. }
  54. static const struct drm_framebuffer_funcs nouveau_framebuffer_funcs = {
  55. .destroy = nouveau_user_framebuffer_destroy,
  56. .create_handle = nouveau_user_framebuffer_create_handle,
  57. };
  58. int
  59. nouveau_framebuffer_init(struct drm_device *dev,
  60. struct nouveau_framebuffer *nv_fb,
  61. struct drm_mode_fb_cmd2 *mode_cmd,
  62. struct nouveau_bo *nvbo)
  63. {
  64. struct drm_nouveau_private *dev_priv = dev->dev_private;
  65. struct drm_framebuffer *fb = &nv_fb->base;
  66. int ret;
  67. ret = drm_framebuffer_init(dev, fb, &nouveau_framebuffer_funcs);
  68. if (ret) {
  69. return ret;
  70. }
  71. drm_helper_mode_fill_fb_struct(fb, mode_cmd);
  72. nv_fb->nvbo = nvbo;
  73. if (dev_priv->card_type >= NV_50) {
  74. u32 tile_flags = nouveau_bo_tile_layout(nvbo);
  75. if (tile_flags == 0x7a00 ||
  76. tile_flags == 0xfe00)
  77. nv_fb->r_dma = NvEvoFB32;
  78. else
  79. if (tile_flags == 0x7000)
  80. nv_fb->r_dma = NvEvoFB16;
  81. else
  82. nv_fb->r_dma = NvEvoVRAM_LP;
  83. switch (fb->depth) {
  84. case 8: nv_fb->r_format = NV50_EVO_CRTC_FB_DEPTH_8; break;
  85. case 15: nv_fb->r_format = NV50_EVO_CRTC_FB_DEPTH_15; break;
  86. case 16: nv_fb->r_format = NV50_EVO_CRTC_FB_DEPTH_16; break;
  87. case 24:
  88. case 32: nv_fb->r_format = NV50_EVO_CRTC_FB_DEPTH_24; break;
  89. case 30: nv_fb->r_format = NV50_EVO_CRTC_FB_DEPTH_30; break;
  90. default:
  91. NV_ERROR(dev, "unknown depth %d\n", fb->depth);
  92. return -EINVAL;
  93. }
  94. if (dev_priv->chipset == 0x50)
  95. nv_fb->r_format |= (tile_flags << 8);
  96. if (!tile_flags) {
  97. if (dev_priv->card_type < NV_D0)
  98. nv_fb->r_pitch = 0x00100000 | fb->pitches[0];
  99. else
  100. nv_fb->r_pitch = 0x01000000 | fb->pitches[0];
  101. } else {
  102. u32 mode = nvbo->tile_mode;
  103. if (dev_priv->card_type >= NV_C0)
  104. mode >>= 4;
  105. nv_fb->r_pitch = ((fb->pitches[0] / 4) << 4) | mode;
  106. }
  107. }
  108. return 0;
  109. }
  110. static struct drm_framebuffer *
  111. nouveau_user_framebuffer_create(struct drm_device *dev,
  112. struct drm_file *file_priv,
  113. struct drm_mode_fb_cmd2 *mode_cmd)
  114. {
  115. struct nouveau_framebuffer *nouveau_fb;
  116. struct drm_gem_object *gem;
  117. int ret;
  118. gem = drm_gem_object_lookup(dev, file_priv, mode_cmd->handles[0]);
  119. if (!gem)
  120. return ERR_PTR(-ENOENT);
  121. nouveau_fb = kzalloc(sizeof(struct nouveau_framebuffer), GFP_KERNEL);
  122. if (!nouveau_fb)
  123. return ERR_PTR(-ENOMEM);
  124. ret = nouveau_framebuffer_init(dev, nouveau_fb, mode_cmd, nouveau_gem_object(gem));
  125. if (ret) {
  126. drm_gem_object_unreference(gem);
  127. return ERR_PTR(ret);
  128. }
  129. return &nouveau_fb->base;
  130. }
  131. static const struct drm_mode_config_funcs nouveau_mode_config_funcs = {
  132. .fb_create = nouveau_user_framebuffer_create,
  133. .output_poll_changed = nouveau_fbcon_output_poll_changed,
  134. };
  135. struct nouveau_drm_prop_enum_list {
  136. u8 gen_mask;
  137. int type;
  138. char *name;
  139. };
  140. static struct nouveau_drm_prop_enum_list underscan[] = {
  141. { 6, UNDERSCAN_AUTO, "auto" },
  142. { 6, UNDERSCAN_OFF, "off" },
  143. { 6, UNDERSCAN_ON, "on" },
  144. {}
  145. };
  146. static struct nouveau_drm_prop_enum_list dither_mode[] = {
  147. { 7, DITHERING_MODE_AUTO, "auto" },
  148. { 7, DITHERING_MODE_OFF, "off" },
  149. { 1, DITHERING_MODE_ON, "on" },
  150. { 6, DITHERING_MODE_STATIC2X2, "static 2x2" },
  151. { 6, DITHERING_MODE_DYNAMIC2X2, "dynamic 2x2" },
  152. { 4, DITHERING_MODE_TEMPORAL, "temporal" },
  153. {}
  154. };
  155. static struct nouveau_drm_prop_enum_list dither_depth[] = {
  156. { 6, DITHERING_DEPTH_AUTO, "auto" },
  157. { 6, DITHERING_DEPTH_6BPC, "6 bpc" },
  158. { 6, DITHERING_DEPTH_8BPC, "8 bpc" },
  159. {}
  160. };
  161. #define PROP_ENUM(p,gen,n,list) do { \
  162. struct nouveau_drm_prop_enum_list *l = (list); \
  163. int c = 0; \
  164. while (l->gen_mask) { \
  165. if (l->gen_mask & (1 << (gen))) \
  166. c++; \
  167. l++; \
  168. } \
  169. if (c) { \
  170. p = drm_property_create(dev, DRM_MODE_PROP_ENUM, n, c); \
  171. l = (list); \
  172. c = 0; \
  173. while (p && l->gen_mask) { \
  174. if (l->gen_mask & (1 << (gen))) { \
  175. drm_property_add_enum(p, c, l->type, l->name); \
  176. c++; \
  177. } \
  178. l++; \
  179. } \
  180. } \
  181. } while(0)
  182. int
  183. nouveau_display_init(struct drm_device *dev)
  184. {
  185. struct drm_nouveau_private *dev_priv = dev->dev_private;
  186. struct nouveau_display_engine *disp = &dev_priv->engine.display;
  187. struct drm_connector *connector;
  188. int ret;
  189. ret = disp->init(dev);
  190. if (ret)
  191. return ret;
  192. /* power on internal panel if it's not already. the init tables of
  193. * some vbios default this to off for some reason, causing the
  194. * panel to not work after resume
  195. */
  196. if (nouveau_gpio_func_get(dev, DCB_GPIO_PANEL_POWER) == 0) {
  197. nouveau_gpio_func_set(dev, DCB_GPIO_PANEL_POWER, true);
  198. msleep(300);
  199. }
  200. /* enable polling for external displays */
  201. drm_kms_helper_poll_enable(dev);
  202. /* enable hotplug interrupts */
  203. list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
  204. struct nouveau_connector *conn = nouveau_connector(connector);
  205. nouveau_gpio_irq(dev, 0, conn->hpd, 0xff, true);
  206. }
  207. return ret;
  208. }
  209. void
  210. nouveau_display_fini(struct drm_device *dev)
  211. {
  212. struct drm_nouveau_private *dev_priv = dev->dev_private;
  213. struct nouveau_display_engine *disp = &dev_priv->engine.display;
  214. struct drm_connector *connector;
  215. /* disable hotplug interrupts */
  216. list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
  217. struct nouveau_connector *conn = nouveau_connector(connector);
  218. nouveau_gpio_irq(dev, 0, conn->hpd, 0xff, false);
  219. }
  220. drm_kms_helper_poll_disable(dev);
  221. disp->fini(dev);
  222. }
  223. int
  224. nouveau_display_create(struct drm_device *dev)
  225. {
  226. struct drm_nouveau_private *dev_priv = dev->dev_private;
  227. struct nouveau_display_engine *disp = &dev_priv->engine.display;
  228. int ret, gen;
  229. drm_mode_config_init(dev);
  230. drm_mode_create_scaling_mode_property(dev);
  231. drm_mode_create_dvi_i_properties(dev);
  232. if (dev_priv->card_type < NV_50)
  233. gen = 0;
  234. else
  235. if (dev_priv->card_type < NV_D0)
  236. gen = 1;
  237. else
  238. gen = 2;
  239. PROP_ENUM(disp->dithering_mode, gen, "dithering mode", dither_mode);
  240. PROP_ENUM(disp->dithering_depth, gen, "dithering depth", dither_depth);
  241. PROP_ENUM(disp->underscan_property, gen, "underscan", underscan);
  242. disp->underscan_hborder_property =
  243. drm_property_create_range(dev, 0, "underscan hborder", 0, 128);
  244. disp->underscan_vborder_property =
  245. drm_property_create_range(dev, 0, "underscan vborder", 0, 128);
  246. if (gen == 1) {
  247. disp->vibrant_hue_property =
  248. drm_property_create(dev, DRM_MODE_PROP_RANGE,
  249. "vibrant hue", 2);
  250. disp->vibrant_hue_property->values[0] = 0;
  251. disp->vibrant_hue_property->values[1] = 180; /* -90..+90 */
  252. disp->color_vibrance_property =
  253. drm_property_create(dev, DRM_MODE_PROP_RANGE,
  254. "color vibrance", 2);
  255. disp->color_vibrance_property->values[0] = 0;
  256. disp->color_vibrance_property->values[1] = 200; /* -100..+100 */
  257. }
  258. dev->mode_config.funcs = (void *)&nouveau_mode_config_funcs;
  259. dev->mode_config.fb_base = pci_resource_start(dev->pdev, 1);
  260. dev->mode_config.min_width = 0;
  261. dev->mode_config.min_height = 0;
  262. if (dev_priv->card_type < NV_10) {
  263. dev->mode_config.max_width = 2048;
  264. dev->mode_config.max_height = 2048;
  265. } else
  266. if (dev_priv->card_type < NV_50) {
  267. dev->mode_config.max_width = 4096;
  268. dev->mode_config.max_height = 4096;
  269. } else {
  270. dev->mode_config.max_width = 8192;
  271. dev->mode_config.max_height = 8192;
  272. }
  273. dev->mode_config.preferred_depth = 24;
  274. dev->mode_config.prefer_shadow = 1;
  275. drm_kms_helper_poll_init(dev);
  276. drm_kms_helper_poll_disable(dev);
  277. ret = disp->create(dev);
  278. if (ret)
  279. return ret;
  280. if (dev->mode_config.num_crtc) {
  281. ret = drm_vblank_init(dev, dev->mode_config.num_crtc);
  282. if (ret)
  283. return ret;
  284. }
  285. return ret;
  286. }
  287. void
  288. nouveau_display_destroy(struct drm_device *dev)
  289. {
  290. struct drm_nouveau_private *dev_priv = dev->dev_private;
  291. struct nouveau_display_engine *disp = &dev_priv->engine.display;
  292. drm_vblank_cleanup(dev);
  293. disp->destroy(dev);
  294. drm_kms_helper_poll_fini(dev);
  295. drm_mode_config_cleanup(dev);
  296. }
  297. int
  298. nouveau_vblank_enable(struct drm_device *dev, int crtc)
  299. {
  300. struct drm_nouveau_private *dev_priv = dev->dev_private;
  301. if (dev_priv->card_type >= NV_50)
  302. nv_mask(dev, NV50_PDISPLAY_INTR_EN_1, 0,
  303. NV50_PDISPLAY_INTR_EN_1_VBLANK_CRTC_(crtc));
  304. else
  305. NVWriteCRTC(dev, crtc, NV_PCRTC_INTR_EN_0,
  306. NV_PCRTC_INTR_0_VBLANK);
  307. return 0;
  308. }
  309. void
  310. nouveau_vblank_disable(struct drm_device *dev, int crtc)
  311. {
  312. struct drm_nouveau_private *dev_priv = dev->dev_private;
  313. if (dev_priv->card_type >= NV_50)
  314. nv_mask(dev, NV50_PDISPLAY_INTR_EN_1,
  315. NV50_PDISPLAY_INTR_EN_1_VBLANK_CRTC_(crtc), 0);
  316. else
  317. NVWriteCRTC(dev, crtc, NV_PCRTC_INTR_EN_0, 0);
  318. }
  319. static int
  320. nouveau_page_flip_reserve(struct nouveau_bo *old_bo,
  321. struct nouveau_bo *new_bo)
  322. {
  323. int ret;
  324. ret = nouveau_bo_pin(new_bo, TTM_PL_FLAG_VRAM);
  325. if (ret)
  326. return ret;
  327. ret = ttm_bo_reserve(&new_bo->bo, false, false, false, 0);
  328. if (ret)
  329. goto fail;
  330. ret = ttm_bo_reserve(&old_bo->bo, false, false, false, 0);
  331. if (ret)
  332. goto fail_unreserve;
  333. return 0;
  334. fail_unreserve:
  335. ttm_bo_unreserve(&new_bo->bo);
  336. fail:
  337. nouveau_bo_unpin(new_bo);
  338. return ret;
  339. }
  340. static void
  341. nouveau_page_flip_unreserve(struct nouveau_bo *old_bo,
  342. struct nouveau_bo *new_bo,
  343. struct nouveau_fence *fence)
  344. {
  345. nouveau_bo_fence(new_bo, fence);
  346. ttm_bo_unreserve(&new_bo->bo);
  347. nouveau_bo_fence(old_bo, fence);
  348. ttm_bo_unreserve(&old_bo->bo);
  349. nouveau_bo_unpin(old_bo);
  350. }
  351. static int
  352. nouveau_page_flip_emit(struct nouveau_channel *chan,
  353. struct nouveau_bo *old_bo,
  354. struct nouveau_bo *new_bo,
  355. struct nouveau_page_flip_state *s,
  356. struct nouveau_fence **pfence)
  357. {
  358. struct drm_nouveau_private *dev_priv = chan->dev->dev_private;
  359. struct drm_device *dev = chan->dev;
  360. unsigned long flags;
  361. int ret;
  362. /* Queue it to the pending list */
  363. spin_lock_irqsave(&dev->event_lock, flags);
  364. list_add_tail(&s->head, &chan->nvsw.flip);
  365. spin_unlock_irqrestore(&dev->event_lock, flags);
  366. /* Synchronize with the old framebuffer */
  367. ret = nouveau_fence_sync(old_bo->bo.sync_obj, chan);
  368. if (ret)
  369. goto fail;
  370. /* Emit the pageflip */
  371. ret = RING_SPACE(chan, 3);
  372. if (ret)
  373. goto fail;
  374. if (dev_priv->card_type < NV_C0) {
  375. BEGIN_RING(chan, NvSubSw, NV_SW_PAGE_FLIP, 1);
  376. OUT_RING (chan, 0x00000000);
  377. OUT_RING (chan, 0x00000000);
  378. } else {
  379. BEGIN_NVC0(chan, 2, 0, NV10_SUBCHAN_REF_CNT, 1);
  380. OUT_RING (chan, ++chan->fence.sequence);
  381. BEGIN_NVC0(chan, 8, 0, NVSW_SUBCHAN_PAGE_FLIP, 0x0000);
  382. }
  383. FIRE_RING (chan);
  384. ret = nouveau_fence_new(chan, pfence, true);
  385. if (ret)
  386. goto fail;
  387. return 0;
  388. fail:
  389. spin_lock_irqsave(&dev->event_lock, flags);
  390. list_del(&s->head);
  391. spin_unlock_irqrestore(&dev->event_lock, flags);
  392. return ret;
  393. }
  394. int
  395. nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
  396. struct drm_pending_vblank_event *event)
  397. {
  398. struct drm_device *dev = crtc->dev;
  399. struct drm_nouveau_private *dev_priv = dev->dev_private;
  400. struct nouveau_bo *old_bo = nouveau_framebuffer(crtc->fb)->nvbo;
  401. struct nouveau_bo *new_bo = nouveau_framebuffer(fb)->nvbo;
  402. struct nouveau_page_flip_state *s;
  403. struct nouveau_channel *chan;
  404. struct nouveau_fence *fence;
  405. int ret;
  406. if (!dev_priv->channel)
  407. return -ENODEV;
  408. s = kzalloc(sizeof(*s), GFP_KERNEL);
  409. if (!s)
  410. return -ENOMEM;
  411. /* Don't let the buffers go away while we flip */
  412. ret = nouveau_page_flip_reserve(old_bo, new_bo);
  413. if (ret)
  414. goto fail_free;
  415. /* Initialize a page flip struct */
  416. *s = (struct nouveau_page_flip_state)
  417. { { }, event, nouveau_crtc(crtc)->index,
  418. fb->bits_per_pixel, fb->pitches[0], crtc->x, crtc->y,
  419. new_bo->bo.offset };
  420. /* Choose the channel the flip will be handled in */
  421. chan = nouveau_fence_channel(new_bo->bo.sync_obj);
  422. if (!chan)
  423. chan = nouveau_channel_get_unlocked(dev_priv->channel);
  424. mutex_lock(&chan->mutex);
  425. /* Emit a page flip */
  426. if (dev_priv->card_type >= NV_50) {
  427. if (dev_priv->card_type >= NV_D0)
  428. ret = nvd0_display_flip_next(crtc, fb, chan, 0);
  429. else
  430. ret = nv50_display_flip_next(crtc, fb, chan);
  431. if (ret) {
  432. nouveau_channel_put(&chan);
  433. goto fail_unreserve;
  434. }
  435. }
  436. ret = nouveau_page_flip_emit(chan, old_bo, new_bo, s, &fence);
  437. nouveau_channel_put(&chan);
  438. if (ret)
  439. goto fail_unreserve;
  440. /* Update the crtc struct and cleanup */
  441. crtc->fb = fb;
  442. nouveau_page_flip_unreserve(old_bo, new_bo, fence);
  443. nouveau_fence_unref(&fence);
  444. return 0;
  445. fail_unreserve:
  446. nouveau_page_flip_unreserve(old_bo, new_bo, NULL);
  447. fail_free:
  448. kfree(s);
  449. return ret;
  450. }
  451. int
  452. nouveau_finish_page_flip(struct nouveau_channel *chan,
  453. struct nouveau_page_flip_state *ps)
  454. {
  455. struct drm_device *dev = chan->dev;
  456. struct nouveau_page_flip_state *s;
  457. unsigned long flags;
  458. spin_lock_irqsave(&dev->event_lock, flags);
  459. if (list_empty(&chan->nvsw.flip)) {
  460. NV_ERROR(dev, "Unexpected pageflip in channel %d.\n", chan->id);
  461. spin_unlock_irqrestore(&dev->event_lock, flags);
  462. return -EINVAL;
  463. }
  464. s = list_first_entry(&chan->nvsw.flip,
  465. struct nouveau_page_flip_state, head);
  466. if (s->event) {
  467. struct drm_pending_vblank_event *e = s->event;
  468. struct timeval now;
  469. do_gettimeofday(&now);
  470. e->event.sequence = 0;
  471. e->event.tv_sec = now.tv_sec;
  472. e->event.tv_usec = now.tv_usec;
  473. list_add_tail(&e->base.link, &e->base.file_priv->event_list);
  474. wake_up_interruptible(&e->base.file_priv->event_wait);
  475. }
  476. list_del(&s->head);
  477. if (ps)
  478. *ps = *s;
  479. kfree(s);
  480. spin_unlock_irqrestore(&dev->event_lock, flags);
  481. return 0;
  482. }
  483. int
  484. nouveau_display_dumb_create(struct drm_file *file_priv, struct drm_device *dev,
  485. struct drm_mode_create_dumb *args)
  486. {
  487. struct nouveau_bo *bo;
  488. int ret;
  489. args->pitch = roundup(args->width * (args->bpp / 8), 256);
  490. args->size = args->pitch * args->height;
  491. args->size = roundup(args->size, PAGE_SIZE);
  492. ret = nouveau_gem_new(dev, args->size, 0, NOUVEAU_GEM_DOMAIN_VRAM, 0, 0, &bo);
  493. if (ret)
  494. return ret;
  495. ret = drm_gem_handle_create(file_priv, bo->gem, &args->handle);
  496. drm_gem_object_unreference_unlocked(bo->gem);
  497. return ret;
  498. }
  499. int
  500. nouveau_display_dumb_destroy(struct drm_file *file_priv, struct drm_device *dev,
  501. uint32_t handle)
  502. {
  503. return drm_gem_handle_delete(file_priv, handle);
  504. }
  505. int
  506. nouveau_display_dumb_map_offset(struct drm_file *file_priv,
  507. struct drm_device *dev,
  508. uint32_t handle, uint64_t *poffset)
  509. {
  510. struct drm_gem_object *gem;
  511. gem = drm_gem_object_lookup(dev, file_priv, handle);
  512. if (gem) {
  513. struct nouveau_bo *bo = gem->driver_private;
  514. *poffset = bo->bo.addr_space_offset;
  515. drm_gem_object_unreference_unlocked(gem);
  516. return 0;
  517. }
  518. return -ENOENT;
  519. }