drm_drv.h 20 KB

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