drm_mode_config.h 33 KB

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