drm_irq.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. /**
  2. * \file drm_irq.c
  3. * IRQ support
  4. *
  5. * \author Rickard E. (Rik) Faith <faith@valinux.com>
  6. * \author Gareth Hughes <gareth@valinux.com>
  7. */
  8. /*
  9. * Created: Fri Mar 19 14:30:16 1999 by faith@valinux.com
  10. *
  11. * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
  12. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
  13. * All Rights Reserved.
  14. *
  15. * Permission is hereby granted, free of charge, to any person obtaining a
  16. * copy of this software and associated documentation files (the "Software"),
  17. * to deal in the Software without restriction, including without limitation
  18. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  19. * and/or sell copies of the Software, and to permit persons to whom the
  20. * Software is furnished to do so, subject to the following conditions:
  21. *
  22. * The above copyright notice and this permission notice (including the next
  23. * paragraph) shall be included in all copies or substantial portions of the
  24. * Software.
  25. *
  26. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  27. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  28. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  29. * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  30. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  31. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  32. * OTHER DEALINGS IN THE SOFTWARE.
  33. */
  34. #include "drmP.h"
  35. #include <linux/interrupt.h> /* For task queue support */
  36. /**
  37. * Get interrupt from bus id.
  38. *
  39. * \param inode device inode.
  40. * \param file_priv DRM file private.
  41. * \param cmd command.
  42. * \param arg user argument, pointing to a drm_irq_busid structure.
  43. * \return zero on success or a negative number on failure.
  44. *
  45. * Finds the PCI device with the specified bus id and gets its IRQ number.
  46. * This IOCTL is deprecated, and will now return EINVAL for any busid not equal
  47. * to that of the device that this DRM instance attached to.
  48. */
  49. int drm_irq_by_busid(struct drm_device *dev, void *data,
  50. struct drm_file *file_priv)
  51. {
  52. struct drm_irq_busid *p = data;
  53. if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
  54. return -EINVAL;
  55. if ((p->busnum >> 8) != drm_get_pci_domain(dev) ||
  56. (p->busnum & 0xff) != dev->pdev->bus->number ||
  57. p->devnum != PCI_SLOT(dev->pdev->devfn) || p->funcnum != PCI_FUNC(dev->pdev->devfn))
  58. return -EINVAL;
  59. p->irq = dev->pdev->irq;
  60. DRM_DEBUG("%d:%d:%d => IRQ %d\n", p->busnum, p->devnum, p->funcnum,
  61. p->irq);
  62. return 0;
  63. }
  64. static void vblank_disable_fn(unsigned long arg)
  65. {
  66. struct drm_device *dev = (struct drm_device *)arg;
  67. unsigned long irqflags;
  68. int i;
  69. if (!dev->vblank_disable_allowed)
  70. return;
  71. for (i = 0; i < dev->num_crtcs; i++) {
  72. spin_lock_irqsave(&dev->vbl_lock, irqflags);
  73. if (atomic_read(&dev->vblank_refcount[i]) == 0 &&
  74. dev->vblank_enabled[i]) {
  75. DRM_DEBUG("disabling vblank on crtc %d\n", i);
  76. dev->last_vblank[i] =
  77. dev->driver->get_vblank_counter(dev, i);
  78. dev->driver->disable_vblank(dev, i);
  79. dev->vblank_enabled[i] = 0;
  80. }
  81. spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
  82. }
  83. }
  84. void drm_vblank_cleanup(struct drm_device *dev)
  85. {
  86. /* Bail if the driver didn't call drm_vblank_init() */
  87. if (dev->num_crtcs == 0)
  88. return;
  89. del_timer(&dev->vblank_disable_timer);
  90. vblank_disable_fn((unsigned long)dev);
  91. kfree(dev->vbl_queue);
  92. kfree(dev->_vblank_count);
  93. kfree(dev->vblank_refcount);
  94. kfree(dev->vblank_enabled);
  95. kfree(dev->last_vblank);
  96. kfree(dev->last_vblank_wait);
  97. kfree(dev->vblank_inmodeset);
  98. dev->num_crtcs = 0;
  99. }
  100. int drm_vblank_init(struct drm_device *dev, int num_crtcs)
  101. {
  102. int i, ret = -ENOMEM;
  103. setup_timer(&dev->vblank_disable_timer, vblank_disable_fn,
  104. (unsigned long)dev);
  105. spin_lock_init(&dev->vbl_lock);
  106. dev->num_crtcs = num_crtcs;
  107. dev->vbl_queue = kmalloc(sizeof(wait_queue_head_t) * num_crtcs,
  108. GFP_KERNEL);
  109. if (!dev->vbl_queue)
  110. goto err;
  111. dev->_vblank_count = kmalloc(sizeof(atomic_t) * num_crtcs, GFP_KERNEL);
  112. if (!dev->_vblank_count)
  113. goto err;
  114. dev->vblank_refcount = kmalloc(sizeof(atomic_t) * num_crtcs,
  115. GFP_KERNEL);
  116. if (!dev->vblank_refcount)
  117. goto err;
  118. dev->vblank_enabled = kcalloc(num_crtcs, sizeof(int), GFP_KERNEL);
  119. if (!dev->vblank_enabled)
  120. goto err;
  121. dev->last_vblank = kcalloc(num_crtcs, sizeof(u32), GFP_KERNEL);
  122. if (!dev->last_vblank)
  123. goto err;
  124. dev->last_vblank_wait = kcalloc(num_crtcs, sizeof(u32), GFP_KERNEL);
  125. if (!dev->last_vblank_wait)
  126. goto err;
  127. dev->vblank_inmodeset = kcalloc(num_crtcs, sizeof(int), GFP_KERNEL);
  128. if (!dev->vblank_inmodeset)
  129. goto err;
  130. /* Zero per-crtc vblank stuff */
  131. for (i = 0; i < num_crtcs; i++) {
  132. init_waitqueue_head(&dev->vbl_queue[i]);
  133. atomic_set(&dev->_vblank_count[i], 0);
  134. atomic_set(&dev->vblank_refcount[i], 0);
  135. }
  136. dev->vblank_disable_allowed = 0;
  137. return 0;
  138. err:
  139. drm_vblank_cleanup(dev);
  140. return ret;
  141. }
  142. EXPORT_SYMBOL(drm_vblank_init);
  143. /**
  144. * Install IRQ handler.
  145. *
  146. * \param dev DRM device.
  147. *
  148. * Initializes the IRQ related data. Installs the handler, calling the driver
  149. * \c drm_driver_irq_preinstall() and \c drm_driver_irq_postinstall() functions
  150. * before and after the installation.
  151. */
  152. int drm_irq_install(struct drm_device *dev)
  153. {
  154. int ret = 0;
  155. unsigned long sh_flags = 0;
  156. char *irqname;
  157. if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
  158. return -EINVAL;
  159. if (dev->pdev->irq == 0)
  160. return -EINVAL;
  161. mutex_lock(&dev->struct_mutex);
  162. /* Driver must have been initialized */
  163. if (!dev->dev_private) {
  164. mutex_unlock(&dev->struct_mutex);
  165. return -EINVAL;
  166. }
  167. if (dev->irq_enabled) {
  168. mutex_unlock(&dev->struct_mutex);
  169. return -EBUSY;
  170. }
  171. dev->irq_enabled = 1;
  172. mutex_unlock(&dev->struct_mutex);
  173. DRM_DEBUG("irq=%d\n", dev->pdev->irq);
  174. /* Before installing handler */
  175. dev->driver->irq_preinstall(dev);
  176. /* Install handler */
  177. if (drm_core_check_feature(dev, DRIVER_IRQ_SHARED))
  178. sh_flags = IRQF_SHARED;
  179. if (dev->devname)
  180. irqname = dev->devname;
  181. else
  182. irqname = dev->driver->name;
  183. ret = request_irq(drm_dev_to_irq(dev), dev->driver->irq_handler,
  184. sh_flags, irqname, dev);
  185. if (ret < 0) {
  186. mutex_lock(&dev->struct_mutex);
  187. dev->irq_enabled = 0;
  188. mutex_unlock(&dev->struct_mutex);
  189. return ret;
  190. }
  191. /* After installing handler */
  192. ret = dev->driver->irq_postinstall(dev);
  193. if (ret < 0) {
  194. mutex_lock(&dev->struct_mutex);
  195. dev->irq_enabled = 0;
  196. mutex_unlock(&dev->struct_mutex);
  197. }
  198. return ret;
  199. }
  200. EXPORT_SYMBOL(drm_irq_install);
  201. /**
  202. * Uninstall the IRQ handler.
  203. *
  204. * \param dev DRM device.
  205. *
  206. * Calls the driver's \c drm_driver_irq_uninstall() function, and stops the irq.
  207. */
  208. int drm_irq_uninstall(struct drm_device * dev)
  209. {
  210. unsigned long irqflags;
  211. int irq_enabled, i;
  212. if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
  213. return -EINVAL;
  214. mutex_lock(&dev->struct_mutex);
  215. irq_enabled = dev->irq_enabled;
  216. dev->irq_enabled = 0;
  217. mutex_unlock(&dev->struct_mutex);
  218. /*
  219. * Wake up any waiters so they don't hang.
  220. */
  221. spin_lock_irqsave(&dev->vbl_lock, irqflags);
  222. for (i = 0; i < dev->num_crtcs; i++) {
  223. DRM_WAKEUP(&dev->vbl_queue[i]);
  224. dev->vblank_enabled[i] = 0;
  225. dev->last_vblank[i] = dev->driver->get_vblank_counter(dev, i);
  226. }
  227. spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
  228. if (!irq_enabled)
  229. return -EINVAL;
  230. DRM_DEBUG("irq=%d\n", dev->pdev->irq);
  231. dev->driver->irq_uninstall(dev);
  232. free_irq(dev->pdev->irq, dev);
  233. return 0;
  234. }
  235. EXPORT_SYMBOL(drm_irq_uninstall);
  236. /**
  237. * IRQ control ioctl.
  238. *
  239. * \param inode device inode.
  240. * \param file_priv DRM file private.
  241. * \param cmd command.
  242. * \param arg user argument, pointing to a drm_control structure.
  243. * \return zero on success or a negative number on failure.
  244. *
  245. * Calls irq_install() or irq_uninstall() according to \p arg.
  246. */
  247. int drm_control(struct drm_device *dev, void *data,
  248. struct drm_file *file_priv)
  249. {
  250. struct drm_control *ctl = data;
  251. /* if we haven't irq we fallback for compatibility reasons - this used to be a separate function in drm_dma.h */
  252. switch (ctl->func) {
  253. case DRM_INST_HANDLER:
  254. if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
  255. return 0;
  256. if (drm_core_check_feature(dev, DRIVER_MODESET))
  257. return 0;
  258. if (dev->if_version < DRM_IF_VERSION(1, 2) &&
  259. ctl->irq != dev->pdev->irq)
  260. return -EINVAL;
  261. return drm_irq_install(dev);
  262. case DRM_UNINST_HANDLER:
  263. if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
  264. return 0;
  265. if (drm_core_check_feature(dev, DRIVER_MODESET))
  266. return 0;
  267. return drm_irq_uninstall(dev);
  268. default:
  269. return -EINVAL;
  270. }
  271. }
  272. /**
  273. * drm_vblank_count - retrieve "cooked" vblank counter value
  274. * @dev: DRM device
  275. * @crtc: which counter to retrieve
  276. *
  277. * Fetches the "cooked" vblank count value that represents the number of
  278. * vblank events since the system was booted, including lost events due to
  279. * modesetting activity.
  280. */
  281. u32 drm_vblank_count(struct drm_device *dev, int crtc)
  282. {
  283. return atomic_read(&dev->_vblank_count[crtc]);
  284. }
  285. EXPORT_SYMBOL(drm_vblank_count);
  286. /**
  287. * drm_update_vblank_count - update the master vblank counter
  288. * @dev: DRM device
  289. * @crtc: counter to update
  290. *
  291. * Call back into the driver to update the appropriate vblank counter
  292. * (specified by @crtc). Deal with wraparound, if it occurred, and
  293. * update the last read value so we can deal with wraparound on the next
  294. * call if necessary.
  295. *
  296. * Only necessary when going from off->on, to account for frames we
  297. * didn't get an interrupt for.
  298. *
  299. * Note: caller must hold dev->vbl_lock since this reads & writes
  300. * device vblank fields.
  301. */
  302. static void drm_update_vblank_count(struct drm_device *dev, int crtc)
  303. {
  304. u32 cur_vblank, diff;
  305. /*
  306. * Interrupts were disabled prior to this call, so deal with counter
  307. * wrap if needed.
  308. * NOTE! It's possible we lost a full dev->max_vblank_count events
  309. * here if the register is small or we had vblank interrupts off for
  310. * a long time.
  311. */
  312. cur_vblank = dev->driver->get_vblank_counter(dev, crtc);
  313. diff = cur_vblank - dev->last_vblank[crtc];
  314. if (cur_vblank < dev->last_vblank[crtc]) {
  315. diff += dev->max_vblank_count;
  316. DRM_DEBUG("last_vblank[%d]=0x%x, cur_vblank=0x%x => diff=0x%x\n",
  317. crtc, dev->last_vblank[crtc], cur_vblank, diff);
  318. }
  319. DRM_DEBUG("enabling vblank interrupts on crtc %d, missed %d\n",
  320. crtc, diff);
  321. atomic_add(diff, &dev->_vblank_count[crtc]);
  322. }
  323. /**
  324. * drm_vblank_get - get a reference count on vblank events
  325. * @dev: DRM device
  326. * @crtc: which CRTC to own
  327. *
  328. * Acquire a reference count on vblank events to avoid having them disabled
  329. * while in use.
  330. *
  331. * RETURNS
  332. * Zero on success, nonzero on failure.
  333. */
  334. int drm_vblank_get(struct drm_device *dev, int crtc)
  335. {
  336. unsigned long irqflags;
  337. int ret = 0;
  338. spin_lock_irqsave(&dev->vbl_lock, irqflags);
  339. /* Going from 0->1 means we have to enable interrupts again */
  340. if (atomic_add_return(1, &dev->vblank_refcount[crtc]) == 1 &&
  341. !dev->vblank_enabled[crtc]) {
  342. ret = dev->driver->enable_vblank(dev, crtc);
  343. DRM_DEBUG("enabling vblank on crtc %d, ret: %d\n", crtc, ret);
  344. if (ret)
  345. atomic_dec(&dev->vblank_refcount[crtc]);
  346. else {
  347. dev->vblank_enabled[crtc] = 1;
  348. drm_update_vblank_count(dev, crtc);
  349. }
  350. }
  351. spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
  352. return ret;
  353. }
  354. EXPORT_SYMBOL(drm_vblank_get);
  355. /**
  356. * drm_vblank_put - give up ownership of vblank events
  357. * @dev: DRM device
  358. * @crtc: which counter to give up
  359. *
  360. * Release ownership of a given vblank counter, turning off interrupts
  361. * if possible.
  362. */
  363. void drm_vblank_put(struct drm_device *dev, int crtc)
  364. {
  365. BUG_ON (atomic_read (&dev->vblank_refcount[crtc]) == 0);
  366. /* Last user schedules interrupt disable */
  367. if (atomic_dec_and_test(&dev->vblank_refcount[crtc]))
  368. mod_timer(&dev->vblank_disable_timer, jiffies + 5*DRM_HZ);
  369. }
  370. EXPORT_SYMBOL(drm_vblank_put);
  371. /**
  372. * drm_vblank_pre_modeset - account for vblanks across mode sets
  373. * @dev: DRM device
  374. * @crtc: CRTC in question
  375. * @post: post or pre mode set?
  376. *
  377. * Account for vblank events across mode setting events, which will likely
  378. * reset the hardware frame counter.
  379. */
  380. void drm_vblank_pre_modeset(struct drm_device *dev, int crtc)
  381. {
  382. /*
  383. * To avoid all the problems that might happen if interrupts
  384. * were enabled/disabled around or between these calls, we just
  385. * have the kernel take a reference on the CRTC (just once though
  386. * to avoid corrupting the count if multiple, mismatch calls occur),
  387. * so that interrupts remain enabled in the interim.
  388. */
  389. if (!dev->vblank_inmodeset[crtc]) {
  390. dev->vblank_inmodeset[crtc] = 0x1;
  391. if (drm_vblank_get(dev, crtc) == 0)
  392. dev->vblank_inmodeset[crtc] |= 0x2;
  393. }
  394. }
  395. EXPORT_SYMBOL(drm_vblank_pre_modeset);
  396. void drm_vblank_post_modeset(struct drm_device *dev, int crtc)
  397. {
  398. unsigned long irqflags;
  399. if (dev->vblank_inmodeset[crtc]) {
  400. spin_lock_irqsave(&dev->vbl_lock, irqflags);
  401. dev->vblank_disable_allowed = 1;
  402. spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
  403. if (dev->vblank_inmodeset[crtc] & 0x2)
  404. drm_vblank_put(dev, crtc);
  405. dev->vblank_inmodeset[crtc] = 0;
  406. }
  407. }
  408. EXPORT_SYMBOL(drm_vblank_post_modeset);
  409. /**
  410. * drm_modeset_ctl - handle vblank event counter changes across mode switch
  411. * @DRM_IOCTL_ARGS: standard ioctl arguments
  412. *
  413. * Applications should call the %_DRM_PRE_MODESET and %_DRM_POST_MODESET
  414. * ioctls around modesetting so that any lost vblank events are accounted for.
  415. *
  416. * Generally the counter will reset across mode sets. If interrupts are
  417. * enabled around this call, we don't have to do anything since the counter
  418. * will have already been incremented.
  419. */
  420. int drm_modeset_ctl(struct drm_device *dev, void *data,
  421. struct drm_file *file_priv)
  422. {
  423. struct drm_modeset_ctl *modeset = data;
  424. int crtc, ret = 0;
  425. /* If drm_vblank_init() hasn't been called yet, just no-op */
  426. if (!dev->num_crtcs)
  427. goto out;
  428. crtc = modeset->crtc;
  429. if (crtc >= dev->num_crtcs) {
  430. ret = -EINVAL;
  431. goto out;
  432. }
  433. switch (modeset->cmd) {
  434. case _DRM_PRE_MODESET:
  435. drm_vblank_pre_modeset(dev, crtc);
  436. break;
  437. case _DRM_POST_MODESET:
  438. drm_vblank_post_modeset(dev, crtc);
  439. break;
  440. default:
  441. ret = -EINVAL;
  442. break;
  443. }
  444. out:
  445. return ret;
  446. }
  447. /**
  448. * Wait for VBLANK.
  449. *
  450. * \param inode device inode.
  451. * \param file_priv DRM file private.
  452. * \param cmd command.
  453. * \param data user argument, pointing to a drm_wait_vblank structure.
  454. * \return zero on success or a negative number on failure.
  455. *
  456. * This function enables the vblank interrupt on the pipe requested, then
  457. * sleeps waiting for the requested sequence number to occur, and drops
  458. * the vblank interrupt refcount afterwards. (vblank irq disable follows that
  459. * after a timeout with no further vblank waits scheduled).
  460. */
  461. int drm_wait_vblank(struct drm_device *dev, void *data,
  462. struct drm_file *file_priv)
  463. {
  464. union drm_wait_vblank *vblwait = data;
  465. int ret = 0;
  466. unsigned int flags, seq, crtc;
  467. if ((!dev->pdev->irq) || (!dev->irq_enabled))
  468. return -EINVAL;
  469. if (vblwait->request.type & _DRM_VBLANK_SIGNAL)
  470. return -EINVAL;
  471. if (vblwait->request.type &
  472. ~(_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK)) {
  473. DRM_ERROR("Unsupported type value 0x%x, supported mask 0x%x\n",
  474. vblwait->request.type,
  475. (_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK));
  476. return -EINVAL;
  477. }
  478. flags = vblwait->request.type & _DRM_VBLANK_FLAGS_MASK;
  479. crtc = flags & _DRM_VBLANK_SECONDARY ? 1 : 0;
  480. if (crtc >= dev->num_crtcs)
  481. return -EINVAL;
  482. ret = drm_vblank_get(dev, crtc);
  483. if (ret) {
  484. DRM_ERROR("failed to acquire vblank counter, %d\n", ret);
  485. return ret;
  486. }
  487. seq = drm_vblank_count(dev, crtc);
  488. switch (vblwait->request.type & _DRM_VBLANK_TYPES_MASK) {
  489. case _DRM_VBLANK_RELATIVE:
  490. vblwait->request.sequence += seq;
  491. vblwait->request.type &= ~_DRM_VBLANK_RELATIVE;
  492. case _DRM_VBLANK_ABSOLUTE:
  493. break;
  494. default:
  495. ret = -EINVAL;
  496. goto done;
  497. }
  498. if ((flags & _DRM_VBLANK_NEXTONMISS) &&
  499. (seq - vblwait->request.sequence) <= (1<<23)) {
  500. vblwait->request.sequence = seq + 1;
  501. }
  502. DRM_DEBUG("waiting on vblank count %d, crtc %d\n",
  503. vblwait->request.sequence, crtc);
  504. dev->last_vblank_wait[crtc] = vblwait->request.sequence;
  505. DRM_WAIT_ON(ret, dev->vbl_queue[crtc], 3 * DRM_HZ,
  506. (((drm_vblank_count(dev, crtc) -
  507. vblwait->request.sequence) <= (1 << 23)) ||
  508. !dev->irq_enabled));
  509. if (ret != -EINTR) {
  510. struct timeval now;
  511. do_gettimeofday(&now);
  512. vblwait->reply.tval_sec = now.tv_sec;
  513. vblwait->reply.tval_usec = now.tv_usec;
  514. vblwait->reply.sequence = drm_vblank_count(dev, crtc);
  515. DRM_DEBUG("returning %d to client\n",
  516. vblwait->reply.sequence);
  517. } else {
  518. DRM_DEBUG("vblank wait interrupted by signal\n");
  519. }
  520. done:
  521. drm_vblank_put(dev, crtc);
  522. return ret;
  523. }
  524. /**
  525. * drm_handle_vblank - handle a vblank event
  526. * @dev: DRM device
  527. * @crtc: where this event occurred
  528. *
  529. * Drivers should call this routine in their vblank interrupt handlers to
  530. * update the vblank counter and send any signals that may be pending.
  531. */
  532. void drm_handle_vblank(struct drm_device *dev, int crtc)
  533. {
  534. atomic_inc(&dev->_vblank_count[crtc]);
  535. DRM_WAKEUP(&dev->vbl_queue[crtc]);
  536. }
  537. EXPORT_SYMBOL(drm_handle_vblank);