drm_drv.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. /*
  2. * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
  3. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
  4. * Copyright (c) 2009-2010, Code Aurora Forum.
  5. * Copyright 2016 Intel Corp.
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a
  8. * copy of this software and associated documentation files (the "Software"),
  9. * to deal in the Software without restriction, including without limitation
  10. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11. * and/or sell copies of the Software, and to permit persons to whom the
  12. * Software is furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice (including the next
  15. * paragraph) shall be included in all copies or substantial portions of the
  16. * Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  21. * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  22. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  23. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  24. * OTHER DEALINGS IN THE SOFTWARE.
  25. */
  26. #ifndef _DRM_DRV_H_
  27. #define _DRM_DRV_H_
  28. #include <linux/list.h>
  29. #include <linux/irqreturn.h>
  30. #include <drm/drm_device.h>
  31. struct drm_file;
  32. struct drm_gem_object;
  33. struct drm_master;
  34. struct drm_minor;
  35. struct dma_buf_attachment;
  36. struct drm_display_mode;
  37. struct drm_mode_create_dumb;
  38. /* driver capabilities and requirements mask */
  39. #define DRIVER_USE_AGP 0x1
  40. #define DRIVER_LEGACY 0x2
  41. #define DRIVER_PCI_DMA 0x8
  42. #define DRIVER_SG 0x10
  43. #define DRIVER_HAVE_DMA 0x20
  44. #define DRIVER_HAVE_IRQ 0x40
  45. #define DRIVER_IRQ_SHARED 0x80
  46. #define DRIVER_GEM 0x1000
  47. #define DRIVER_MODESET 0x2000
  48. #define DRIVER_PRIME 0x4000
  49. #define DRIVER_RENDER 0x8000
  50. #define DRIVER_ATOMIC 0x10000
  51. #define DRIVER_KMS_LEGACY_CONTEXT 0x20000
  52. #define DRIVER_SYNCOBJ 0x40000
  53. #define DRIVER_PREFER_XBGR_30BPP 0x80000
  54. /**
  55. * struct drm_driver - DRM driver structure
  56. *
  57. * This structure represent the common code for a family of cards. There will
  58. * one drm_device for each card present in this family. It contains lots of
  59. * vfunc entries, and a pile of those probably should be moved to more
  60. * appropriate places like &drm_mode_config_funcs or into a new operations
  61. * structure for GEM drivers.
  62. */
  63. struct drm_driver {
  64. /**
  65. * @load:
  66. *
  67. * Backward-compatible driver callback to complete
  68. * initialization steps after the driver is registered. For
  69. * this reason, may suffer from race conditions and its use is
  70. * deprecated for new drivers. It is therefore only supported
  71. * for existing drivers not yet converted to the new scheme.
  72. * See drm_dev_init() and drm_dev_register() for proper and
  73. * race-free way to set up a &struct drm_device.
  74. *
  75. * This is deprecated, do not use!
  76. *
  77. * Returns:
  78. *
  79. * Zero on success, non-zero value on failure.
  80. */
  81. int (*load) (struct drm_device *, unsigned long flags);
  82. /**
  83. * @open:
  84. *
  85. * Driver callback when a new &struct drm_file is opened. Useful for
  86. * setting up driver-private data structures like buffer allocators,
  87. * execution contexts or similar things. Such driver-private resources
  88. * must be released again in @postclose.
  89. *
  90. * Since the display/modeset side of DRM can only be owned by exactly
  91. * one &struct drm_file (see &drm_file.is_master and &drm_device.master)
  92. * there should never be a need to set up any modeset related resources
  93. * in this callback. Doing so would be a driver design bug.
  94. *
  95. * Returns:
  96. *
  97. * 0 on success, a negative error code on failure, which will be
  98. * promoted to userspace as the result of the open() system call.
  99. */
  100. int (*open) (struct drm_device *, struct drm_file *);
  101. /**
  102. * @postclose:
  103. *
  104. * One of the driver callbacks when a new &struct drm_file is closed.
  105. * Useful for tearing down driver-private data structures allocated in
  106. * @open like buffer allocators, execution contexts or similar things.
  107. *
  108. * Since the display/modeset side of DRM can only be owned by exactly
  109. * one &struct drm_file (see &drm_file.is_master and &drm_device.master)
  110. * there should never be a need to tear down any modeset related
  111. * resources in this callback. Doing so would be a driver design bug.
  112. */
  113. void (*postclose) (struct drm_device *, struct drm_file *);
  114. /**
  115. * @lastclose:
  116. *
  117. * Called when the last &struct drm_file has been closed and there's
  118. * currently no userspace client for the &struct drm_device.
  119. *
  120. * Modern drivers should only use this to force-restore the fbdev
  121. * framebuffer using drm_fb_helper_restore_fbdev_mode_unlocked().
  122. * Anything else would indicate there's something seriously wrong.
  123. * Modern drivers can also use this to execute delayed power switching
  124. * state changes, e.g. in conjunction with the :ref:`vga_switcheroo`
  125. * infrastructure.
  126. *
  127. * This is called after @postclose hook has been called.
  128. *
  129. * NOTE:
  130. *
  131. * All legacy drivers use this callback to de-initialize the hardware.
  132. * This is purely because of the shadow-attach model, where the DRM
  133. * kernel driver does not really own the hardware. Instead ownershipe is
  134. * handled with the help of userspace through an inheritedly racy dance
  135. * to set/unset the VT into raw mode.
  136. *
  137. * Legacy drivers initialize the hardware in the @firstopen callback,
  138. * which isn't even called for modern drivers.
  139. */
  140. void (*lastclose) (struct drm_device *);
  141. /**
  142. * @unload:
  143. *
  144. * Reverse the effects of the driver load callback. Ideally,
  145. * the clean up performed by the driver should happen in the
  146. * reverse order of the initialization. Similarly to the load
  147. * hook, this handler is deprecated and its usage should be
  148. * dropped in favor of an open-coded teardown function at the
  149. * driver layer. See drm_dev_unregister() and drm_dev_unref()
  150. * for the proper way to remove a &struct drm_device.
  151. *
  152. * The unload() hook is called right after unregistering
  153. * the device.
  154. *
  155. */
  156. void (*unload) (struct drm_device *);
  157. /**
  158. * @release:
  159. *
  160. * Optional callback for destroying device data after the final
  161. * reference is released, i.e. the device is being destroyed. Drivers
  162. * using this callback are responsible for calling drm_dev_fini()
  163. * to finalize the device and then freeing the struct themselves.
  164. */
  165. void (*release) (struct drm_device *);
  166. /**
  167. * @get_vblank_counter:
  168. *
  169. * Driver callback for fetching a raw hardware vblank counter for the
  170. * CRTC specified with the pipe argument. If a device doesn't have a
  171. * hardware counter, the driver can simply leave the hook as NULL.
  172. * The DRM core will account for missed vblank events while interrupts
  173. * where disabled based on system timestamps.
  174. *
  175. * Wraparound handling and loss of events due to modesetting is dealt
  176. * with in the DRM core code, as long as drivers call
  177. * drm_crtc_vblank_off() and drm_crtc_vblank_on() when disabling or
  178. * enabling a CRTC.
  179. *
  180. * This is deprecated and should not be used by new drivers.
  181. * Use &drm_crtc_funcs.get_vblank_counter instead.
  182. *
  183. * Returns:
  184. *
  185. * Raw vblank counter value.
  186. */
  187. u32 (*get_vblank_counter) (struct drm_device *dev, unsigned int pipe);
  188. /**
  189. * @enable_vblank:
  190. *
  191. * Enable vblank interrupts for the CRTC specified with the pipe
  192. * argument.
  193. *
  194. * This is deprecated and should not be used by new drivers.
  195. * Use &drm_crtc_funcs.enable_vblank instead.
  196. *
  197. * Returns:
  198. *
  199. * Zero on success, appropriate errno if the given @crtc's vblank
  200. * interrupt cannot be enabled.
  201. */
  202. int (*enable_vblank) (struct drm_device *dev, unsigned int pipe);
  203. /**
  204. * @disable_vblank:
  205. *
  206. * Disable vblank interrupts for the CRTC specified with the pipe
  207. * argument.
  208. *
  209. * This is deprecated and should not be used by new drivers.
  210. * Use &drm_crtc_funcs.disable_vblank instead.
  211. */
  212. void (*disable_vblank) (struct drm_device *dev, unsigned int pipe);
  213. /**
  214. * @get_scanout_position:
  215. *
  216. * Called by vblank timestamping code.
  217. *
  218. * Returns the current display scanout position from a crtc, and an
  219. * optional accurate ktime_get() timestamp of when position was
  220. * measured. Note that this is a helper callback which is only used if a
  221. * driver uses drm_calc_vbltimestamp_from_scanoutpos() for the
  222. * @get_vblank_timestamp callback.
  223. *
  224. * Parameters:
  225. *
  226. * dev:
  227. * DRM device.
  228. * pipe:
  229. * Id of the crtc to query.
  230. * in_vblank_irq:
  231. * True when called from drm_crtc_handle_vblank(). Some drivers
  232. * need to apply some workarounds for gpu-specific vblank irq quirks
  233. * if flag is set.
  234. * vpos:
  235. * Target location for current vertical scanout position.
  236. * hpos:
  237. * Target location for current horizontal scanout position.
  238. * stime:
  239. * Target location for timestamp taken immediately before
  240. * scanout position query. Can be NULL to skip timestamp.
  241. * etime:
  242. * Target location for timestamp taken immediately after
  243. * scanout position query. Can be NULL to skip timestamp.
  244. * mode:
  245. * Current display timings.
  246. *
  247. * Returns vpos as a positive number while in active scanout area.
  248. * Returns vpos as a negative number inside vblank, counting the number
  249. * of scanlines to go until end of vblank, e.g., -1 means "one scanline
  250. * until start of active scanout / end of vblank."
  251. *
  252. * Returns:
  253. *
  254. * True on success, false if a reliable scanout position counter could
  255. * not be read out.
  256. *
  257. * FIXME:
  258. *
  259. * Since this is a helper to implement @get_vblank_timestamp, we should
  260. * move it to &struct drm_crtc_helper_funcs, like all the other
  261. * helper-internal hooks.
  262. */
  263. bool (*get_scanout_position) (struct drm_device *dev, unsigned int pipe,
  264. bool in_vblank_irq, int *vpos, int *hpos,
  265. ktime_t *stime, ktime_t *etime,
  266. const struct drm_display_mode *mode);
  267. /**
  268. * @get_vblank_timestamp:
  269. *
  270. * Called by drm_get_last_vbltimestamp(). Should return a precise
  271. * timestamp when the most recent VBLANK interval ended or will end.
  272. *
  273. * Specifically, the timestamp in @vblank_time should correspond as
  274. * closely as possible to the time when the first video scanline of
  275. * the video frame after the end of VBLANK will start scanning out,
  276. * the time immediately after end of the VBLANK interval. If the
  277. * @crtc is currently inside VBLANK, this will be a time in the future.
  278. * If the @crtc is currently scanning out a frame, this will be the
  279. * past start time of the current scanout. This is meant to adhere
  280. * to the OpenML OML_sync_control extension specification.
  281. *
  282. * Paramters:
  283. *
  284. * dev:
  285. * dev DRM device handle.
  286. * pipe:
  287. * crtc for which timestamp should be returned.
  288. * max_error:
  289. * Maximum allowable timestamp error in nanoseconds.
  290. * Implementation should strive to provide timestamp
  291. * with an error of at most max_error nanoseconds.
  292. * Returns true upper bound on error for timestamp.
  293. * vblank_time:
  294. * Target location for returned vblank timestamp.
  295. * in_vblank_irq:
  296. * True when called from drm_crtc_handle_vblank(). Some drivers
  297. * need to apply some workarounds for gpu-specific vblank irq quirks
  298. * if flag is set.
  299. *
  300. * Returns:
  301. *
  302. * True on success, false on failure, which means the core should
  303. * fallback to a simple timestamp taken in drm_crtc_handle_vblank().
  304. *
  305. * FIXME:
  306. *
  307. * We should move this hook to &struct drm_crtc_funcs like all the other
  308. * vblank hooks.
  309. */
  310. bool (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
  311. int *max_error,
  312. struct timeval *vblank_time,
  313. bool in_vblank_irq);
  314. /**
  315. * @irq_handler:
  316. *
  317. * Interrupt handler called when using drm_irq_install(). Not used by
  318. * drivers which implement their own interrupt handling.
  319. */
  320. irqreturn_t(*irq_handler) (int irq, void *arg);
  321. /**
  322. * @irq_preinstall:
  323. *
  324. * Optional callback used by drm_irq_install() which is called before
  325. * the interrupt handler is registered. This should be used to clear out
  326. * any pending interrupts (from e.g. firmware based drives) and reset
  327. * the interrupt handling registers.
  328. */
  329. void (*irq_preinstall) (struct drm_device *dev);
  330. /**
  331. * @irq_postinstall:
  332. *
  333. * Optional callback used by drm_irq_install() which is called after
  334. * the interrupt handler is registered. This should be used to enable
  335. * interrupt generation in the hardware.
  336. */
  337. int (*irq_postinstall) (struct drm_device *dev);
  338. /**
  339. * @irq_uninstall:
  340. *
  341. * Optional callback used by drm_irq_uninstall() which is called before
  342. * the interrupt handler is unregistered. This should be used to disable
  343. * interrupt generation in the hardware.
  344. */
  345. void (*irq_uninstall) (struct drm_device *dev);
  346. /**
  347. * @master_create:
  348. *
  349. * Called whenever a new master is created. Only used by vmwgfx.
  350. */
  351. int (*master_create)(struct drm_device *dev, struct drm_master *master);
  352. /**
  353. * @master_destroy:
  354. *
  355. * Called whenever a master is destroyed. Only used by vmwgfx.
  356. */
  357. void (*master_destroy)(struct drm_device *dev, struct drm_master *master);
  358. /**
  359. * @master_set:
  360. *
  361. * Called whenever the minor master is set. Only used by vmwgfx.
  362. */
  363. int (*master_set)(struct drm_device *dev, struct drm_file *file_priv,
  364. bool from_open);
  365. /**
  366. * @master_drop:
  367. *
  368. * Called whenever the minor master is dropped. Only used by vmwgfx.
  369. */
  370. void (*master_drop)(struct drm_device *dev, struct drm_file *file_priv);
  371. /**
  372. * @debugfs_init:
  373. *
  374. * Allows drivers to create driver-specific debugfs files.
  375. */
  376. int (*debugfs_init)(struct drm_minor *minor);
  377. /**
  378. * @gem_free_object: deconstructor for drm_gem_objects
  379. *
  380. * This is deprecated and should not be used by new drivers. Use
  381. * @gem_free_object_unlocked instead.
  382. */
  383. void (*gem_free_object) (struct drm_gem_object *obj);
  384. /**
  385. * @gem_free_object_unlocked: deconstructor for drm_gem_objects
  386. *
  387. * This is for drivers which are not encumbered with &drm_device.struct_mutex
  388. * legacy locking schemes. Use this hook instead of @gem_free_object.
  389. */
  390. void (*gem_free_object_unlocked) (struct drm_gem_object *obj);
  391. /**
  392. * @gem_open_object:
  393. *
  394. * Driver hook called upon gem handle creation
  395. */
  396. int (*gem_open_object) (struct drm_gem_object *, struct drm_file *);
  397. /**
  398. * @gem_close_object:
  399. *
  400. * Driver hook called upon gem handle release
  401. */
  402. void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
  403. /**
  404. * @gem_create_object: constructor for gem objects
  405. *
  406. * Hook for allocating the GEM object struct, for use by core
  407. * helpers.
  408. */
  409. struct drm_gem_object *(*gem_create_object)(struct drm_device *dev,
  410. size_t size);
  411. /* prime: */
  412. /**
  413. * @prime_handle_to_fd:
  414. *
  415. * export handle -> fd (see drm_gem_prime_handle_to_fd() helper)
  416. */
  417. int (*prime_handle_to_fd)(struct drm_device *dev, struct drm_file *file_priv,
  418. uint32_t handle, uint32_t flags, int *prime_fd);
  419. /**
  420. * @prime_fd_to_handle:
  421. *
  422. * import fd -> handle (see drm_gem_prime_fd_to_handle() helper)
  423. */
  424. int (*prime_fd_to_handle)(struct drm_device *dev, struct drm_file *file_priv,
  425. int prime_fd, uint32_t *handle);
  426. /**
  427. * @gem_prime_export:
  428. *
  429. * export GEM -> dmabuf
  430. */
  431. struct dma_buf * (*gem_prime_export)(struct drm_device *dev,
  432. struct drm_gem_object *obj, int flags);
  433. /**
  434. * @gem_prime_import:
  435. *
  436. * import dmabuf -> GEM
  437. */
  438. struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev,
  439. struct dma_buf *dma_buf);
  440. int (*gem_prime_pin)(struct drm_gem_object *obj);
  441. void (*gem_prime_unpin)(struct drm_gem_object *obj);
  442. struct reservation_object * (*gem_prime_res_obj)(
  443. struct drm_gem_object *obj);
  444. struct sg_table *(*gem_prime_get_sg_table)(struct drm_gem_object *obj);
  445. struct drm_gem_object *(*gem_prime_import_sg_table)(
  446. struct drm_device *dev,
  447. struct dma_buf_attachment *attach,
  448. struct sg_table *sgt);
  449. void *(*gem_prime_vmap)(struct drm_gem_object *obj);
  450. void (*gem_prime_vunmap)(struct drm_gem_object *obj, void *vaddr);
  451. int (*gem_prime_mmap)(struct drm_gem_object *obj,
  452. struct vm_area_struct *vma);
  453. /**
  454. * @dumb_create:
  455. *
  456. * This creates a new dumb buffer in the driver's backing storage manager (GEM,
  457. * TTM or something else entirely) and returns the resulting buffer handle. This
  458. * handle can then be wrapped up into a framebuffer modeset object.
  459. *
  460. * Note that userspace is not allowed to use such objects for render
  461. * acceleration - drivers must create their own private ioctls for such a use
  462. * case.
  463. *
  464. * Width, height and depth are specified in the &drm_mode_create_dumb
  465. * argument. The callback needs to fill the handle, pitch and size for
  466. * the created buffer.
  467. *
  468. * Called by the user via ioctl.
  469. *
  470. * Returns:
  471. *
  472. * Zero on success, negative errno on failure.
  473. */
  474. int (*dumb_create)(struct drm_file *file_priv,
  475. struct drm_device *dev,
  476. struct drm_mode_create_dumb *args);
  477. /**
  478. * @dumb_map_offset:
  479. *
  480. * Allocate an offset in the drm device node's address space to be able to
  481. * memory map a dumb buffer. GEM-based drivers must use
  482. * drm_gem_create_mmap_offset() to implement this.
  483. *
  484. * Called by the user via ioctl.
  485. *
  486. * Returns:
  487. *
  488. * Zero on success, negative errno on failure.
  489. */
  490. int (*dumb_map_offset)(struct drm_file *file_priv,
  491. struct drm_device *dev, uint32_t handle,
  492. uint64_t *offset);
  493. /**
  494. * @dumb_destroy:
  495. *
  496. * This destroys the userspace handle for the given dumb backing storage buffer.
  497. * Since buffer objects must be reference counted in the kernel a buffer object
  498. * won't be immediately freed if a framebuffer modeset object still uses it.
  499. *
  500. * Called by the user via ioctl.
  501. *
  502. * Returns:
  503. *
  504. * Zero on success, negative errno on failure.
  505. */
  506. int (*dumb_destroy)(struct drm_file *file_priv,
  507. struct drm_device *dev,
  508. uint32_t handle);
  509. /**
  510. * @gem_vm_ops: Driver private ops for this object
  511. */
  512. const struct vm_operations_struct *gem_vm_ops;
  513. /** @major: driver major number */
  514. int major;
  515. /** @minor: driver minor number */
  516. int minor;
  517. /** @patchlevel: driver patch level */
  518. int patchlevel;
  519. /** @name: driver name */
  520. char *name;
  521. /** @desc: driver description */
  522. char *desc;
  523. /** @date: driver date */
  524. char *date;
  525. /** @driver_features: driver features */
  526. u32 driver_features;
  527. /**
  528. * @ioctls:
  529. *
  530. * Array of driver-private IOCTL description entries. See the chapter on
  531. * :ref:`IOCTL support in the userland interfaces
  532. * chapter<drm_driver_ioctl>` for the full details.
  533. */
  534. const struct drm_ioctl_desc *ioctls;
  535. /** @num_ioctls: Number of entries in @ioctls. */
  536. int num_ioctls;
  537. /**
  538. * @fops:
  539. *
  540. * File operations for the DRM device node. See the discussion in
  541. * :ref:`file operations<drm_driver_fops>` for in-depth coverage and
  542. * some examples.
  543. */
  544. const struct file_operations *fops;
  545. /* Everything below here is for legacy driver, never use! */
  546. /* private: */
  547. /* List of devices hanging off this driver with stealth attach. */
  548. struct list_head legacy_dev_list;
  549. int (*firstopen) (struct drm_device *);
  550. void (*preclose) (struct drm_device *, struct drm_file *file_priv);
  551. int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
  552. int (*dma_quiescent) (struct drm_device *);
  553. int (*context_dtor) (struct drm_device *dev, int context);
  554. int dev_priv_size;
  555. };
  556. __printf(6, 7)
  557. void drm_dev_printk(const struct device *dev, const char *level,
  558. unsigned int category, const char *function_name,
  559. const char *prefix, const char *format, ...);
  560. __printf(3, 4)
  561. void drm_printk(const char *level, unsigned int category,
  562. const char *format, ...);
  563. extern unsigned int drm_debug;
  564. int drm_dev_init(struct drm_device *dev,
  565. struct drm_driver *driver,
  566. struct device *parent);
  567. void drm_dev_fini(struct drm_device *dev);
  568. struct drm_device *drm_dev_alloc(struct drm_driver *driver,
  569. struct device *parent);
  570. int drm_dev_register(struct drm_device *dev, unsigned long flags);
  571. void drm_dev_unregister(struct drm_device *dev);
  572. void drm_dev_ref(struct drm_device *dev);
  573. void drm_dev_unref(struct drm_device *dev);
  574. void drm_put_dev(struct drm_device *dev);
  575. void drm_dev_unplug(struct drm_device *dev);
  576. /**
  577. * drm_dev_is_unplugged - is a DRM device unplugged
  578. * @dev: DRM device
  579. *
  580. * This function can be called to check whether a hotpluggable is unplugged.
  581. * Unplugging itself is singalled through drm_dev_unplug(). If a device is
  582. * unplugged, these two functions guarantee that any store before calling
  583. * drm_dev_unplug() is visible to callers of this function after it completes
  584. */
  585. static inline int drm_dev_is_unplugged(struct drm_device *dev)
  586. {
  587. int ret = atomic_read(&dev->unplugged);
  588. smp_rmb();
  589. return ret;
  590. }
  591. int drm_dev_set_unique(struct drm_device *dev, const char *name);
  592. #endif