drmP.h 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149
  1. /*
  2. * Internal Header for the Direct Rendering Manager
  3. *
  4. * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
  5. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
  6. * Copyright (c) 2009-2010, Code Aurora Forum.
  7. * All rights reserved.
  8. *
  9. * Author: Rickard E. (Rik) Faith <faith@valinux.com>
  10. * Author: Gareth Hughes <gareth@valinux.com>
  11. *
  12. * Permission is hereby granted, free of charge, to any person obtaining a
  13. * copy of this software and associated documentation files (the "Software"),
  14. * to deal in the Software without restriction, including without limitation
  15. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  16. * and/or sell copies of the Software, and to permit persons to whom the
  17. * Software is furnished to do so, subject to the following conditions:
  18. *
  19. * The above copyright notice and this permission notice (including the next
  20. * paragraph) shall be included in all copies or substantial portions of the
  21. * Software.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  25. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  26. * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  27. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  28. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  29. * OTHER DEALINGS IN THE SOFTWARE.
  30. */
  31. #ifndef _DRM_P_H_
  32. #define _DRM_P_H_
  33. #include <linux/agp_backend.h>
  34. #include <linux/cdev.h>
  35. #include <linux/dma-mapping.h>
  36. #include <linux/file.h>
  37. #include <linux/fs.h>
  38. #include <linux/highmem.h>
  39. #include <linux/idr.h>
  40. #include <linux/init.h>
  41. #include <linux/io.h>
  42. #include <linux/jiffies.h>
  43. #include <linux/kernel.h>
  44. #include <linux/kref.h>
  45. #include <linux/miscdevice.h>
  46. #include <linux/mm.h>
  47. #include <linux/mutex.h>
  48. #include <linux/pci.h>
  49. #include <linux/platform_device.h>
  50. #include <linux/poll.h>
  51. #include <linux/ratelimit.h>
  52. #include <linux/sched.h>
  53. #include <linux/slab.h>
  54. #include <linux/types.h>
  55. #include <linux/vmalloc.h>
  56. #include <linux/workqueue.h>
  57. #include <asm/mman.h>
  58. #include <asm/pgalloc.h>
  59. #include <asm/uaccess.h>
  60. #include <uapi/drm/drm.h>
  61. #include <uapi/drm/drm_mode.h>
  62. #include <drm/drm_agpsupport.h>
  63. #include <drm/drm_crtc.h>
  64. #include <drm/drm_global.h>
  65. #include <drm/drm_hashtab.h>
  66. #include <drm/drm_mem_util.h>
  67. #include <drm/drm_mm.h>
  68. #include <drm/drm_os_linux.h>
  69. #include <drm/drm_sarea.h>
  70. #include <drm/drm_vma_manager.h>
  71. struct module;
  72. struct drm_file;
  73. struct drm_device;
  74. struct drm_agp_head;
  75. struct drm_local_map;
  76. struct drm_device_dma;
  77. struct drm_dma_handle;
  78. struct drm_gem_object;
  79. struct device_node;
  80. struct videomode;
  81. struct reservation_object;
  82. struct dma_buf_attachment;
  83. /*
  84. * 4 debug categories are defined:
  85. *
  86. * CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, drm_memory.c, ...
  87. * This is the category used by the DRM_DEBUG() macro.
  88. *
  89. * DRIVER: Used in the vendor specific part of the driver: i915, radeon, ...
  90. * This is the category used by the DRM_DEBUG_DRIVER() macro.
  91. *
  92. * KMS: used in the modesetting code.
  93. * This is the category used by the DRM_DEBUG_KMS() macro.
  94. *
  95. * PRIME: used in the prime code.
  96. * This is the category used by the DRM_DEBUG_PRIME() macro.
  97. *
  98. * ATOMIC: used in the atomic code.
  99. * This is the category used by the DRM_DEBUG_ATOMIC() macro.
  100. *
  101. * VBL: used for verbose debug message in the vblank code
  102. * This is the category used by the DRM_DEBUG_VBL() macro.
  103. *
  104. * Enabling verbose debug messages is done through the drm.debug parameter,
  105. * each category being enabled by a bit.
  106. *
  107. * drm.debug=0x1 will enable CORE messages
  108. * drm.debug=0x2 will enable DRIVER messages
  109. * drm.debug=0x3 will enable CORE and DRIVER messages
  110. * ...
  111. * drm.debug=0x3f will enable all messages
  112. *
  113. * An interesting feature is that it's possible to enable verbose logging at
  114. * run-time by echoing the debug value in its sysfs node:
  115. * # echo 0xf > /sys/module/drm/parameters/debug
  116. */
  117. #define DRM_UT_CORE 0x01
  118. #define DRM_UT_DRIVER 0x02
  119. #define DRM_UT_KMS 0x04
  120. #define DRM_UT_PRIME 0x08
  121. #define DRM_UT_ATOMIC 0x10
  122. #define DRM_UT_VBL 0x20
  123. extern __printf(2, 3)
  124. void drm_ut_debug_printk(const char *function_name,
  125. const char *format, ...);
  126. extern __printf(1, 2)
  127. void drm_err(const char *format, ...);
  128. /***********************************************************************/
  129. /** \name DRM template customization defaults */
  130. /*@{*/
  131. /* driver capabilities and requirements mask */
  132. #define DRIVER_USE_AGP 0x1
  133. #define DRIVER_PCI_DMA 0x8
  134. #define DRIVER_SG 0x10
  135. #define DRIVER_HAVE_DMA 0x20
  136. #define DRIVER_HAVE_IRQ 0x40
  137. #define DRIVER_IRQ_SHARED 0x80
  138. #define DRIVER_GEM 0x1000
  139. #define DRIVER_MODESET 0x2000
  140. #define DRIVER_PRIME 0x4000
  141. #define DRIVER_RENDER 0x8000
  142. #define DRIVER_ATOMIC 0x10000
  143. #define DRIVER_KMS_LEGACY_CONTEXT 0x20000
  144. /***********************************************************************/
  145. /** \name Macros to make printk easier */
  146. /*@{*/
  147. /**
  148. * Error output.
  149. *
  150. * \param fmt printf() like format string.
  151. * \param arg arguments
  152. */
  153. #define DRM_ERROR(fmt, ...) \
  154. drm_err(fmt, ##__VA_ARGS__)
  155. /**
  156. * Rate limited error output. Like DRM_ERROR() but won't flood the log.
  157. *
  158. * \param fmt printf() like format string.
  159. * \param arg arguments
  160. */
  161. #define DRM_ERROR_RATELIMITED(fmt, ...) \
  162. ({ \
  163. static DEFINE_RATELIMIT_STATE(_rs, \
  164. DEFAULT_RATELIMIT_INTERVAL, \
  165. DEFAULT_RATELIMIT_BURST); \
  166. \
  167. if (__ratelimit(&_rs)) \
  168. drm_err(fmt, ##__VA_ARGS__); \
  169. })
  170. #define DRM_INFO(fmt, ...) \
  171. printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
  172. #define DRM_INFO_ONCE(fmt, ...) \
  173. printk_once(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
  174. /**
  175. * Debug output.
  176. *
  177. * \param fmt printf() like format string.
  178. * \param arg arguments
  179. */
  180. #define DRM_DEBUG(fmt, args...) \
  181. do { \
  182. if (unlikely(drm_debug & DRM_UT_CORE)) \
  183. drm_ut_debug_printk(__func__, fmt, ##args); \
  184. } while (0)
  185. #define DRM_DEBUG_DRIVER(fmt, args...) \
  186. do { \
  187. if (unlikely(drm_debug & DRM_UT_DRIVER)) \
  188. drm_ut_debug_printk(__func__, fmt, ##args); \
  189. } while (0)
  190. #define DRM_DEBUG_KMS(fmt, args...) \
  191. do { \
  192. if (unlikely(drm_debug & DRM_UT_KMS)) \
  193. drm_ut_debug_printk(__func__, fmt, ##args); \
  194. } while (0)
  195. #define DRM_DEBUG_PRIME(fmt, args...) \
  196. do { \
  197. if (unlikely(drm_debug & DRM_UT_PRIME)) \
  198. drm_ut_debug_printk(__func__, fmt, ##args); \
  199. } while (0)
  200. #define DRM_DEBUG_ATOMIC(fmt, args...) \
  201. do { \
  202. if (unlikely(drm_debug & DRM_UT_ATOMIC)) \
  203. drm_ut_debug_printk(__func__, fmt, ##args); \
  204. } while (0)
  205. #define DRM_DEBUG_VBL(fmt, args...) \
  206. do { \
  207. if (unlikely(drm_debug & DRM_UT_VBL)) \
  208. drm_ut_debug_printk(__func__, fmt, ##args); \
  209. } while (0)
  210. /*@}*/
  211. /***********************************************************************/
  212. /** \name Internal types and structures */
  213. /*@{*/
  214. #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
  215. /**
  216. * Ioctl function type.
  217. *
  218. * \param inode device inode.
  219. * \param file_priv DRM file private pointer.
  220. * \param cmd command.
  221. * \param arg argument.
  222. */
  223. typedef int drm_ioctl_t(struct drm_device *dev, void *data,
  224. struct drm_file *file_priv);
  225. typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
  226. unsigned long arg);
  227. #define DRM_IOCTL_NR(n) _IOC_NR(n)
  228. #define DRM_MAJOR 226
  229. #define DRM_AUTH 0x1
  230. #define DRM_MASTER 0x2
  231. #define DRM_ROOT_ONLY 0x4
  232. #define DRM_CONTROL_ALLOW 0x8
  233. #define DRM_UNLOCKED 0x10
  234. #define DRM_RENDER_ALLOW 0x20
  235. struct drm_ioctl_desc {
  236. unsigned int cmd;
  237. int flags;
  238. drm_ioctl_t *func;
  239. const char *name;
  240. };
  241. /**
  242. * Creates a driver or general drm_ioctl_desc array entry for the given
  243. * ioctl, for use by drm_ioctl().
  244. */
  245. #define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \
  246. [DRM_IOCTL_NR(DRM_IOCTL_##ioctl) - DRM_COMMAND_BASE] = { \
  247. .cmd = DRM_IOCTL_##ioctl, \
  248. .func = _func, \
  249. .flags = _flags, \
  250. .name = #ioctl \
  251. }
  252. /* Event queued up for userspace to read */
  253. struct drm_pending_event {
  254. struct drm_event *event;
  255. struct list_head link;
  256. struct list_head pending_link;
  257. struct drm_file *file_priv;
  258. pid_t pid; /* pid of requester, no guarantee it's valid by the time
  259. we deliver the event, for tracing only */
  260. void (*destroy)(struct drm_pending_event *event);
  261. };
  262. /* initial implementaton using a linked list - todo hashtab */
  263. struct drm_prime_file_private {
  264. struct list_head head;
  265. struct mutex lock;
  266. };
  267. /** File private data */
  268. struct drm_file {
  269. unsigned authenticated :1;
  270. /* Whether we're master for a minor. Protected by master_mutex */
  271. unsigned is_master :1;
  272. /* true when the client has asked us to expose stereo 3D mode flags */
  273. unsigned stereo_allowed :1;
  274. /*
  275. * true if client understands CRTC primary planes and cursor planes
  276. * in the plane list
  277. */
  278. unsigned universal_planes:1;
  279. /* true if client understands atomic properties */
  280. unsigned atomic:1;
  281. /*
  282. * This client is allowed to gain master privileges for @master.
  283. * Protected by struct drm_device::master_mutex.
  284. */
  285. unsigned allowed_master:1;
  286. struct pid *pid;
  287. kuid_t uid;
  288. drm_magic_t magic;
  289. struct list_head lhead;
  290. struct drm_minor *minor;
  291. unsigned long lock_count;
  292. /** Mapping of mm object handles to object pointers. */
  293. struct idr object_idr;
  294. /** Lock for synchronization of access to object_idr. */
  295. spinlock_t table_lock;
  296. struct file *filp;
  297. void *driver_priv;
  298. struct drm_master *master; /* master this node is currently associated with
  299. N.B. not always minor->master */
  300. /**
  301. * fbs - List of framebuffers associated with this file.
  302. *
  303. * Protected by fbs_lock. Note that the fbs list holds a reference on
  304. * the fb object to prevent it from untimely disappearing.
  305. */
  306. struct list_head fbs;
  307. struct mutex fbs_lock;
  308. /** User-created blob properties; this retains a reference on the
  309. * property. */
  310. struct list_head blobs;
  311. wait_queue_head_t event_wait;
  312. struct list_head pending_event_list;
  313. struct list_head event_list;
  314. int event_space;
  315. struct mutex event_read_lock;
  316. struct drm_prime_file_private prime;
  317. };
  318. /**
  319. * Lock data.
  320. */
  321. struct drm_lock_data {
  322. struct drm_hw_lock *hw_lock; /**< Hardware lock */
  323. /** Private of lock holder's file (NULL=kernel) */
  324. struct drm_file *file_priv;
  325. wait_queue_head_t lock_queue; /**< Queue of blocked processes */
  326. unsigned long lock_time; /**< Time of last lock in jiffies */
  327. spinlock_t spinlock;
  328. uint32_t kernel_waiters;
  329. uint32_t user_waiters;
  330. int idle_has_lock;
  331. };
  332. /**
  333. * struct drm_master - drm master structure
  334. *
  335. * @refcount: Refcount for this master object.
  336. * @minor: Link back to minor char device we are master for. Immutable.
  337. * @unique: Unique identifier: e.g. busid. Protected by drm_global_mutex.
  338. * @unique_len: Length of unique field. Protected by drm_global_mutex.
  339. * @magic_map: Map of used authentication tokens. Protected by struct_mutex.
  340. * @lock: DRI lock information.
  341. * @driver_priv: Pointer to driver-private information.
  342. */
  343. struct drm_master {
  344. struct kref refcount;
  345. struct drm_minor *minor;
  346. char *unique;
  347. int unique_len;
  348. struct idr magic_map;
  349. struct drm_lock_data lock;
  350. void *driver_priv;
  351. };
  352. /* Size of ringbuffer for vblank timestamps. Just double-buffer
  353. * in initial implementation.
  354. */
  355. #define DRM_VBLANKTIME_RBSIZE 2
  356. /* Flags and return codes for get_vblank_timestamp() driver function. */
  357. #define DRM_CALLED_FROM_VBLIRQ 1
  358. #define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
  359. #define DRM_VBLANKTIME_IN_VBLANK (1 << 1)
  360. /* get_scanout_position() return flags */
  361. #define DRM_SCANOUTPOS_VALID (1 << 0)
  362. #define DRM_SCANOUTPOS_IN_VBLANK (1 << 1)
  363. #define DRM_SCANOUTPOS_ACCURATE (1 << 2)
  364. /**
  365. * DRM driver structure. This structure represent the common code for
  366. * a family of cards. There will one drm_device for each card present
  367. * in this family
  368. */
  369. struct drm_driver {
  370. int (*load) (struct drm_device *, unsigned long flags);
  371. int (*firstopen) (struct drm_device *);
  372. int (*open) (struct drm_device *, struct drm_file *);
  373. void (*preclose) (struct drm_device *, struct drm_file *file_priv);
  374. void (*postclose) (struct drm_device *, struct drm_file *);
  375. void (*lastclose) (struct drm_device *);
  376. int (*unload) (struct drm_device *);
  377. int (*suspend) (struct drm_device *, pm_message_t state);
  378. int (*resume) (struct drm_device *);
  379. int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
  380. int (*dma_quiescent) (struct drm_device *);
  381. int (*context_dtor) (struct drm_device *dev, int context);
  382. int (*set_busid)(struct drm_device *dev, struct drm_master *master);
  383. /**
  384. * get_vblank_counter - get raw hardware vblank counter
  385. * @dev: DRM device
  386. * @pipe: counter to fetch
  387. *
  388. * Driver callback for fetching a raw hardware vblank counter for @crtc.
  389. * If a device doesn't have a hardware counter, the driver can simply
  390. * return the value of drm_vblank_count. The DRM core will account for
  391. * missed vblank events while interrupts where disabled based on system
  392. * timestamps.
  393. *
  394. * Wraparound handling and loss of events due to modesetting is dealt
  395. * with in the DRM core code.
  396. *
  397. * RETURNS
  398. * Raw vblank counter value.
  399. */
  400. u32 (*get_vblank_counter) (struct drm_device *dev, unsigned int pipe);
  401. /**
  402. * enable_vblank - enable vblank interrupt events
  403. * @dev: DRM device
  404. * @pipe: which irq to enable
  405. *
  406. * Enable vblank interrupts for @crtc. If the device doesn't have
  407. * a hardware vblank counter, this routine should be a no-op, since
  408. * interrupts will have to stay on to keep the count accurate.
  409. *
  410. * RETURNS
  411. * Zero on success, appropriate errno if the given @crtc's vblank
  412. * interrupt cannot be enabled.
  413. */
  414. int (*enable_vblank) (struct drm_device *dev, unsigned int pipe);
  415. /**
  416. * disable_vblank - disable vblank interrupt events
  417. * @dev: DRM device
  418. * @pipe: which irq to enable
  419. *
  420. * Disable vblank interrupts for @crtc. If the device doesn't have
  421. * a hardware vblank counter, this routine should be a no-op, since
  422. * interrupts will have to stay on to keep the count accurate.
  423. */
  424. void (*disable_vblank) (struct drm_device *dev, unsigned int pipe);
  425. /**
  426. * Called by \c drm_device_is_agp. Typically used to determine if a
  427. * card is really attached to AGP or not.
  428. *
  429. * \param dev DRM device handle
  430. *
  431. * \returns
  432. * One of three values is returned depending on whether or not the
  433. * card is absolutely \b not AGP (return of 0), absolutely \b is AGP
  434. * (return of 1), or may or may not be AGP (return of 2).
  435. */
  436. int (*device_is_agp) (struct drm_device *dev);
  437. /**
  438. * Called by vblank timestamping code.
  439. *
  440. * Return the current display scanout position from a crtc, and an
  441. * optional accurate ktime_get timestamp of when position was measured.
  442. *
  443. * \param dev DRM device.
  444. * \param pipe Id of the crtc to query.
  445. * \param flags Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0).
  446. * \param *vpos Target location for current vertical scanout position.
  447. * \param *hpos Target location for current horizontal scanout position.
  448. * \param *stime Target location for timestamp taken immediately before
  449. * scanout position query. Can be NULL to skip timestamp.
  450. * \param *etime Target location for timestamp taken immediately after
  451. * scanout position query. Can be NULL to skip timestamp.
  452. * \param mode Current display timings.
  453. *
  454. * Returns vpos as a positive number while in active scanout area.
  455. * Returns vpos as a negative number inside vblank, counting the number
  456. * of scanlines to go until end of vblank, e.g., -1 means "one scanline
  457. * until start of active scanout / end of vblank."
  458. *
  459. * \return Flags, or'ed together as follows:
  460. *
  461. * DRM_SCANOUTPOS_VALID = Query successful.
  462. * DRM_SCANOUTPOS_INVBL = Inside vblank.
  463. * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of
  464. * this flag means that returned position may be offset by a constant
  465. * but unknown small number of scanlines wrt. real scanout position.
  466. *
  467. */
  468. int (*get_scanout_position) (struct drm_device *dev, unsigned int pipe,
  469. unsigned int flags, int *vpos, int *hpos,
  470. ktime_t *stime, ktime_t *etime,
  471. const struct drm_display_mode *mode);
  472. /**
  473. * Called by \c drm_get_last_vbltimestamp. Should return a precise
  474. * timestamp when the most recent VBLANK interval ended or will end.
  475. *
  476. * Specifically, the timestamp in @vblank_time should correspond as
  477. * closely as possible to the time when the first video scanline of
  478. * the video frame after the end of VBLANK will start scanning out,
  479. * the time immediately after end of the VBLANK interval. If the
  480. * @crtc is currently inside VBLANK, this will be a time in the future.
  481. * If the @crtc is currently scanning out a frame, this will be the
  482. * past start time of the current scanout. This is meant to adhere
  483. * to the OpenML OML_sync_control extension specification.
  484. *
  485. * \param dev dev DRM device handle.
  486. * \param pipe crtc for which timestamp should be returned.
  487. * \param *max_error Maximum allowable timestamp error in nanoseconds.
  488. * Implementation should strive to provide timestamp
  489. * with an error of at most *max_error nanoseconds.
  490. * Returns true upper bound on error for timestamp.
  491. * \param *vblank_time Target location for returned vblank timestamp.
  492. * \param flags 0 = Defaults, no special treatment needed.
  493. * \param DRM_CALLED_FROM_VBLIRQ = Function is called from vblank
  494. * irq handler. Some drivers need to apply some workarounds
  495. * for gpu-specific vblank irq quirks if flag is set.
  496. *
  497. * \returns
  498. * Zero if timestamping isn't supported in current display mode or a
  499. * negative number on failure. A positive status code on success,
  500. * which describes how the vblank_time timestamp was computed.
  501. */
  502. int (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
  503. int *max_error,
  504. struct timeval *vblank_time,
  505. unsigned flags);
  506. /* these have to be filled in */
  507. irqreturn_t(*irq_handler) (int irq, void *arg);
  508. void (*irq_preinstall) (struct drm_device *dev);
  509. int (*irq_postinstall) (struct drm_device *dev);
  510. void (*irq_uninstall) (struct drm_device *dev);
  511. /* Master routines */
  512. int (*master_create)(struct drm_device *dev, struct drm_master *master);
  513. void (*master_destroy)(struct drm_device *dev, struct drm_master *master);
  514. /**
  515. * master_set is called whenever the minor master is set.
  516. * master_drop is called whenever the minor master is dropped.
  517. */
  518. int (*master_set)(struct drm_device *dev, struct drm_file *file_priv,
  519. bool from_open);
  520. void (*master_drop)(struct drm_device *dev, struct drm_file *file_priv,
  521. bool from_release);
  522. int (*debugfs_init)(struct drm_minor *minor);
  523. void (*debugfs_cleanup)(struct drm_minor *minor);
  524. /**
  525. * Driver-specific constructor for drm_gem_objects, to set up
  526. * obj->driver_private.
  527. *
  528. * Returns 0 on success.
  529. */
  530. void (*gem_free_object) (struct drm_gem_object *obj);
  531. int (*gem_open_object) (struct drm_gem_object *, struct drm_file *);
  532. void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
  533. /**
  534. * Hook for allocating the GEM object struct, for use by core
  535. * helpers.
  536. */
  537. struct drm_gem_object *(*gem_create_object)(struct drm_device *dev,
  538. size_t size);
  539. /* prime: */
  540. /* export handle -> fd (see drm_gem_prime_handle_to_fd() helper) */
  541. int (*prime_handle_to_fd)(struct drm_device *dev, struct drm_file *file_priv,
  542. uint32_t handle, uint32_t flags, int *prime_fd);
  543. /* import fd -> handle (see drm_gem_prime_fd_to_handle() helper) */
  544. int (*prime_fd_to_handle)(struct drm_device *dev, struct drm_file *file_priv,
  545. int prime_fd, uint32_t *handle);
  546. /* export GEM -> dmabuf */
  547. struct dma_buf * (*gem_prime_export)(struct drm_device *dev,
  548. struct drm_gem_object *obj, int flags);
  549. /* import dmabuf -> GEM */
  550. struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev,
  551. struct dma_buf *dma_buf);
  552. /* low-level interface used by drm_gem_prime_{import,export} */
  553. int (*gem_prime_pin)(struct drm_gem_object *obj);
  554. void (*gem_prime_unpin)(struct drm_gem_object *obj);
  555. struct reservation_object * (*gem_prime_res_obj)(
  556. struct drm_gem_object *obj);
  557. struct sg_table *(*gem_prime_get_sg_table)(struct drm_gem_object *obj);
  558. struct drm_gem_object *(*gem_prime_import_sg_table)(
  559. struct drm_device *dev,
  560. struct dma_buf_attachment *attach,
  561. struct sg_table *sgt);
  562. void *(*gem_prime_vmap)(struct drm_gem_object *obj);
  563. void (*gem_prime_vunmap)(struct drm_gem_object *obj, void *vaddr);
  564. int (*gem_prime_mmap)(struct drm_gem_object *obj,
  565. struct vm_area_struct *vma);
  566. /* vga arb irq handler */
  567. void (*vgaarb_irq)(struct drm_device *dev, bool state);
  568. /* dumb alloc support */
  569. int (*dumb_create)(struct drm_file *file_priv,
  570. struct drm_device *dev,
  571. struct drm_mode_create_dumb *args);
  572. int (*dumb_map_offset)(struct drm_file *file_priv,
  573. struct drm_device *dev, uint32_t handle,
  574. uint64_t *offset);
  575. int (*dumb_destroy)(struct drm_file *file_priv,
  576. struct drm_device *dev,
  577. uint32_t handle);
  578. /* Driver private ops for this object */
  579. const struct vm_operations_struct *gem_vm_ops;
  580. int major;
  581. int minor;
  582. int patchlevel;
  583. char *name;
  584. char *desc;
  585. char *date;
  586. u32 driver_features;
  587. int dev_priv_size;
  588. const struct drm_ioctl_desc *ioctls;
  589. int num_ioctls;
  590. const struct file_operations *fops;
  591. /* List of devices hanging off this driver with stealth attach. */
  592. struct list_head legacy_dev_list;
  593. };
  594. enum drm_minor_type {
  595. DRM_MINOR_LEGACY,
  596. DRM_MINOR_CONTROL,
  597. DRM_MINOR_RENDER,
  598. DRM_MINOR_CNT,
  599. };
  600. /**
  601. * Info file list entry. This structure represents a debugfs or proc file to
  602. * be created by the drm core
  603. */
  604. struct drm_info_list {
  605. const char *name; /** file name */
  606. int (*show)(struct seq_file*, void*); /** show callback */
  607. u32 driver_features; /**< Required driver features for this entry */
  608. void *data;
  609. };
  610. /**
  611. * debugfs node structure. This structure represents a debugfs file.
  612. */
  613. struct drm_info_node {
  614. struct list_head list;
  615. struct drm_minor *minor;
  616. const struct drm_info_list *info_ent;
  617. struct dentry *dent;
  618. };
  619. /**
  620. * DRM minor structure. This structure represents a drm minor number.
  621. */
  622. struct drm_minor {
  623. int index; /**< Minor device number */
  624. int type; /**< Control or render */
  625. struct device *kdev; /**< Linux device */
  626. struct drm_device *dev;
  627. struct dentry *debugfs_root;
  628. struct list_head debugfs_list;
  629. struct mutex debugfs_lock; /* Protects debugfs_list. */
  630. /* currently active master for this node. Protected by master_mutex */
  631. struct drm_master *master;
  632. };
  633. struct drm_pending_vblank_event {
  634. struct drm_pending_event base;
  635. unsigned int pipe;
  636. struct drm_event_vblank event;
  637. };
  638. struct drm_vblank_crtc {
  639. struct drm_device *dev; /* pointer to the drm_device */
  640. wait_queue_head_t queue; /**< VBLANK wait queue */
  641. struct timer_list disable_timer; /* delayed disable timer */
  642. /* vblank counter, protected by dev->vblank_time_lock for writes */
  643. u32 count;
  644. /* vblank timestamps, protected by dev->vblank_time_lock for writes */
  645. struct timeval time[DRM_VBLANKTIME_RBSIZE];
  646. atomic_t refcount; /* number of users of vblank interruptsper crtc */
  647. u32 last; /* protected by dev->vbl_lock, used */
  648. /* for wraparound handling */
  649. u32 last_wait; /* Last vblank seqno waited per CRTC */
  650. unsigned int inmodeset; /* Display driver is setting mode */
  651. unsigned int pipe; /* crtc index */
  652. int framedur_ns; /* frame/field duration in ns */
  653. int linedur_ns; /* line duration in ns */
  654. bool enabled; /* so we don't call enable more than
  655. once per disable */
  656. };
  657. /**
  658. * DRM device structure. This structure represent a complete card that
  659. * may contain multiple heads.
  660. */
  661. struct drm_device {
  662. struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */
  663. int if_version; /**< Highest interface version set */
  664. /** \name Lifetime Management */
  665. /*@{ */
  666. struct kref ref; /**< Object ref-count */
  667. struct device *dev; /**< Device structure of bus-device */
  668. struct drm_driver *driver; /**< DRM driver managing the device */
  669. void *dev_private; /**< DRM driver private data */
  670. struct drm_minor *control; /**< Control node */
  671. struct drm_minor *primary; /**< Primary node */
  672. struct drm_minor *render; /**< Render node */
  673. atomic_t unplugged; /**< Flag whether dev is dead */
  674. struct inode *anon_inode; /**< inode for private address-space */
  675. char *unique; /**< unique name of the device */
  676. /*@} */
  677. /** \name Locks */
  678. /*@{ */
  679. struct mutex struct_mutex; /**< For others */
  680. struct mutex master_mutex; /**< For drm_minor::master and drm_file::is_master */
  681. /*@} */
  682. /** \name Usage Counters */
  683. /*@{ */
  684. int open_count; /**< Outstanding files open, protected by drm_global_mutex. */
  685. spinlock_t buf_lock; /**< For drm_device::buf_use and a few other things. */
  686. int buf_use; /**< Buffers in use -- cannot alloc */
  687. atomic_t buf_alloc; /**< Buffer allocation in progress */
  688. /*@} */
  689. struct list_head filelist;
  690. /** \name Memory management */
  691. /*@{ */
  692. struct list_head maplist; /**< Linked list of regions */
  693. struct drm_open_hash map_hash; /**< User token hash table for maps */
  694. /** \name Context handle management */
  695. /*@{ */
  696. struct list_head ctxlist; /**< Linked list of context handles */
  697. struct mutex ctxlist_mutex; /**< For ctxlist */
  698. struct idr ctx_idr;
  699. struct list_head vmalist; /**< List of vmas (for debugging) */
  700. /*@} */
  701. /** \name DMA support */
  702. /*@{ */
  703. struct drm_device_dma *dma; /**< Optional pointer for DMA support */
  704. /*@} */
  705. /** \name Context support */
  706. /*@{ */
  707. __volatile__ long context_flag; /**< Context swapping flag */
  708. int last_context; /**< Last current context */
  709. /*@} */
  710. /** \name VBLANK IRQ support */
  711. /*@{ */
  712. bool irq_enabled;
  713. int irq;
  714. /*
  715. * At load time, disabling the vblank interrupt won't be allowed since
  716. * old clients may not call the modeset ioctl and therefore misbehave.
  717. * Once the modeset ioctl *has* been called though, we can safely
  718. * disable them when unused.
  719. */
  720. bool vblank_disable_allowed;
  721. /*
  722. * If true, vblank interrupt will be disabled immediately when the
  723. * refcount drops to zero, as opposed to via the vblank disable
  724. * timer.
  725. * This can be set to true it the hardware has a working vblank
  726. * counter and the driver uses drm_vblank_on() and drm_vblank_off()
  727. * appropriately.
  728. */
  729. bool vblank_disable_immediate;
  730. /* array of size num_crtcs */
  731. struct drm_vblank_crtc *vblank;
  732. spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */
  733. spinlock_t vbl_lock;
  734. u32 max_vblank_count; /**< size of vblank counter register */
  735. /**
  736. * List of events
  737. */
  738. struct list_head vblank_event_list;
  739. spinlock_t event_lock;
  740. /*@} */
  741. struct drm_agp_head *agp; /**< AGP data */
  742. struct pci_dev *pdev; /**< PCI device structure */
  743. #ifdef __alpha__
  744. struct pci_controller *hose;
  745. #endif
  746. struct platform_device *platformdev; /**< Platform device struture */
  747. struct virtio_device *virtdev;
  748. struct drm_sg_mem *sg; /**< Scatter gather memory */
  749. unsigned int num_crtcs; /**< Number of CRTCs on this device */
  750. struct {
  751. int context;
  752. struct drm_hw_lock *lock;
  753. } sigdata;
  754. struct drm_local_map *agp_buffer_map;
  755. unsigned int agp_buffer_token;
  756. struct drm_mode_config mode_config; /**< Current mode config */
  757. /** \name GEM information */
  758. /*@{ */
  759. struct mutex object_name_lock;
  760. struct idr object_name_idr;
  761. struct drm_vma_offset_manager *vma_offset_manager;
  762. /*@} */
  763. int switch_power_state;
  764. };
  765. #define DRM_SWITCH_POWER_ON 0
  766. #define DRM_SWITCH_POWER_OFF 1
  767. #define DRM_SWITCH_POWER_CHANGING 2
  768. #define DRM_SWITCH_POWER_DYNAMIC_OFF 3
  769. static __inline__ int drm_core_check_feature(struct drm_device *dev,
  770. int feature)
  771. {
  772. return ((dev->driver->driver_features & feature) ? 1 : 0);
  773. }
  774. static inline void drm_device_set_unplugged(struct drm_device *dev)
  775. {
  776. smp_wmb();
  777. atomic_set(&dev->unplugged, 1);
  778. }
  779. static inline int drm_device_is_unplugged(struct drm_device *dev)
  780. {
  781. int ret = atomic_read(&dev->unplugged);
  782. smp_rmb();
  783. return ret;
  784. }
  785. static inline bool drm_is_render_client(const struct drm_file *file_priv)
  786. {
  787. return file_priv->minor->type == DRM_MINOR_RENDER;
  788. }
  789. static inline bool drm_is_control_client(const struct drm_file *file_priv)
  790. {
  791. return file_priv->minor->type == DRM_MINOR_CONTROL;
  792. }
  793. static inline bool drm_is_primary_client(const struct drm_file *file_priv)
  794. {
  795. return file_priv->minor->type == DRM_MINOR_LEGACY;
  796. }
  797. /******************************************************************/
  798. /** \name Internal function definitions */
  799. /*@{*/
  800. /* Driver support (drm_drv.h) */
  801. extern int drm_ioctl_permit(u32 flags, struct drm_file *file_priv);
  802. extern long drm_ioctl(struct file *filp,
  803. unsigned int cmd, unsigned long arg);
  804. extern long drm_compat_ioctl(struct file *filp,
  805. unsigned int cmd, unsigned long arg);
  806. extern bool drm_ioctl_flags(unsigned int nr, unsigned int *flags);
  807. /* File Operations (drm_fops.c) */
  808. int drm_open(struct inode *inode, struct file *filp);
  809. ssize_t drm_read(struct file *filp, char __user *buffer,
  810. size_t count, loff_t *offset);
  811. int drm_release(struct inode *inode, struct file *filp);
  812. int drm_new_set_master(struct drm_device *dev, struct drm_file *fpriv);
  813. unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
  814. int drm_event_reserve_init_locked(struct drm_device *dev,
  815. struct drm_file *file_priv,
  816. struct drm_pending_event *p,
  817. struct drm_event *e);
  818. int drm_event_reserve_init(struct drm_device *dev,
  819. struct drm_file *file_priv,
  820. struct drm_pending_event *p,
  821. struct drm_event *e);
  822. void drm_event_cancel_free(struct drm_device *dev,
  823. struct drm_pending_event *p);
  824. void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e);
  825. void drm_send_event(struct drm_device *dev, struct drm_pending_event *e);
  826. /* Misc. IOCTL support (drm_ioctl.c) */
  827. int drm_noop(struct drm_device *dev, void *data,
  828. struct drm_file *file_priv);
  829. int drm_invalid_op(struct drm_device *dev, void *data,
  830. struct drm_file *file_priv);
  831. /* Cache management (drm_cache.c) */
  832. void drm_clflush_pages(struct page *pages[], unsigned long num_pages);
  833. void drm_clflush_sg(struct sg_table *st);
  834. void drm_clflush_virt_range(void *addr, unsigned long length);
  835. /*
  836. * These are exported to drivers so that they can implement fencing using
  837. * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
  838. */
  839. /* IRQ support (drm_irq.h) */
  840. extern int drm_irq_install(struct drm_device *dev, int irq);
  841. extern int drm_irq_uninstall(struct drm_device *dev);
  842. extern int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs);
  843. extern int drm_wait_vblank(struct drm_device *dev, void *data,
  844. struct drm_file *filp);
  845. extern u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe);
  846. extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
  847. extern u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
  848. struct timeval *vblanktime);
  849. extern u32 drm_crtc_vblank_count_and_time(struct drm_crtc *crtc,
  850. struct timeval *vblanktime);
  851. extern void drm_send_vblank_event(struct drm_device *dev, unsigned int pipe,
  852. struct drm_pending_vblank_event *e);
  853. extern void drm_crtc_send_vblank_event(struct drm_crtc *crtc,
  854. struct drm_pending_vblank_event *e);
  855. extern void drm_arm_vblank_event(struct drm_device *dev, unsigned int pipe,
  856. struct drm_pending_vblank_event *e);
  857. extern void drm_crtc_arm_vblank_event(struct drm_crtc *crtc,
  858. struct drm_pending_vblank_event *e);
  859. extern bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe);
  860. extern bool drm_crtc_handle_vblank(struct drm_crtc *crtc);
  861. extern int drm_vblank_get(struct drm_device *dev, unsigned int pipe);
  862. extern void drm_vblank_put(struct drm_device *dev, unsigned int pipe);
  863. extern int drm_crtc_vblank_get(struct drm_crtc *crtc);
  864. extern void drm_crtc_vblank_put(struct drm_crtc *crtc);
  865. extern void drm_wait_one_vblank(struct drm_device *dev, unsigned int pipe);
  866. extern void drm_crtc_wait_one_vblank(struct drm_crtc *crtc);
  867. extern void drm_vblank_off(struct drm_device *dev, unsigned int pipe);
  868. extern void drm_vblank_on(struct drm_device *dev, unsigned int pipe);
  869. extern void drm_crtc_vblank_off(struct drm_crtc *crtc);
  870. extern void drm_crtc_vblank_reset(struct drm_crtc *crtc);
  871. extern void drm_crtc_vblank_on(struct drm_crtc *crtc);
  872. extern void drm_vblank_cleanup(struct drm_device *dev);
  873. extern u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe);
  874. extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
  875. unsigned int pipe, int *max_error,
  876. struct timeval *vblank_time,
  877. unsigned flags,
  878. const struct drm_display_mode *mode);
  879. extern void drm_calc_timestamping_constants(struct drm_crtc *crtc,
  880. const struct drm_display_mode *mode);
  881. /**
  882. * drm_crtc_vblank_waitqueue - get vblank waitqueue for the CRTC
  883. * @crtc: which CRTC's vblank waitqueue to retrieve
  884. *
  885. * This function returns a pointer to the vblank waitqueue for the CRTC.
  886. * Drivers can use this to implement vblank waits using wait_event() & co.
  887. */
  888. static inline wait_queue_head_t *drm_crtc_vblank_waitqueue(struct drm_crtc *crtc)
  889. {
  890. return &crtc->dev->vblank[drm_crtc_index(crtc)].queue;
  891. }
  892. /* Modesetting support */
  893. extern void drm_vblank_pre_modeset(struct drm_device *dev, unsigned int pipe);
  894. extern void drm_vblank_post_modeset(struct drm_device *dev, unsigned int pipe);
  895. /* Stub support (drm_stub.h) */
  896. extern struct drm_master *drm_master_get(struct drm_master *master);
  897. extern void drm_master_put(struct drm_master **master);
  898. extern void drm_put_dev(struct drm_device *dev);
  899. extern void drm_unplug_dev(struct drm_device *dev);
  900. extern unsigned int drm_debug;
  901. extern bool drm_atomic;
  902. /* Debugfs support */
  903. #if defined(CONFIG_DEBUG_FS)
  904. extern int drm_debugfs_create_files(const struct drm_info_list *files,
  905. int count, struct dentry *root,
  906. struct drm_minor *minor);
  907. extern int drm_debugfs_remove_files(const struct drm_info_list *files,
  908. int count, struct drm_minor *minor);
  909. #else
  910. static inline int drm_debugfs_create_files(const struct drm_info_list *files,
  911. int count, struct dentry *root,
  912. struct drm_minor *minor)
  913. {
  914. return 0;
  915. }
  916. static inline int drm_debugfs_remove_files(const struct drm_info_list *files,
  917. int count, struct drm_minor *minor)
  918. {
  919. return 0;
  920. }
  921. #endif
  922. extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev,
  923. struct drm_gem_object *obj, int flags);
  924. extern int drm_gem_prime_handle_to_fd(struct drm_device *dev,
  925. struct drm_file *file_priv, uint32_t handle, uint32_t flags,
  926. int *prime_fd);
  927. extern struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev,
  928. struct dma_buf *dma_buf);
  929. extern int drm_gem_prime_fd_to_handle(struct drm_device *dev,
  930. struct drm_file *file_priv, int prime_fd, uint32_t *handle);
  931. extern void drm_gem_dmabuf_release(struct dma_buf *dma_buf);
  932. extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages,
  933. dma_addr_t *addrs, int max_pages);
  934. extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, unsigned int nr_pages);
  935. extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg);
  936. extern struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size,
  937. size_t align);
  938. extern void drm_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah);
  939. /* sysfs support (drm_sysfs.c) */
  940. extern void drm_sysfs_hotplug_event(struct drm_device *dev);
  941. struct drm_device *drm_dev_alloc(struct drm_driver *driver,
  942. struct device *parent);
  943. void drm_dev_ref(struct drm_device *dev);
  944. void drm_dev_unref(struct drm_device *dev);
  945. int drm_dev_register(struct drm_device *dev, unsigned long flags);
  946. void drm_dev_unregister(struct drm_device *dev);
  947. int drm_dev_set_unique(struct drm_device *dev, const char *name);
  948. struct drm_minor *drm_minor_acquire(unsigned int minor_id);
  949. void drm_minor_release(struct drm_minor *minor);
  950. /*@}*/
  951. /* PCI section */
  952. static __inline__ int drm_pci_device_is_agp(struct drm_device *dev)
  953. {
  954. if (dev->driver->device_is_agp != NULL) {
  955. int err = (*dev->driver->device_is_agp) (dev);
  956. if (err != 2) {
  957. return err;
  958. }
  959. }
  960. return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP);
  961. }
  962. void drm_pci_agp_destroy(struct drm_device *dev);
  963. extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver);
  964. extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
  965. #ifdef CONFIG_PCI
  966. extern int drm_get_pci_dev(struct pci_dev *pdev,
  967. const struct pci_device_id *ent,
  968. struct drm_driver *driver);
  969. extern int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master);
  970. #else
  971. static inline int drm_get_pci_dev(struct pci_dev *pdev,
  972. const struct pci_device_id *ent,
  973. struct drm_driver *driver)
  974. {
  975. return -ENOSYS;
  976. }
  977. static inline int drm_pci_set_busid(struct drm_device *dev,
  978. struct drm_master *master)
  979. {
  980. return -ENOSYS;
  981. }
  982. #endif
  983. #define DRM_PCIE_SPEED_25 1
  984. #define DRM_PCIE_SPEED_50 2
  985. #define DRM_PCIE_SPEED_80 4
  986. extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask);
  987. extern int drm_pcie_get_max_link_width(struct drm_device *dev, u32 *mlw);
  988. /* platform section */
  989. extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device);
  990. extern int drm_platform_set_busid(struct drm_device *d, struct drm_master *m);
  991. /* returns true if currently okay to sleep */
  992. static __inline__ bool drm_can_sleep(void)
  993. {
  994. if (in_atomic() || in_dbg_master() || irqs_disabled())
  995. return false;
  996. return true;
  997. }
  998. /* helper for handling conditionals in various for_each macros */
  999. #define for_each_if(condition) if (!(condition)) {} else
  1000. #endif