drm_mode_config.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979
  1. /*
  2. * Copyright (c) 2016 Intel Corporation
  3. *
  4. * Permission to use, copy, modify, distribute, and sell this software and its
  5. * documentation for any purpose is hereby granted without fee, provided that
  6. * the above copyright notice appear in all copies and that both that copyright
  7. * notice and this permission notice appear in supporting documentation, and
  8. * that the name of the copyright holders not be used in advertising or
  9. * publicity pertaining to distribution of the software without specific,
  10. * written prior permission. The copyright holders make no representations
  11. * about the suitability of this software for any purpose. It is provided "as
  12. * is" without express or implied warranty.
  13. *
  14. * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15. * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  16. * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17. * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18. * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  19. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  20. * OF THIS SOFTWARE.
  21. */
  22. #ifndef __DRM_MODE_CONFIG_H__
  23. #define __DRM_MODE_CONFIG_H__
  24. #include <linux/mutex.h>
  25. #include <linux/types.h>
  26. #include <linux/idr.h>
  27. #include <linux/workqueue.h>
  28. #include <linux/llist.h>
  29. #include <drm/drm_modeset_lock.h>
  30. struct drm_file;
  31. struct drm_device;
  32. struct drm_atomic_state;
  33. struct drm_mode_fb_cmd2;
  34. struct drm_format_info;
  35. struct drm_display_mode;
  36. /**
  37. * struct drm_mode_config_funcs - basic driver provided mode setting functions
  38. *
  39. * Some global (i.e. not per-CRTC, connector, etc) mode setting functions that
  40. * involve drivers.
  41. */
  42. struct drm_mode_config_funcs {
  43. /**
  44. * @fb_create:
  45. *
  46. * Create a new framebuffer object. The core does basic checks on the
  47. * requested metadata, but most of that is left to the driver. See
  48. * &struct drm_mode_fb_cmd2 for details.
  49. *
  50. * To validate the pixel format and modifier drivers can use
  51. * drm_any_plane_has_format() to make sure at least one plane supports
  52. * the requested values. Note that the driver must first determine the
  53. * actual modifier used if the request doesn't have it specified,
  54. * ie. when (@mode_cmd->flags & DRM_MODE_FB_MODIFIERS) == 0.
  55. *
  56. * IMPORTANT: These implied modifiers for legacy userspace must be
  57. * stored in struct &drm_framebuffer, including all relevant metadata
  58. * like &drm_framebuffer.pitches and &drm_framebuffer.offsets if the
  59. * modifier enables additional planes beyond the fourcc pixel format
  60. * code. This is required by the GETFB2 ioctl.
  61. *
  62. * If the parameters are deemed valid and the backing storage objects in
  63. * the underlying memory manager all exist, then the driver allocates
  64. * a new &drm_framebuffer structure, subclassed to contain
  65. * driver-specific information (like the internal native buffer object
  66. * references). It also needs to fill out all relevant metadata, which
  67. * should be done by calling drm_helper_mode_fill_fb_struct().
  68. *
  69. * The initialization is finalized by calling drm_framebuffer_init(),
  70. * which registers the framebuffer and makes it accessible to other
  71. * threads.
  72. *
  73. * RETURNS:
  74. *
  75. * A new framebuffer with an initial reference count of 1 or a negative
  76. * error code encoded with ERR_PTR().
  77. */
  78. struct drm_framebuffer *(*fb_create)(struct drm_device *dev,
  79. struct drm_file *file_priv,
  80. const struct drm_mode_fb_cmd2 *mode_cmd);
  81. /**
  82. * @get_format_info:
  83. *
  84. * Allows a driver to return custom format information for special
  85. * fb layouts (eg. ones with auxiliary compression control planes).
  86. *
  87. * RETURNS:
  88. *
  89. * The format information specific to the given fb metadata, or
  90. * NULL if none is found.
  91. */
  92. const struct drm_format_info *(*get_format_info)(const struct drm_mode_fb_cmd2 *mode_cmd);
  93. /**
  94. * @output_poll_changed:
  95. *
  96. * Callback used by helpers to inform the driver of output configuration
  97. * changes.
  98. *
  99. * Drivers implementing fbdev emulation use drm_kms_helper_hotplug_event()
  100. * to call this hook to inform the fbdev helper of output changes.
  101. *
  102. * This hook is deprecated, drivers should instead use
  103. * drm_fbdev_generic_setup() which takes care of any necessary
  104. * hotplug event forwarding already without further involvement by
  105. * the driver.
  106. */
  107. void (*output_poll_changed)(struct drm_device *dev);
  108. /**
  109. * @mode_valid:
  110. *
  111. * Device specific validation of display modes. Can be used to reject
  112. * modes that can never be supported. Only device wide constraints can
  113. * be checked here. crtc/encoder/bridge/connector specific constraints
  114. * should be checked in the .mode_valid() hook for each specific object.
  115. */
  116. enum drm_mode_status (*mode_valid)(struct drm_device *dev,
  117. const struct drm_display_mode *mode);
  118. /**
  119. * @atomic_check:
  120. *
  121. * This is the only hook to validate an atomic modeset update. This
  122. * function must reject any modeset and state changes which the hardware
  123. * or driver doesn't support. This includes but is of course not limited
  124. * to:
  125. *
  126. * - Checking that the modes, framebuffers, scaling and placement
  127. * requirements and so on are within the limits of the hardware.
  128. *
  129. * - Checking that any hidden shared resources are not oversubscribed.
  130. * This can be shared PLLs, shared lanes, overall memory bandwidth,
  131. * display fifo space (where shared between planes or maybe even
  132. * CRTCs).
  133. *
  134. * - Checking that virtualized resources exported to userspace are not
  135. * oversubscribed. For various reasons it can make sense to expose
  136. * more planes, crtcs or encoders than which are physically there. One
  137. * example is dual-pipe operations (which generally should be hidden
  138. * from userspace if when lockstepped in hardware, exposed otherwise),
  139. * where a plane might need 1 hardware plane (if it's just on one
  140. * pipe), 2 hardware planes (when it spans both pipes) or maybe even
  141. * shared a hardware plane with a 2nd plane (if there's a compatible
  142. * plane requested on the area handled by the other pipe).
  143. *
  144. * - Check that any transitional state is possible and that if
  145. * requested, the update can indeed be done in the vblank period
  146. * without temporarily disabling some functions.
  147. *
  148. * - Check any other constraints the driver or hardware might have.
  149. *
  150. * - This callback also needs to correctly fill out the &drm_crtc_state
  151. * in this update to make sure that drm_atomic_crtc_needs_modeset()
  152. * reflects the nature of the possible update and returns true if and
  153. * only if the update cannot be applied without tearing within one
  154. * vblank on that CRTC. The core uses that information to reject
  155. * updates which require a full modeset (i.e. blanking the screen, or
  156. * at least pausing updates for a substantial amount of time) if
  157. * userspace has disallowed that in its request.
  158. *
  159. * - The driver also does not need to repeat basic input validation
  160. * like done for the corresponding legacy entry points. The core does
  161. * that before calling this hook.
  162. *
  163. * See the documentation of @atomic_commit for an exhaustive list of
  164. * error conditions which don't have to be checked at the in this
  165. * callback.
  166. *
  167. * See the documentation for &struct drm_atomic_state for how exactly
  168. * an atomic modeset update is described.
  169. *
  170. * Drivers using the atomic helpers can implement this hook using
  171. * drm_atomic_helper_check(), or one of the exported sub-functions of
  172. * it.
  173. *
  174. * RETURNS:
  175. *
  176. * 0 on success or one of the below negative error codes:
  177. *
  178. * - -EINVAL, if any of the above constraints are violated.
  179. *
  180. * - -EDEADLK, when returned from an attempt to acquire an additional
  181. * &drm_modeset_lock through drm_modeset_lock().
  182. *
  183. * - -ENOMEM, if allocating additional state sub-structures failed due
  184. * to lack of memory.
  185. *
  186. * - -EINTR, -EAGAIN or -ERESTARTSYS, if the IOCTL should be restarted.
  187. * This can either be due to a pending signal, or because the driver
  188. * needs to completely bail out to recover from an exceptional
  189. * situation like a GPU hang. From a userspace point all errors are
  190. * treated equally.
  191. */
  192. int (*atomic_check)(struct drm_device *dev,
  193. struct drm_atomic_state *state);
  194. /**
  195. * @atomic_commit:
  196. *
  197. * This is the only hook to commit an atomic modeset update. The core
  198. * guarantees that @atomic_check has been called successfully before
  199. * calling this function, and that nothing has been changed in the
  200. * interim.
  201. *
  202. * See the documentation for &struct drm_atomic_state for how exactly
  203. * an atomic modeset update is described.
  204. *
  205. * Drivers using the atomic helpers can implement this hook using
  206. * drm_atomic_helper_commit(), or one of the exported sub-functions of
  207. * it.
  208. *
  209. * Nonblocking commits (as indicated with the nonblock parameter) must
  210. * do any preparatory work which might result in an unsuccessful commit
  211. * in the context of this callback. The only exceptions are hardware
  212. * errors resulting in -EIO. But even in that case the driver must
  213. * ensure that the display pipe is at least running, to avoid
  214. * compositors crashing when pageflips don't work. Anything else,
  215. * specifically committing the update to the hardware, should be done
  216. * without blocking the caller. For updates which do not require a
  217. * modeset this must be guaranteed.
  218. *
  219. * The driver must wait for any pending rendering to the new
  220. * framebuffers to complete before executing the flip. It should also
  221. * wait for any pending rendering from other drivers if the underlying
  222. * buffer is a shared dma-buf. Nonblocking commits must not wait for
  223. * rendering in the context of this callback.
  224. *
  225. * An application can request to be notified when the atomic commit has
  226. * completed. These events are per-CRTC and can be distinguished by the
  227. * CRTC index supplied in &drm_event to userspace.
  228. *
  229. * The drm core will supply a &struct drm_event in each CRTC's
  230. * &drm_crtc_state.event. See the documentation for
  231. * &drm_crtc_state.event for more details about the precise semantics of
  232. * this event.
  233. *
  234. * NOTE:
  235. *
  236. * Drivers are not allowed to shut down any display pipe successfully
  237. * enabled through an atomic commit on their own. Doing so can result in
  238. * compositors crashing if a page flip is suddenly rejected because the
  239. * pipe is off.
  240. *
  241. * RETURNS:
  242. *
  243. * 0 on success or one of the below negative error codes:
  244. *
  245. * - -EBUSY, if a nonblocking updated is requested and there is
  246. * an earlier updated pending. Drivers are allowed to support a queue
  247. * of outstanding updates, but currently no driver supports that.
  248. * Note that drivers must wait for preceding updates to complete if a
  249. * synchronous update is requested, they are not allowed to fail the
  250. * commit in that case.
  251. *
  252. * - -ENOMEM, if the driver failed to allocate memory. Specifically
  253. * this can happen when trying to pin framebuffers, which must only
  254. * be done when committing the state.
  255. *
  256. * - -ENOSPC, as a refinement of the more generic -ENOMEM to indicate
  257. * that the driver has run out of vram, iommu space or similar GPU
  258. * address space needed for framebuffer.
  259. *
  260. * - -EIO, if the hardware completely died.
  261. *
  262. * - -EINTR, -EAGAIN or -ERESTARTSYS, if the IOCTL should be restarted.
  263. * This can either be due to a pending signal, or because the driver
  264. * needs to completely bail out to recover from an exceptional
  265. * situation like a GPU hang. From a userspace point of view all errors are
  266. * treated equally.
  267. *
  268. * This list is exhaustive. Specifically this hook is not allowed to
  269. * return -EINVAL (any invalid requests should be caught in
  270. * @atomic_check) or -EDEADLK (this function must not acquire
  271. * additional modeset locks).
  272. */
  273. int (*atomic_commit)(struct drm_device *dev,
  274. struct drm_atomic_state *state,
  275. bool nonblock);
  276. /**
  277. * @atomic_state_alloc:
  278. *
  279. * This optional hook can be used by drivers that want to subclass struct
  280. * &drm_atomic_state to be able to track their own driver-private global
  281. * state easily. If this hook is implemented, drivers must also
  282. * implement @atomic_state_clear and @atomic_state_free.
  283. *
  284. * Subclassing of &drm_atomic_state is deprecated in favour of using
  285. * &drm_private_state and &drm_private_obj.
  286. *
  287. * RETURNS:
  288. *
  289. * A new &drm_atomic_state on success or NULL on failure.
  290. */
  291. struct drm_atomic_state *(*atomic_state_alloc)(struct drm_device *dev);
  292. /**
  293. * @atomic_state_clear:
  294. *
  295. * This hook must clear any driver private state duplicated into the
  296. * passed-in &drm_atomic_state. This hook is called when the caller
  297. * encountered a &drm_modeset_lock deadlock and needs to drop all
  298. * already acquired locks as part of the deadlock avoidance dance
  299. * implemented in drm_modeset_backoff().
  300. *
  301. * Any duplicated state must be invalidated since a concurrent atomic
  302. * update might change it, and the drm atomic interfaces always apply
  303. * updates as relative changes to the current state.
  304. *
  305. * Drivers that implement this must call drm_atomic_state_default_clear()
  306. * to clear common state.
  307. *
  308. * Subclassing of &drm_atomic_state is deprecated in favour of using
  309. * &drm_private_state and &drm_private_obj.
  310. */
  311. void (*atomic_state_clear)(struct drm_atomic_state *state);
  312. /**
  313. * @atomic_state_free:
  314. *
  315. * This hook needs driver private resources and the &drm_atomic_state
  316. * itself. Note that the core first calls drm_atomic_state_clear() to
  317. * avoid code duplicate between the clear and free hooks.
  318. *
  319. * Drivers that implement this must call
  320. * drm_atomic_state_default_release() to release common resources.
  321. *
  322. * Subclassing of &drm_atomic_state is deprecated in favour of using
  323. * &drm_private_state and &drm_private_obj.
  324. */
  325. void (*atomic_state_free)(struct drm_atomic_state *state);
  326. };
  327. /**
  328. * struct drm_mode_config - Mode configuration control structure
  329. * @min_width: minimum fb pixel width on this device
  330. * @min_height: minimum fb pixel height on this device
  331. * @max_width: maximum fb pixel width on this device
  332. * @max_height: maximum fb pixel height on this device
  333. * @funcs: core driver provided mode setting functions
  334. * @fb_base: base address of the framebuffer
  335. * @poll_enabled: track polling support for this device
  336. * @poll_running: track polling status for this device
  337. * @delayed_event: track delayed poll uevent deliver for this device
  338. * @output_poll_work: delayed work for polling in process context
  339. * @preferred_depth: preferred RBG pixel depth, used by fb helpers
  340. * @prefer_shadow: hint to userspace to prefer shadow-fb rendering
  341. * @cursor_width: hint to userspace for max cursor width
  342. * @cursor_height: hint to userspace for max cursor height
  343. * @helper_private: mid-layer private data
  344. *
  345. * Core mode resource tracking structure. All CRTC, encoders, and connectors
  346. * enumerated by the driver are added here, as are global properties. Some
  347. * global restrictions are also here, e.g. dimension restrictions.
  348. *
  349. * Framebuffer sizes refer to the virtual screen that can be displayed by
  350. * the CRTC. This can be different from the physical resolution programmed.
  351. * The minimum width and height, stored in @min_width and @min_height,
  352. * describe the smallest size of the framebuffer. It correlates to the
  353. * minimum programmable resolution.
  354. * The maximum width, stored in @max_width, is typically limited by the
  355. * maximum pitch between two adjacent scanlines. The maximum height, stored
  356. * in @max_height, is usually only limited by the amount of addressable video
  357. * memory. For hardware that has no real maximum, drivers should pick a
  358. * reasonable default.
  359. *
  360. * See also @DRM_SHADOW_PLANE_MAX_WIDTH and @DRM_SHADOW_PLANE_MAX_HEIGHT.
  361. */
  362. struct drm_mode_config {
  363. /**
  364. * @mutex:
  365. *
  366. * This is the big scary modeset BKL which protects everything that
  367. * isn't protect otherwise. Scope is unclear and fuzzy, try to remove
  368. * anything from under its protection and move it into more well-scoped
  369. * locks.
  370. *
  371. * The one important thing this protects is the use of @acquire_ctx.
  372. */
  373. struct mutex mutex;
  374. /**
  375. * @connection_mutex:
  376. *
  377. * This protects connector state and the connector to encoder to CRTC
  378. * routing chain.
  379. *
  380. * For atomic drivers specifically this protects &drm_connector.state.
  381. */
  382. struct drm_modeset_lock connection_mutex;
  383. /**
  384. * @acquire_ctx:
  385. *
  386. * Global implicit acquire context used by atomic drivers for legacy
  387. * IOCTLs. Deprecated, since implicit locking contexts make it
  388. * impossible to use driver-private &struct drm_modeset_lock. Users of
  389. * this must hold @mutex.
  390. */
  391. struct drm_modeset_acquire_ctx *acquire_ctx;
  392. /**
  393. * @idr_mutex:
  394. *
  395. * Mutex for KMS ID allocation and management. Protects both @object_idr
  396. * and @tile_idr.
  397. */
  398. struct mutex idr_mutex;
  399. /**
  400. * @object_idr:
  401. *
  402. * Main KMS ID tracking object. Use this idr for all IDs, fb, crtc,
  403. * connector, modes - just makes life easier to have only one.
  404. */
  405. struct idr object_idr;
  406. /**
  407. * @tile_idr:
  408. *
  409. * Use this idr for allocating new IDs for tiled sinks like use in some
  410. * high-res DP MST screens.
  411. */
  412. struct idr tile_idr;
  413. /** @fb_lock: Mutex to protect fb the global @fb_list and @num_fb. */
  414. struct mutex fb_lock;
  415. /** @num_fb: Number of entries on @fb_list. */
  416. int num_fb;
  417. /** @fb_list: List of all &struct drm_framebuffer. */
  418. struct list_head fb_list;
  419. /**
  420. * @connector_list_lock: Protects @num_connector and
  421. * @connector_list and @connector_free_list.
  422. */
  423. spinlock_t connector_list_lock;
  424. /**
  425. * @num_connector: Number of connectors on this device. Protected by
  426. * @connector_list_lock.
  427. */
  428. int num_connector;
  429. /**
  430. * @connector_ida: ID allocator for connector indices.
  431. */
  432. struct ida connector_ida;
  433. /**
  434. * @connector_list:
  435. *
  436. * List of connector objects linked with &drm_connector.head. Protected
  437. * by @connector_list_lock. Only use drm_for_each_connector_iter() and
  438. * &struct drm_connector_list_iter to walk this list.
  439. */
  440. struct list_head connector_list;
  441. /**
  442. * @connector_free_list:
  443. *
  444. * List of connector objects linked with &drm_connector.free_head.
  445. * Protected by @connector_list_lock. Used by
  446. * drm_for_each_connector_iter() and
  447. * &struct drm_connector_list_iter to savely free connectors using
  448. * @connector_free_work.
  449. */
  450. struct llist_head connector_free_list;
  451. /**
  452. * @connector_free_work: Work to clean up @connector_free_list.
  453. */
  454. struct work_struct connector_free_work;
  455. /**
  456. * @num_encoder:
  457. *
  458. * Number of encoders on this device. This is invariant over the
  459. * lifetime of a device and hence doesn't need any locks.
  460. */
  461. int num_encoder;
  462. /**
  463. * @encoder_list:
  464. *
  465. * List of encoder objects linked with &drm_encoder.head. This is
  466. * invariant over the lifetime of a device and hence doesn't need any
  467. * locks.
  468. */
  469. struct list_head encoder_list;
  470. /**
  471. * @num_total_plane:
  472. *
  473. * Number of universal (i.e. with primary/curso) planes on this device.
  474. * This is invariant over the lifetime of a device and hence doesn't
  475. * need any locks.
  476. */
  477. int num_total_plane;
  478. /**
  479. * @plane_list:
  480. *
  481. * List of plane objects linked with &drm_plane.head. This is invariant
  482. * over the lifetime of a device and hence doesn't need any locks.
  483. */
  484. struct list_head plane_list;
  485. /**
  486. * @num_crtc:
  487. *
  488. * Number of CRTCs on this device linked with &drm_crtc.head. This is invariant over the lifetime
  489. * of a device and hence doesn't need any locks.
  490. */
  491. int num_crtc;
  492. /**
  493. * @crtc_list:
  494. *
  495. * List of CRTC objects linked with &drm_crtc.head. This is invariant
  496. * over the lifetime of a device and hence doesn't need any locks.
  497. */
  498. struct list_head crtc_list;
  499. /**
  500. * @property_list:
  501. *
  502. * List of property type objects linked with &drm_property.head. This is
  503. * invariant over the lifetime of a device and hence doesn't need any
  504. * locks.
  505. */
  506. struct list_head property_list;
  507. /**
  508. * @privobj_list:
  509. *
  510. * List of private objects linked with &drm_private_obj.head. This is
  511. * invariant over the lifetime of a device and hence doesn't need any
  512. * locks.
  513. */
  514. struct list_head privobj_list;
  515. int min_width, min_height;
  516. int max_width, max_height;
  517. const struct drm_mode_config_funcs *funcs;
  518. resource_size_t fb_base;
  519. /* output poll support */
  520. bool poll_enabled;
  521. bool poll_running;
  522. bool delayed_event;
  523. struct delayed_work output_poll_work;
  524. /**
  525. * @blob_lock:
  526. *
  527. * Mutex for blob property allocation and management, protects
  528. * @property_blob_list and &drm_file.blobs.
  529. */
  530. struct mutex blob_lock;
  531. /**
  532. * @property_blob_list:
  533. *
  534. * List of all the blob property objects linked with
  535. * &drm_property_blob.head. Protected by @blob_lock.
  536. */
  537. struct list_head property_blob_list;
  538. /* pointers to standard properties */
  539. /**
  540. * @edid_property: Default connector property to hold the EDID of the
  541. * currently connected sink, if any.
  542. */
  543. struct drm_property *edid_property;
  544. /**
  545. * @dpms_property: Default connector property to control the
  546. * connector's DPMS state.
  547. */
  548. struct drm_property *dpms_property;
  549. /**
  550. * @path_property: Default connector property to hold the DP MST path
  551. * for the port.
  552. */
  553. struct drm_property *path_property;
  554. /**
  555. * @tile_property: Default connector property to store the tile
  556. * position of a tiled screen, for sinks which need to be driven with
  557. * multiple CRTCs.
  558. */
  559. struct drm_property *tile_property;
  560. /**
  561. * @link_status_property: Default connector property for link status
  562. * of a connector
  563. */
  564. struct drm_property *link_status_property;
  565. /**
  566. * @plane_type_property: Default plane property to differentiate
  567. * CURSOR, PRIMARY and OVERLAY legacy uses of planes.
  568. */
  569. struct drm_property *plane_type_property;
  570. /**
  571. * @prop_src_x: Default atomic plane property for the plane source
  572. * position in the connected &drm_framebuffer.
  573. */
  574. struct drm_property *prop_src_x;
  575. /**
  576. * @prop_src_y: Default atomic plane property for the plane source
  577. * position in the connected &drm_framebuffer.
  578. */
  579. struct drm_property *prop_src_y;
  580. /**
  581. * @prop_src_w: Default atomic plane property for the plane source
  582. * position in the connected &drm_framebuffer.
  583. */
  584. struct drm_property *prop_src_w;
  585. /**
  586. * @prop_src_h: Default atomic plane property for the plane source
  587. * position in the connected &drm_framebuffer.
  588. */
  589. struct drm_property *prop_src_h;
  590. /**
  591. * @prop_crtc_x: Default atomic plane property for the plane destination
  592. * position in the &drm_crtc is being shown on.
  593. */
  594. struct drm_property *prop_crtc_x;
  595. /**
  596. * @prop_crtc_y: Default atomic plane property for the plane destination
  597. * position in the &drm_crtc is being shown on.
  598. */
  599. struct drm_property *prop_crtc_y;
  600. /**
  601. * @prop_crtc_w: Default atomic plane property for the plane destination
  602. * position in the &drm_crtc is being shown on.
  603. */
  604. struct drm_property *prop_crtc_w;
  605. /**
  606. * @prop_crtc_h: Default atomic plane property for the plane destination
  607. * position in the &drm_crtc is being shown on.
  608. */
  609. struct drm_property *prop_crtc_h;
  610. /**
  611. * @prop_fb_id: Default atomic plane property to specify the
  612. * &drm_framebuffer.
  613. */
  614. struct drm_property *prop_fb_id;
  615. /**
  616. * @prop_in_fence_fd: Sync File fd representing the incoming fences
  617. * for a Plane.
  618. */
  619. struct drm_property *prop_in_fence_fd;
  620. /**
  621. * @prop_out_fence_ptr: Sync File fd pointer representing the
  622. * outgoing fences for a CRTC. Userspace should provide a pointer to a
  623. * value of type s32, and then cast that pointer to u64.
  624. */
  625. struct drm_property *prop_out_fence_ptr;
  626. /**
  627. * @prop_crtc_id: Default atomic plane property to specify the
  628. * &drm_crtc.
  629. */
  630. struct drm_property *prop_crtc_id;
  631. /**
  632. * @prop_fb_damage_clips: Optional plane property to mark damaged
  633. * regions on the plane in framebuffer coordinates of the framebuffer
  634. * attached to the plane.
  635. *
  636. * The layout of blob data is simply an array of &drm_mode_rect. Unlike
  637. * plane src coordinates, damage clips are not in 16.16 fixed point.
  638. */
  639. struct drm_property *prop_fb_damage_clips;
  640. /**
  641. * @prop_active: Default atomic CRTC property to control the active
  642. * state, which is the simplified implementation for DPMS in atomic
  643. * drivers.
  644. */
  645. struct drm_property *prop_active;
  646. /**
  647. * @prop_mode_id: Default atomic CRTC property to set the mode for a
  648. * CRTC. A 0 mode implies that the CRTC is entirely disabled - all
  649. * connectors must be of and active must be set to disabled, too.
  650. */
  651. struct drm_property *prop_mode_id;
  652. /**
  653. * @prop_vrr_enabled: Default atomic CRTC property to indicate
  654. * whether variable refresh rate should be enabled on the CRTC.
  655. */
  656. struct drm_property *prop_vrr_enabled;
  657. /**
  658. * @dvi_i_subconnector_property: Optional DVI-I property to
  659. * differentiate between analog or digital mode.
  660. */
  661. struct drm_property *dvi_i_subconnector_property;
  662. /**
  663. * @dvi_i_select_subconnector_property: Optional DVI-I property to
  664. * select between analog or digital mode.
  665. */
  666. struct drm_property *dvi_i_select_subconnector_property;
  667. /**
  668. * @dp_subconnector_property: Optional DP property to differentiate
  669. * between different DP downstream port types.
  670. */
  671. struct drm_property *dp_subconnector_property;
  672. /**
  673. * @tv_subconnector_property: Optional TV property to differentiate
  674. * between different TV connector types.
  675. */
  676. struct drm_property *tv_subconnector_property;
  677. /**
  678. * @tv_select_subconnector_property: Optional TV property to select
  679. * between different TV connector types.
  680. */
  681. struct drm_property *tv_select_subconnector_property;
  682. /**
  683. * @tv_mode_property: Optional TV property to select
  684. * the output TV mode.
  685. */
  686. struct drm_property *tv_mode_property;
  687. /**
  688. * @tv_left_margin_property: Optional TV property to set the left
  689. * margin (expressed in pixels).
  690. */
  691. struct drm_property *tv_left_margin_property;
  692. /**
  693. * @tv_right_margin_property: Optional TV property to set the right
  694. * margin (expressed in pixels).
  695. */
  696. struct drm_property *tv_right_margin_property;
  697. /**
  698. * @tv_top_margin_property: Optional TV property to set the right
  699. * margin (expressed in pixels).
  700. */
  701. struct drm_property *tv_top_margin_property;
  702. /**
  703. * @tv_bottom_margin_property: Optional TV property to set the right
  704. * margin (expressed in pixels).
  705. */
  706. struct drm_property *tv_bottom_margin_property;
  707. /**
  708. * @tv_brightness_property: Optional TV property to set the
  709. * brightness.
  710. */
  711. struct drm_property *tv_brightness_property;
  712. /**
  713. * @tv_contrast_property: Optional TV property to set the
  714. * contrast.
  715. */
  716. struct drm_property *tv_contrast_property;
  717. /**
  718. * @tv_flicker_reduction_property: Optional TV property to control the
  719. * flicker reduction mode.
  720. */
  721. struct drm_property *tv_flicker_reduction_property;
  722. /**
  723. * @tv_overscan_property: Optional TV property to control the overscan
  724. * setting.
  725. */
  726. struct drm_property *tv_overscan_property;
  727. /**
  728. * @tv_saturation_property: Optional TV property to set the
  729. * saturation.
  730. */
  731. struct drm_property *tv_saturation_property;
  732. /**
  733. * @tv_hue_property: Optional TV property to set the hue.
  734. */
  735. struct drm_property *tv_hue_property;
  736. /**
  737. * @scaling_mode_property: Optional connector property to control the
  738. * upscaling, mostly used for built-in panels.
  739. */
  740. struct drm_property *scaling_mode_property;
  741. /**
  742. * @aspect_ratio_property: Optional connector property to control the
  743. * HDMI infoframe aspect ratio setting.
  744. */
  745. struct drm_property *aspect_ratio_property;
  746. /**
  747. * @content_type_property: Optional connector property to control the
  748. * HDMI infoframe content type setting.
  749. */
  750. struct drm_property *content_type_property;
  751. /**
  752. * @degamma_lut_property: Optional CRTC property to set the LUT used to
  753. * convert the framebuffer's colors to linear gamma.
  754. */
  755. struct drm_property *degamma_lut_property;
  756. /**
  757. * @degamma_lut_size_property: Optional CRTC property for the size of
  758. * the degamma LUT as supported by the driver (read-only).
  759. */
  760. struct drm_property *degamma_lut_size_property;
  761. /**
  762. * @ctm_property: Optional CRTC property to set the
  763. * matrix used to convert colors after the lookup in the
  764. * degamma LUT.
  765. */
  766. struct drm_property *ctm_property;
  767. /**
  768. * @gamma_lut_property: Optional CRTC property to set the LUT used to
  769. * convert the colors, after the CTM matrix, to the gamma space of the
  770. * connected screen.
  771. */
  772. struct drm_property *gamma_lut_property;
  773. /**
  774. * @gamma_lut_size_property: Optional CRTC property for the size of the
  775. * gamma LUT as supported by the driver (read-only).
  776. */
  777. struct drm_property *gamma_lut_size_property;
  778. /**
  779. * @suggested_x_property: Optional connector property with a hint for
  780. * the position of the output on the host's screen.
  781. */
  782. struct drm_property *suggested_x_property;
  783. /**
  784. * @suggested_y_property: Optional connector property with a hint for
  785. * the position of the output on the host's screen.
  786. */
  787. struct drm_property *suggested_y_property;
  788. /**
  789. * @non_desktop_property: Optional connector property with a hint
  790. * that device isn't a standard display, and the console/desktop,
  791. * should not be displayed on it.
  792. */
  793. struct drm_property *non_desktop_property;
  794. /**
  795. * @panel_orientation_property: Optional connector property indicating
  796. * how the lcd-panel is mounted inside the casing (e.g. normal or
  797. * upside-down).
  798. */
  799. struct drm_property *panel_orientation_property;
  800. /**
  801. * @writeback_fb_id_property: Property for writeback connectors, storing
  802. * the ID of the output framebuffer.
  803. * See also: drm_writeback_connector_init()
  804. */
  805. struct drm_property *writeback_fb_id_property;
  806. /**
  807. * @writeback_pixel_formats_property: Property for writeback connectors,
  808. * storing an array of the supported pixel formats for the writeback
  809. * engine (read-only).
  810. * See also: drm_writeback_connector_init()
  811. */
  812. struct drm_property *writeback_pixel_formats_property;
  813. /**
  814. * @writeback_out_fence_ptr_property: Property for writeback connectors,
  815. * fd pointer representing the outgoing fences for a writeback
  816. * connector. Userspace should provide a pointer to a value of type s32,
  817. * and then cast that pointer to u64.
  818. * See also: drm_writeback_connector_init()
  819. */
  820. struct drm_property *writeback_out_fence_ptr_property;
  821. /**
  822. * @hdr_output_metadata_property: Connector property containing hdr
  823. * metatada. This will be provided by userspace compositors based
  824. * on HDR content
  825. */
  826. struct drm_property *hdr_output_metadata_property;
  827. /**
  828. * @content_protection_property: DRM ENUM property for content
  829. * protection. See drm_connector_attach_content_protection_property().
  830. */
  831. struct drm_property *content_protection_property;
  832. /**
  833. * @hdcp_content_type_property: DRM ENUM property for type of
  834. * Protected Content.
  835. */
  836. struct drm_property *hdcp_content_type_property;
  837. /* dumb ioctl parameters */
  838. uint32_t preferred_depth, prefer_shadow;
  839. /**
  840. * @prefer_shadow_fbdev:
  841. *
  842. * Hint to framebuffer emulation to prefer shadow-fb rendering.
  843. */
  844. bool prefer_shadow_fbdev;
  845. /**
  846. * @quirk_addfb_prefer_xbgr_30bpp:
  847. *
  848. * Special hack for legacy ADDFB to keep nouveau userspace happy. Should
  849. * only ever be set by the nouveau kernel driver.
  850. */
  851. bool quirk_addfb_prefer_xbgr_30bpp;
  852. /**
  853. * @quirk_addfb_prefer_host_byte_order:
  854. *
  855. * When set to true drm_mode_addfb() will pick host byte order
  856. * pixel_format when calling drm_mode_addfb2(). This is how
  857. * drm_mode_addfb() should have worked from day one. It
  858. * didn't though, so we ended up with quirks in both kernel
  859. * and userspace drivers to deal with the broken behavior.
  860. * Simply fixing drm_mode_addfb() unconditionally would break
  861. * these drivers, so add a quirk bit here to allow drivers
  862. * opt-in.
  863. */
  864. bool quirk_addfb_prefer_host_byte_order;
  865. /**
  866. * @async_page_flip: Does this device support async flips on the primary
  867. * plane?
  868. */
  869. bool async_page_flip;
  870. /**
  871. * @fb_modifiers_not_supported:
  872. *
  873. * When this flag is set, the DRM device will not expose modifier
  874. * support to userspace. This is only used by legacy drivers that infer
  875. * the buffer layout through heuristics without using modifiers. New
  876. * drivers shall not set fhis flag.
  877. */
  878. bool fb_modifiers_not_supported;
  879. /**
  880. * @normalize_zpos:
  881. *
  882. * If true the drm core will call drm_atomic_normalize_zpos() as part of
  883. * atomic mode checking from drm_atomic_helper_check()
  884. */
  885. bool normalize_zpos;
  886. /**
  887. * @modifiers_property: Plane property to list support modifier/format
  888. * combination.
  889. */
  890. struct drm_property *modifiers_property;
  891. /* cursor size */
  892. uint32_t cursor_width, cursor_height;
  893. /**
  894. * @suspend_state:
  895. *
  896. * Atomic state when suspended.
  897. * Set by drm_mode_config_helper_suspend() and cleared by
  898. * drm_mode_config_helper_resume().
  899. */
  900. struct drm_atomic_state *suspend_state;
  901. const struct drm_mode_config_helper_funcs *helper_private;
  902. };
  903. int __must_check drmm_mode_config_init(struct drm_device *dev);
  904. /**
  905. * drm_mode_config_init - DRM mode_configuration structure initialization
  906. * @dev: DRM device
  907. *
  908. * This is the unmanaged version of drmm_mode_config_init() for drivers which
  909. * still explicitly call drm_mode_config_cleanup().
  910. *
  911. * FIXME: This function is deprecated and drivers should be converted over to
  912. * drmm_mode_config_init().
  913. */
  914. static inline int drm_mode_config_init(struct drm_device *dev)
  915. {
  916. return drmm_mode_config_init(dev);
  917. }
  918. void drm_mode_config_reset(struct drm_device *dev);
  919. void drm_mode_config_cleanup(struct drm_device *dev);
  920. #endif