drm_modeset_helper_vtables.h 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188
  1. /*
  2. * Copyright © 2006 Keith Packard
  3. * Copyright © 2007-2008 Dave Airlie
  4. * Copyright © 2007-2008 Intel Corporation
  5. * Jesse Barnes <jesse.barnes@intel.com>
  6. * Copyright © 2011-2013 Intel Corporation
  7. * Copyright © 2015 Intel Corporation
  8. * Daniel Vetter <daniel.vetter@ffwll.ch>
  9. *
  10. * Permission is hereby granted, free of charge, to any person obtaining a
  11. * copy of this software and associated documentation files (the "Software"),
  12. * to deal in the Software without restriction, including without limitation
  13. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  14. * and/or sell copies of the Software, and to permit persons to whom the
  15. * Software is furnished to do so, subject to the following conditions:
  16. *
  17. * The above copyright notice and this permission notice shall be included in
  18. * all copies or substantial portions of the Software.
  19. *
  20. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  23. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  24. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  25. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26. * OTHER DEALINGS IN THE SOFTWARE.
  27. */
  28. #ifndef __DRM_MODESET_HELPER_VTABLES_H__
  29. #define __DRM_MODESET_HELPER_VTABLES_H__
  30. #include <drm/drm_crtc.h>
  31. #include <drm/drm_encoder.h>
  32. /**
  33. * DOC: overview
  34. *
  35. * The DRM mode setting helper functions are common code for drivers to use if
  36. * they wish. Drivers are not forced to use this code in their
  37. * implementations but it would be useful if the code they do use at least
  38. * provides a consistent interface and operation to userspace. Therefore it is
  39. * highly recommended to use the provided helpers as much as possible.
  40. *
  41. * Because there is only one pointer per modeset object to hold a vfunc table
  42. * for helper libraries they are by necessity shared among the different
  43. * helpers.
  44. *
  45. * To make this clear all the helper vtables are pulled together in this location here.
  46. */
  47. enum mode_set_atomic;
  48. /**
  49. * struct drm_crtc_helper_funcs - helper operations for CRTCs
  50. *
  51. * These hooks are used by the legacy CRTC helpers, the transitional plane
  52. * helpers and the new atomic modesetting helpers.
  53. */
  54. struct drm_crtc_helper_funcs {
  55. /**
  56. * @dpms:
  57. *
  58. * Callback to control power levels on the CRTC. If the mode passed in
  59. * is unsupported, the provider must use the next lowest power level.
  60. * This is used by the legacy CRTC helpers to implement DPMS
  61. * functionality in drm_helper_connector_dpms().
  62. *
  63. * This callback is also used to disable a CRTC by calling it with
  64. * DRM_MODE_DPMS_OFF if the @disable hook isn't used.
  65. *
  66. * This callback is used by the legacy CRTC helpers. Atomic helpers
  67. * also support using this hook for enabling and disabling a CRTC to
  68. * facilitate transitions to atomic, but it is deprecated. Instead
  69. * @enable and @disable should be used.
  70. */
  71. void (*dpms)(struct drm_crtc *crtc, int mode);
  72. /**
  73. * @prepare:
  74. *
  75. * This callback should prepare the CRTC for a subsequent modeset, which
  76. * in practice means the driver should disable the CRTC if it is
  77. * running. Most drivers ended up implementing this by calling their
  78. * @dpms hook with DRM_MODE_DPMS_OFF.
  79. *
  80. * This callback is used by the legacy CRTC helpers. Atomic helpers
  81. * also support using this hook for disabling a CRTC to facilitate
  82. * transitions to atomic, but it is deprecated. Instead @disable should
  83. * be used.
  84. */
  85. void (*prepare)(struct drm_crtc *crtc);
  86. /**
  87. * @commit:
  88. *
  89. * This callback should commit the new mode on the CRTC after a modeset,
  90. * which in practice means the driver should enable the CRTC. Most
  91. * drivers ended up implementing this by calling their @dpms hook with
  92. * DRM_MODE_DPMS_ON.
  93. *
  94. * This callback is used by the legacy CRTC helpers. Atomic helpers
  95. * also support using this hook for enabling a CRTC to facilitate
  96. * transitions to atomic, but it is deprecated. Instead @enable should
  97. * be used.
  98. */
  99. void (*commit)(struct drm_crtc *crtc);
  100. /**
  101. * @mode_valid:
  102. *
  103. * This callback is used to check if a specific mode is valid in this
  104. * crtc. This should be implemented if the crtc has some sort of
  105. * restriction in the modes it can display. For example, a given crtc
  106. * may be responsible to set a clock value. If the clock can not
  107. * produce all the values for the available modes then this callback
  108. * can be used to restrict the number of modes to only the ones that
  109. * can be displayed.
  110. *
  111. * This hook is used by the probe helpers to filter the mode list in
  112. * drm_helper_probe_single_connector_modes(), and it is used by the
  113. * atomic helpers to validate modes supplied by userspace in
  114. * drm_atomic_helper_check_modeset().
  115. *
  116. * This function is optional.
  117. *
  118. * NOTE:
  119. *
  120. * Since this function is both called from the check phase of an atomic
  121. * commit, and the mode validation in the probe paths it is not allowed
  122. * to look at anything else but the passed-in mode, and validate it
  123. * against configuration-invariant hardward constraints. Any further
  124. * limits which depend upon the configuration can only be checked in
  125. * @mode_fixup or @atomic_check.
  126. *
  127. * RETURNS:
  128. *
  129. * drm_mode_status Enum
  130. */
  131. enum drm_mode_status (*mode_valid)(struct drm_crtc *crtc,
  132. const struct drm_display_mode *mode);
  133. /**
  134. * @mode_fixup:
  135. *
  136. * This callback is used to validate a mode. The parameter mode is the
  137. * display mode that userspace requested, adjusted_mode is the mode the
  138. * encoders need to be fed with. Note that this is the inverse semantics
  139. * of the meaning for the &drm_encoder and &drm_bridge_funcs.mode_fixup
  140. * vfunc. If the CRTC cannot support the requested conversion from mode
  141. * to adjusted_mode it should reject the modeset. See also
  142. * &drm_crtc_state.adjusted_mode for more details.
  143. *
  144. * This function is used by both legacy CRTC helpers and atomic helpers.
  145. * With atomic helpers it is optional.
  146. *
  147. * NOTE:
  148. *
  149. * This function is called in the check phase of atomic modesets, which
  150. * can be aborted for any reason (including on userspace's request to
  151. * just check whether a configuration would be possible). Atomic drivers
  152. * MUST NOT touch any persistent state (hardware or software) or data
  153. * structures except the passed in adjusted_mode parameter.
  154. *
  155. * This is in contrast to the legacy CRTC helpers where this was
  156. * allowed.
  157. *
  158. * Atomic drivers which need to inspect and adjust more state should
  159. * instead use the @atomic_check callback, but note that they're not
  160. * perfectly equivalent: @mode_valid is called from
  161. * drm_atomic_helper_check_modeset(), but @atomic_check is called from
  162. * drm_atomic_helper_check_planes(), because originally it was meant for
  163. * plane update checks only.
  164. *
  165. * Also beware that userspace can request its own custom modes, neither
  166. * core nor helpers filter modes to the list of probe modes reported by
  167. * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
  168. * that modes are filtered consistently put any CRTC constraints and
  169. * limits checks into @mode_valid.
  170. *
  171. * RETURNS:
  172. *
  173. * True if an acceptable configuration is possible, false if the modeset
  174. * operation should be rejected.
  175. */
  176. bool (*mode_fixup)(struct drm_crtc *crtc,
  177. const struct drm_display_mode *mode,
  178. struct drm_display_mode *adjusted_mode);
  179. /**
  180. * @mode_set:
  181. *
  182. * This callback is used by the legacy CRTC helpers to set a new mode,
  183. * position and framebuffer. Since it ties the primary plane to every
  184. * mode change it is incompatible with universal plane support. And
  185. * since it can't update other planes it's incompatible with atomic
  186. * modeset support.
  187. *
  188. * This callback is only used by CRTC helpers and deprecated.
  189. *
  190. * RETURNS:
  191. *
  192. * 0 on success or a negative error code on failure.
  193. */
  194. int (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode,
  195. struct drm_display_mode *adjusted_mode, int x, int y,
  196. struct drm_framebuffer *old_fb);
  197. /**
  198. * @mode_set_nofb:
  199. *
  200. * This callback is used to update the display mode of a CRTC without
  201. * changing anything of the primary plane configuration. This fits the
  202. * requirement of atomic and hence is used by the atomic helpers. It is
  203. * also used by the transitional plane helpers to implement a
  204. * @mode_set hook in drm_helper_crtc_mode_set().
  205. *
  206. * Note that the display pipe is completely off when this function is
  207. * called. Atomic drivers which need hardware to be running before they
  208. * program the new display mode (e.g. because they implement runtime PM)
  209. * should not use this hook. This is because the helper library calls
  210. * this hook only once per mode change and not every time the display
  211. * pipeline is suspended using either DPMS or the new "ACTIVE" property.
  212. * Which means register values set in this callback might get reset when
  213. * the CRTC is suspended, but not restored. Such drivers should instead
  214. * move all their CRTC setup into the @enable callback.
  215. *
  216. * This callback is optional.
  217. */
  218. void (*mode_set_nofb)(struct drm_crtc *crtc);
  219. /**
  220. * @mode_set_base:
  221. *
  222. * This callback is used by the legacy CRTC helpers to set a new
  223. * framebuffer and scanout position. It is optional and used as an
  224. * optimized fast-path instead of a full mode set operation with all the
  225. * resulting flickering. If it is not present
  226. * drm_crtc_helper_set_config() will fall back to a full modeset, using
  227. * the @mode_set callback. Since it can't update other planes it's
  228. * incompatible with atomic modeset support.
  229. *
  230. * This callback is only used by the CRTC helpers and deprecated.
  231. *
  232. * RETURNS:
  233. *
  234. * 0 on success or a negative error code on failure.
  235. */
  236. int (*mode_set_base)(struct drm_crtc *crtc, int x, int y,
  237. struct drm_framebuffer *old_fb);
  238. /**
  239. * @mode_set_base_atomic:
  240. *
  241. * This callback is used by the fbdev helpers to set a new framebuffer
  242. * and scanout without sleeping, i.e. from an atomic calling context. It
  243. * is only used to implement kgdb support.
  244. *
  245. * This callback is optional and only needed for kgdb support in the fbdev
  246. * helpers.
  247. *
  248. * RETURNS:
  249. *
  250. * 0 on success or a negative error code on failure.
  251. */
  252. int (*mode_set_base_atomic)(struct drm_crtc *crtc,
  253. struct drm_framebuffer *fb, int x, int y,
  254. enum mode_set_atomic);
  255. /**
  256. * @load_lut:
  257. *
  258. * Load a LUT prepared with the &drm_fb_helper_funcs.gamma_set vfunc.
  259. *
  260. * This callback is optional and is only used by the fbdev emulation
  261. * helpers.
  262. *
  263. * FIXME:
  264. *
  265. * This callback is functionally redundant with the core gamma table
  266. * support and simply exists because the fbdev hasn't yet been
  267. * refactored to use the core gamma table interfaces.
  268. */
  269. void (*load_lut)(struct drm_crtc *crtc);
  270. /**
  271. * @disable:
  272. *
  273. * This callback should be used to disable the CRTC. With the atomic
  274. * drivers it is called after all encoders connected to this CRTC have
  275. * been shut off already using their own
  276. * &drm_encoder_helper_funcs.disable hook. If that sequence is too
  277. * simple drivers can just add their own hooks and call it from this
  278. * CRTC callback here by looping over all encoders connected to it using
  279. * for_each_encoder_on_crtc().
  280. *
  281. * This hook is used both by legacy CRTC helpers and atomic helpers.
  282. * Atomic drivers don't need to implement it if there's no need to
  283. * disable anything at the CRTC level. To ensure that runtime PM
  284. * handling (using either DPMS or the new "ACTIVE" property) works
  285. * @disable must be the inverse of @enable for atomic drivers.
  286. * Atomic drivers should consider to use @atomic_disable instead of
  287. * this one.
  288. *
  289. * NOTE:
  290. *
  291. * With legacy CRTC helpers there's a big semantic difference between
  292. * @disable and other hooks (like @prepare or @dpms) used to shut down a
  293. * CRTC: @disable is only called when also logically disabling the
  294. * display pipeline and needs to release any resources acquired in
  295. * @mode_set (like shared PLLs, or again release pinned framebuffers).
  296. *
  297. * Therefore @disable must be the inverse of @mode_set plus @commit for
  298. * drivers still using legacy CRTC helpers, which is different from the
  299. * rules under atomic.
  300. */
  301. void (*disable)(struct drm_crtc *crtc);
  302. /**
  303. * @enable:
  304. *
  305. * This callback should be used to enable the CRTC. With the atomic
  306. * drivers it is called before all encoders connected to this CRTC are
  307. * enabled through the encoder's own &drm_encoder_helper_funcs.enable
  308. * hook. If that sequence is too simple drivers can just add their own
  309. * hooks and call it from this CRTC callback here by looping over all
  310. * encoders connected to it using for_each_encoder_on_crtc().
  311. *
  312. * This hook is used only by atomic helpers, for symmetry with @disable.
  313. * Atomic drivers don't need to implement it if there's no need to
  314. * enable anything at the CRTC level. To ensure that runtime PM handling
  315. * (using either DPMS or the new "ACTIVE" property) works
  316. * @enable must be the inverse of @disable for atomic drivers.
  317. */
  318. void (*enable)(struct drm_crtc *crtc);
  319. /**
  320. * @atomic_check:
  321. *
  322. * Drivers should check plane-update related CRTC constraints in this
  323. * hook. They can also check mode related limitations but need to be
  324. * aware of the calling order, since this hook is used by
  325. * drm_atomic_helper_check_planes() whereas the preparations needed to
  326. * check output routing and the display mode is done in
  327. * drm_atomic_helper_check_modeset(). Therefore drivers that want to
  328. * check output routing and display mode constraints in this callback
  329. * must ensure that drm_atomic_helper_check_modeset() has been called
  330. * beforehand. This is calling order used by the default helper
  331. * implementation in drm_atomic_helper_check().
  332. *
  333. * When using drm_atomic_helper_check_planes() this hook is called
  334. * after the &drm_plane_helper_funcs.atomc_check hook for planes, which
  335. * allows drivers to assign shared resources requested by planes in this
  336. * callback here. For more complicated dependencies the driver can call
  337. * the provided check helpers multiple times until the computed state
  338. * has a final configuration and everything has been checked.
  339. *
  340. * This function is also allowed to inspect any other object's state and
  341. * can add more state objects to the atomic commit if needed. Care must
  342. * be taken though to ensure that state check and compute functions for
  343. * these added states are all called, and derived state in other objects
  344. * all updated. Again the recommendation is to just call check helpers
  345. * until a maximal configuration is reached.
  346. *
  347. * This callback is used by the atomic modeset helpers and by the
  348. * transitional plane helpers, but it is optional.
  349. *
  350. * NOTE:
  351. *
  352. * This function is called in the check phase of an atomic update. The
  353. * driver is not allowed to change anything outside of the free-standing
  354. * state objects passed-in or assembled in the overall &drm_atomic_state
  355. * update tracking structure.
  356. *
  357. * Also beware that userspace can request its own custom modes, neither
  358. * core nor helpers filter modes to the list of probe modes reported by
  359. * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
  360. * that modes are filtered consistently put any CRTC constraints and
  361. * limits checks into @mode_valid.
  362. *
  363. * RETURNS:
  364. *
  365. * 0 on success, -EINVAL if the state or the transition can't be
  366. * supported, -ENOMEM on memory allocation failure and -EDEADLK if an
  367. * attempt to obtain another state object ran into a &drm_modeset_lock
  368. * deadlock.
  369. */
  370. int (*atomic_check)(struct drm_crtc *crtc,
  371. struct drm_crtc_state *state);
  372. /**
  373. * @atomic_begin:
  374. *
  375. * Drivers should prepare for an atomic update of multiple planes on
  376. * a CRTC in this hook. Depending upon hardware this might be vblank
  377. * evasion, blocking updates by setting bits or doing preparatory work
  378. * for e.g. manual update display.
  379. *
  380. * This hook is called before any plane commit functions are called.
  381. *
  382. * Note that the power state of the display pipe when this function is
  383. * called depends upon the exact helpers and calling sequence the driver
  384. * has picked. See drm_atomic_helper_commit_planes() for a discussion of
  385. * the tradeoffs and variants of plane commit helpers.
  386. *
  387. * This callback is used by the atomic modeset helpers and by the
  388. * transitional plane helpers, but it is optional.
  389. */
  390. void (*atomic_begin)(struct drm_crtc *crtc,
  391. struct drm_crtc_state *old_crtc_state);
  392. /**
  393. * @atomic_flush:
  394. *
  395. * Drivers should finalize an atomic update of multiple planes on
  396. * a CRTC in this hook. Depending upon hardware this might include
  397. * checking that vblank evasion was successful, unblocking updates by
  398. * setting bits or setting the GO bit to flush out all updates.
  399. *
  400. * Simple hardware or hardware with special requirements can commit and
  401. * flush out all updates for all planes from this hook and forgo all the
  402. * other commit hooks for plane updates.
  403. *
  404. * This hook is called after any plane commit functions are called.
  405. *
  406. * Note that the power state of the display pipe when this function is
  407. * called depends upon the exact helpers and calling sequence the driver
  408. * has picked. See drm_atomic_helper_commit_planes() for a discussion of
  409. * the tradeoffs and variants of plane commit helpers.
  410. *
  411. * This callback is used by the atomic modeset helpers and by the
  412. * transitional plane helpers, but it is optional.
  413. */
  414. void (*atomic_flush)(struct drm_crtc *crtc,
  415. struct drm_crtc_state *old_crtc_state);
  416. /**
  417. * @atomic_disable:
  418. *
  419. * This callback should be used to disable the CRTC. With the atomic
  420. * drivers it is called after all encoders connected to this CRTC have
  421. * been shut off already using their own
  422. * &drm_encoder_helper_funcs.disable hook. If that sequence is too
  423. * simple drivers can just add their own hooks and call it from this
  424. * CRTC callback here by looping over all encoders connected to it using
  425. * for_each_encoder_on_crtc().
  426. *
  427. * This hook is used only by atomic helpers. Atomic drivers don't
  428. * need to implement it if there's no need to disable anything at the
  429. * CRTC level.
  430. *
  431. * Comparing to @disable, this one provides the additional input
  432. * parameter @old_crtc_state which could be used to access the old
  433. * state. Atomic drivers should consider to use this one instead
  434. * of @disable.
  435. */
  436. void (*atomic_disable)(struct drm_crtc *crtc,
  437. struct drm_crtc_state *old_crtc_state);
  438. };
  439. /**
  440. * drm_crtc_helper_add - sets the helper vtable for a crtc
  441. * @crtc: DRM CRTC
  442. * @funcs: helper vtable to set for @crtc
  443. */
  444. static inline void drm_crtc_helper_add(struct drm_crtc *crtc,
  445. const struct drm_crtc_helper_funcs *funcs)
  446. {
  447. crtc->helper_private = funcs;
  448. }
  449. /**
  450. * struct drm_encoder_helper_funcs - helper operations for encoders
  451. *
  452. * These hooks are used by the legacy CRTC helpers, the transitional plane
  453. * helpers and the new atomic modesetting helpers.
  454. */
  455. struct drm_encoder_helper_funcs {
  456. /**
  457. * @dpms:
  458. *
  459. * Callback to control power levels on the encoder. If the mode passed in
  460. * is unsupported, the provider must use the next lowest power level.
  461. * This is used by the legacy encoder helpers to implement DPMS
  462. * functionality in drm_helper_connector_dpms().
  463. *
  464. * This callback is also used to disable an encoder by calling it with
  465. * DRM_MODE_DPMS_OFF if the @disable hook isn't used.
  466. *
  467. * This callback is used by the legacy CRTC helpers. Atomic helpers
  468. * also support using this hook for enabling and disabling an encoder to
  469. * facilitate transitions to atomic, but it is deprecated. Instead
  470. * @enable and @disable should be used.
  471. */
  472. void (*dpms)(struct drm_encoder *encoder, int mode);
  473. /**
  474. * @mode_valid:
  475. *
  476. * This callback is used to check if a specific mode is valid in this
  477. * encoder. This should be implemented if the encoder has some sort
  478. * of restriction in the modes it can display. For example, a given
  479. * encoder may be responsible to set a clock value. If the clock can
  480. * not produce all the values for the available modes then this callback
  481. * can be used to restrict the number of modes to only the ones that
  482. * can be displayed.
  483. *
  484. * This hook is used by the probe helpers to filter the mode list in
  485. * drm_helper_probe_single_connector_modes(), and it is used by the
  486. * atomic helpers to validate modes supplied by userspace in
  487. * drm_atomic_helper_check_modeset().
  488. *
  489. * This function is optional.
  490. *
  491. * NOTE:
  492. *
  493. * Since this function is both called from the check phase of an atomic
  494. * commit, and the mode validation in the probe paths it is not allowed
  495. * to look at anything else but the passed-in mode, and validate it
  496. * against configuration-invariant hardward constraints. Any further
  497. * limits which depend upon the configuration can only be checked in
  498. * @mode_fixup or @atomic_check.
  499. *
  500. * RETURNS:
  501. *
  502. * drm_mode_status Enum
  503. */
  504. enum drm_mode_status (*mode_valid)(struct drm_encoder *crtc,
  505. const struct drm_display_mode *mode);
  506. /**
  507. * @mode_fixup:
  508. *
  509. * This callback is used to validate and adjust a mode. The parameter
  510. * mode is the display mode that should be fed to the next element in
  511. * the display chain, either the final &drm_connector or a &drm_bridge.
  512. * The parameter adjusted_mode is the input mode the encoder requires. It
  513. * can be modified by this callback and does not need to match mode. See
  514. * also &drm_crtc_state.adjusted_mode for more details.
  515. *
  516. * This function is used by both legacy CRTC helpers and atomic helpers.
  517. * This hook is optional.
  518. *
  519. * NOTE:
  520. *
  521. * This function is called in the check phase of atomic modesets, which
  522. * can be aborted for any reason (including on userspace's request to
  523. * just check whether a configuration would be possible). Atomic drivers
  524. * MUST NOT touch any persistent state (hardware or software) or data
  525. * structures except the passed in adjusted_mode parameter.
  526. *
  527. * This is in contrast to the legacy CRTC helpers where this was
  528. * allowed.
  529. *
  530. * Atomic drivers which need to inspect and adjust more state should
  531. * instead use the @atomic_check callback. If @atomic_check is used,
  532. * this hook isn't called since @atomic_check allows a strict superset
  533. * of the functionality of @mode_fixup.
  534. *
  535. * Also beware that userspace can request its own custom modes, neither
  536. * core nor helpers filter modes to the list of probe modes reported by
  537. * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
  538. * that modes are filtered consistently put any encoder constraints and
  539. * limits checks into @mode_valid.
  540. *
  541. * RETURNS:
  542. *
  543. * True if an acceptable configuration is possible, false if the modeset
  544. * operation should be rejected.
  545. */
  546. bool (*mode_fixup)(struct drm_encoder *encoder,
  547. const struct drm_display_mode *mode,
  548. struct drm_display_mode *adjusted_mode);
  549. /**
  550. * @prepare:
  551. *
  552. * This callback should prepare the encoder for a subsequent modeset,
  553. * which in practice means the driver should disable the encoder if it
  554. * is running. Most drivers ended up implementing this by calling their
  555. * @dpms hook with DRM_MODE_DPMS_OFF.
  556. *
  557. * This callback is used by the legacy CRTC helpers. Atomic helpers
  558. * also support using this hook for disabling an encoder to facilitate
  559. * transitions to atomic, but it is deprecated. Instead @disable should
  560. * be used.
  561. */
  562. void (*prepare)(struct drm_encoder *encoder);
  563. /**
  564. * @commit:
  565. *
  566. * This callback should commit the new mode on the encoder after a modeset,
  567. * which in practice means the driver should enable the encoder. Most
  568. * drivers ended up implementing this by calling their @dpms hook with
  569. * DRM_MODE_DPMS_ON.
  570. *
  571. * This callback is used by the legacy CRTC helpers. Atomic helpers
  572. * also support using this hook for enabling an encoder to facilitate
  573. * transitions to atomic, but it is deprecated. Instead @enable should
  574. * be used.
  575. */
  576. void (*commit)(struct drm_encoder *encoder);
  577. /**
  578. * @mode_set:
  579. *
  580. * This callback is used to update the display mode of an encoder.
  581. *
  582. * Note that the display pipe is completely off when this function is
  583. * called. Drivers which need hardware to be running before they program
  584. * the new display mode (because they implement runtime PM) should not
  585. * use this hook, because the helper library calls it only once and not
  586. * every time the display pipeline is suspend using either DPMS or the
  587. * new "ACTIVE" property. Such drivers should instead move all their
  588. * encoder setup into the @enable callback.
  589. *
  590. * This callback is used both by the legacy CRTC helpers and the atomic
  591. * modeset helpers. It is optional in the atomic helpers.
  592. *
  593. * NOTE:
  594. *
  595. * If the driver uses the atomic modeset helpers and needs to inspect
  596. * the connector state or connector display info during mode setting,
  597. * @atomic_mode_set can be used instead.
  598. */
  599. void (*mode_set)(struct drm_encoder *encoder,
  600. struct drm_display_mode *mode,
  601. struct drm_display_mode *adjusted_mode);
  602. /**
  603. * @atomic_mode_set:
  604. *
  605. * This callback is used to update the display mode of an encoder.
  606. *
  607. * Note that the display pipe is completely off when this function is
  608. * called. Drivers which need hardware to be running before they program
  609. * the new display mode (because they implement runtime PM) should not
  610. * use this hook, because the helper library calls it only once and not
  611. * every time the display pipeline is suspended using either DPMS or the
  612. * new "ACTIVE" property. Such drivers should instead move all their
  613. * encoder setup into the @enable callback.
  614. *
  615. * This callback is used by the atomic modeset helpers in place of the
  616. * @mode_set callback, if set by the driver. It is optional and should
  617. * be used instead of @mode_set if the driver needs to inspect the
  618. * connector state or display info, since there is no direct way to
  619. * go from the encoder to the current connector.
  620. */
  621. void (*atomic_mode_set)(struct drm_encoder *encoder,
  622. struct drm_crtc_state *crtc_state,
  623. struct drm_connector_state *conn_state);
  624. /**
  625. * @get_crtc:
  626. *
  627. * This callback is used by the legacy CRTC helpers to work around
  628. * deficiencies in its own book-keeping.
  629. *
  630. * Do not use, use atomic helpers instead, which get the book keeping
  631. * right.
  632. *
  633. * FIXME:
  634. *
  635. * Currently only nouveau is using this, and as soon as nouveau is
  636. * atomic we can ditch this hook.
  637. */
  638. struct drm_crtc *(*get_crtc)(struct drm_encoder *encoder);
  639. /**
  640. * @detect:
  641. *
  642. * This callback can be used by drivers who want to do detection on the
  643. * encoder object instead of in connector functions.
  644. *
  645. * It is not used by any helper and therefore has purely driver-specific
  646. * semantics. New drivers shouldn't use this and instead just implement
  647. * their own private callbacks.
  648. *
  649. * FIXME:
  650. *
  651. * This should just be converted into a pile of driver vfuncs.
  652. * Currently radeon, amdgpu and nouveau are using it.
  653. */
  654. enum drm_connector_status (*detect)(struct drm_encoder *encoder,
  655. struct drm_connector *connector);
  656. /**
  657. * @disable:
  658. *
  659. * This callback should be used to disable the encoder. With the atomic
  660. * drivers it is called before this encoder's CRTC has been shut off
  661. * using their own &drm_crtc_helper_funcs.disable hook. If that
  662. * sequence is too simple drivers can just add their own driver private
  663. * encoder hooks and call them from CRTC's callback by looping over all
  664. * encoders connected to it using for_each_encoder_on_crtc().
  665. *
  666. * This hook is used both by legacy CRTC helpers and atomic helpers.
  667. * Atomic drivers don't need to implement it if there's no need to
  668. * disable anything at the encoder level. To ensure that runtime PM
  669. * handling (using either DPMS or the new "ACTIVE" property) works
  670. * @disable must be the inverse of @enable for atomic drivers.
  671. *
  672. * NOTE:
  673. *
  674. * With legacy CRTC helpers there's a big semantic difference between
  675. * @disable and other hooks (like @prepare or @dpms) used to shut down a
  676. * encoder: @disable is only called when also logically disabling the
  677. * display pipeline and needs to release any resources acquired in
  678. * @mode_set (like shared PLLs, or again release pinned framebuffers).
  679. *
  680. * Therefore @disable must be the inverse of @mode_set plus @commit for
  681. * drivers still using legacy CRTC helpers, which is different from the
  682. * rules under atomic.
  683. */
  684. void (*disable)(struct drm_encoder *encoder);
  685. /**
  686. * @enable:
  687. *
  688. * This callback should be used to enable the encoder. With the atomic
  689. * drivers it is called after this encoder's CRTC has been enabled using
  690. * their own &drm_crtc_helper_funcs.enable hook. If that sequence is
  691. * too simple drivers can just add their own driver private encoder
  692. * hooks and call them from CRTC's callback by looping over all encoders
  693. * connected to it using for_each_encoder_on_crtc().
  694. *
  695. * This hook is used only by atomic helpers, for symmetry with @disable.
  696. * Atomic drivers don't need to implement it if there's no need to
  697. * enable anything at the encoder level. To ensure that runtime PM handling
  698. * (using either DPMS or the new "ACTIVE" property) works
  699. * @enable must be the inverse of @disable for atomic drivers.
  700. */
  701. void (*enable)(struct drm_encoder *encoder);
  702. /**
  703. * @atomic_check:
  704. *
  705. * This callback is used to validate encoder state for atomic drivers.
  706. * Since the encoder is the object connecting the CRTC and connector it
  707. * gets passed both states, to be able to validate interactions and
  708. * update the CRTC to match what the encoder needs for the requested
  709. * connector.
  710. *
  711. * Since this provides a strict superset of the functionality of
  712. * @mode_fixup (the requested and adjusted modes are both available
  713. * through the passed in &struct drm_crtc_state) @mode_fixup is not
  714. * called when @atomic_check is implemented.
  715. *
  716. * This function is used by the atomic helpers, but it is optional.
  717. *
  718. * NOTE:
  719. *
  720. * This function is called in the check phase of an atomic update. The
  721. * driver is not allowed to change anything outside of the free-standing
  722. * state objects passed-in or assembled in the overall &drm_atomic_state
  723. * update tracking structure.
  724. *
  725. * Also beware that userspace can request its own custom modes, neither
  726. * core nor helpers filter modes to the list of probe modes reported by
  727. * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
  728. * that modes are filtered consistently put any encoder constraints and
  729. * limits checks into @mode_valid.
  730. *
  731. * RETURNS:
  732. *
  733. * 0 on success, -EINVAL if the state or the transition can't be
  734. * supported, -ENOMEM on memory allocation failure and -EDEADLK if an
  735. * attempt to obtain another state object ran into a &drm_modeset_lock
  736. * deadlock.
  737. */
  738. int (*atomic_check)(struct drm_encoder *encoder,
  739. struct drm_crtc_state *crtc_state,
  740. struct drm_connector_state *conn_state);
  741. };
  742. /**
  743. * drm_encoder_helper_add - sets the helper vtable for an encoder
  744. * @encoder: DRM encoder
  745. * @funcs: helper vtable to set for @encoder
  746. */
  747. static inline void drm_encoder_helper_add(struct drm_encoder *encoder,
  748. const struct drm_encoder_helper_funcs *funcs)
  749. {
  750. encoder->helper_private = funcs;
  751. }
  752. /**
  753. * struct drm_connector_helper_funcs - helper operations for connectors
  754. *
  755. * These functions are used by the atomic and legacy modeset helpers and by the
  756. * probe helpers.
  757. */
  758. struct drm_connector_helper_funcs {
  759. /**
  760. * @get_modes:
  761. *
  762. * This function should fill in all modes currently valid for the sink
  763. * into the &drm_connector.probed_modes list. It should also update the
  764. * EDID property by calling drm_mode_connector_update_edid_property().
  765. *
  766. * The usual way to implement this is to cache the EDID retrieved in the
  767. * probe callback somewhere in the driver-private connector structure.
  768. * In this function drivers then parse the modes in the EDID and add
  769. * them by calling drm_add_edid_modes(). But connectors that driver a
  770. * fixed panel can also manually add specific modes using
  771. * drm_mode_probed_add(). Drivers which manually add modes should also
  772. * make sure that the &drm_connector.display_info,
  773. * &drm_connector.width_mm and &drm_connector.height_mm fields are
  774. * filled in.
  775. *
  776. * Virtual drivers that just want some standard VESA mode with a given
  777. * resolution can call drm_add_modes_noedid(), and mark the preferred
  778. * one using drm_set_preferred_mode().
  779. *
  780. * Finally drivers that support audio probably want to update the ELD
  781. * data, too, using drm_edid_to_eld().
  782. *
  783. * This function is only called after the @detect hook has indicated
  784. * that a sink is connected and when the EDID isn't overridden through
  785. * sysfs or the kernel commandline.
  786. *
  787. * This callback is used by the probe helpers in e.g.
  788. * drm_helper_probe_single_connector_modes().
  789. *
  790. * To avoid races with concurrent connector state updates, the helper
  791. * libraries always call this with the &drm_mode_config.connection_mutex
  792. * held. Because of this it's safe to inspect &drm_connector->state.
  793. *
  794. * RETURNS:
  795. *
  796. * The number of modes added by calling drm_mode_probed_add().
  797. */
  798. int (*get_modes)(struct drm_connector *connector);
  799. /**
  800. * @detect_ctx:
  801. *
  802. * Check to see if anything is attached to the connector. The parameter
  803. * force is set to false whilst polling, true when checking the
  804. * connector due to a user request. force can be used by the driver to
  805. * avoid expensive, destructive operations during automated probing.
  806. *
  807. * This callback is optional, if not implemented the connector will be
  808. * considered as always being attached.
  809. *
  810. * This is the atomic version of &drm_connector_funcs.detect.
  811. *
  812. * To avoid races against concurrent connector state updates, the
  813. * helper libraries always call this with ctx set to a valid context,
  814. * and &drm_mode_config.connection_mutex will always be locked with
  815. * the ctx parameter set to this ctx. This allows taking additional
  816. * locks as required.
  817. *
  818. * RETURNS:
  819. *
  820. * &drm_connector_status indicating the connector's status,
  821. * or the error code returned by drm_modeset_lock(), -EDEADLK.
  822. */
  823. int (*detect_ctx)(struct drm_connector *connector,
  824. struct drm_modeset_acquire_ctx *ctx,
  825. bool force);
  826. /**
  827. * @mode_valid:
  828. *
  829. * Callback to validate a mode for a connector, irrespective of the
  830. * specific display configuration.
  831. *
  832. * This callback is used by the probe helpers to filter the mode list
  833. * (which is usually derived from the EDID data block from the sink).
  834. * See e.g. drm_helper_probe_single_connector_modes().
  835. *
  836. * This function is optional.
  837. *
  838. * NOTE:
  839. *
  840. * This only filters the mode list supplied to userspace in the
  841. * GETCONNECTOR IOCTL. Compared to &drm_encoder_helper_funcs.mode_valid,
  842. * &drm_crtc_helper_funcs.mode_valid and &drm_bridge_funcs.mode_valid,
  843. * which are also called by the atomic helpers from
  844. * drm_atomic_helper_check_modeset(). This allows userspace to force and
  845. * ignore sink constraint (like the pixel clock limits in the screen's
  846. * EDID), which is useful for e.g. testing, or working around a broken
  847. * EDID. Any source hardware constraint (which always need to be
  848. * enforced) therefore should be checked in one of the above callbacks,
  849. * and not this one here.
  850. *
  851. * To avoid races with concurrent connector state updates, the helper
  852. * libraries always call this with the &drm_mode_config.connection_mutex
  853. * held. Because of this it's safe to inspect &drm_connector->state.
  854. *
  855. * RETURNS:
  856. *
  857. * Either &drm_mode_status.MODE_OK or one of the failure reasons in &enum
  858. * drm_mode_status.
  859. */
  860. enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
  861. struct drm_display_mode *mode);
  862. /**
  863. * @best_encoder:
  864. *
  865. * This function should select the best encoder for the given connector.
  866. *
  867. * This function is used by both the atomic helpers (in the
  868. * drm_atomic_helper_check_modeset() function) and in the legacy CRTC
  869. * helpers.
  870. *
  871. * NOTE:
  872. *
  873. * In atomic drivers this function is called in the check phase of an
  874. * atomic update. The driver is not allowed to change or inspect
  875. * anything outside of arguments passed-in. Atomic drivers which need to
  876. * inspect dynamic configuration state should instead use
  877. * @atomic_best_encoder.
  878. *
  879. * You can leave this function to NULL if the connector is only
  880. * attached to a single encoder and you are using the atomic helpers.
  881. * In this case, the core will call drm_atomic_helper_best_encoder()
  882. * for you.
  883. *
  884. * RETURNS:
  885. *
  886. * Encoder that should be used for the given connector and connector
  887. * state, or NULL if no suitable encoder exists. Note that the helpers
  888. * will ensure that encoders aren't used twice, drivers should not check
  889. * for this.
  890. */
  891. struct drm_encoder *(*best_encoder)(struct drm_connector *connector);
  892. /**
  893. * @atomic_best_encoder:
  894. *
  895. * This is the atomic version of @best_encoder for atomic drivers which
  896. * need to select the best encoder depending upon the desired
  897. * configuration and can't select it statically.
  898. *
  899. * This function is used by drm_atomic_helper_check_modeset().
  900. * If it is not implemented, the core will fallback to @best_encoder
  901. * (or drm_atomic_helper_best_encoder() if @best_encoder is NULL).
  902. *
  903. * NOTE:
  904. *
  905. * This function is called in the check phase of an atomic update. The
  906. * driver is not allowed to change anything outside of the free-standing
  907. * state objects passed-in or assembled in the overall &drm_atomic_state
  908. * update tracking structure.
  909. *
  910. * RETURNS:
  911. *
  912. * Encoder that should be used for the given connector and connector
  913. * state, or NULL if no suitable encoder exists. Note that the helpers
  914. * will ensure that encoders aren't used twice, drivers should not check
  915. * for this.
  916. */
  917. struct drm_encoder *(*atomic_best_encoder)(struct drm_connector *connector,
  918. struct drm_connector_state *connector_state);
  919. /**
  920. * @atomic_check:
  921. *
  922. * This hook is used to validate connector state. This function is
  923. * called from &drm_atomic_helper_check_modeset, and is called when
  924. * a connector property is set, or a modeset on the crtc is forced.
  925. *
  926. * Because &drm_atomic_helper_check_modeset may be called multiple times,
  927. * this function should handle being called multiple times as well.
  928. *
  929. * This function is also allowed to inspect any other object's state and
  930. * can add more state objects to the atomic commit if needed. Care must
  931. * be taken though to ensure that state check and compute functions for
  932. * these added states are all called, and derived state in other objects
  933. * all updated. Again the recommendation is to just call check helpers
  934. * until a maximal configuration is reached.
  935. *
  936. * NOTE:
  937. *
  938. * This function is called in the check phase of an atomic update. The
  939. * driver is not allowed to change anything outside of the free-standing
  940. * state objects passed-in or assembled in the overall &drm_atomic_state
  941. * update tracking structure.
  942. *
  943. * RETURNS:
  944. *
  945. * 0 on success, -EINVAL if the state or the transition can't be
  946. * supported, -ENOMEM on memory allocation failure and -EDEADLK if an
  947. * attempt to obtain another state object ran into a &drm_modeset_lock
  948. * deadlock.
  949. */
  950. int (*atomic_check)(struct drm_connector *connector,
  951. struct drm_connector_state *state);
  952. };
  953. /**
  954. * drm_connector_helper_add - sets the helper vtable for a connector
  955. * @connector: DRM connector
  956. * @funcs: helper vtable to set for @connector
  957. */
  958. static inline void drm_connector_helper_add(struct drm_connector *connector,
  959. const struct drm_connector_helper_funcs *funcs)
  960. {
  961. connector->helper_private = funcs;
  962. }
  963. /**
  964. * struct drm_plane_helper_funcs - helper operations for planes
  965. *
  966. * These functions are used by the atomic helpers and by the transitional plane
  967. * helpers.
  968. */
  969. struct drm_plane_helper_funcs {
  970. /**
  971. * @prepare_fb:
  972. *
  973. * This hook is to prepare a framebuffer for scanout by e.g. pinning
  974. * it's backing storage or relocating it into a contiguous block of
  975. * VRAM. Other possible preparatory work includes flushing caches.
  976. *
  977. * This function must not block for outstanding rendering, since it is
  978. * called in the context of the atomic IOCTL even for async commits to
  979. * be able to return any errors to userspace. Instead the recommended
  980. * way is to fill out the fence member of the passed-in
  981. * &drm_plane_state. If the driver doesn't support native fences then
  982. * equivalent functionality should be implemented through private
  983. * members in the plane structure.
  984. *
  985. * The helpers will call @cleanup_fb with matching arguments for every
  986. * successful call to this hook.
  987. *
  988. * This callback is used by the atomic modeset helpers and by the
  989. * transitional plane helpers, but it is optional.
  990. *
  991. * RETURNS:
  992. *
  993. * 0 on success or one of the following negative error codes allowed by
  994. * the &drm_mode_config_funcs.atomic_commit vfunc. When using helpers
  995. * this callback is the only one which can fail an atomic commit,
  996. * everything else must complete successfully.
  997. */
  998. int (*prepare_fb)(struct drm_plane *plane,
  999. struct drm_plane_state *new_state);
  1000. /**
  1001. * @cleanup_fb:
  1002. *
  1003. * This hook is called to clean up any resources allocated for the given
  1004. * framebuffer and plane configuration in @prepare_fb.
  1005. *
  1006. * This callback is used by the atomic modeset helpers and by the
  1007. * transitional plane helpers, but it is optional.
  1008. */
  1009. void (*cleanup_fb)(struct drm_plane *plane,
  1010. struct drm_plane_state *old_state);
  1011. /**
  1012. * @atomic_check:
  1013. *
  1014. * Drivers should check plane specific constraints in this hook.
  1015. *
  1016. * When using drm_atomic_helper_check_planes() plane's @atomic_check
  1017. * hooks are called before the ones for CRTCs, which allows drivers to
  1018. * request shared resources that the CRTC controls here. For more
  1019. * complicated dependencies the driver can call the provided check helpers
  1020. * multiple times until the computed state has a final configuration and
  1021. * everything has been checked.
  1022. *
  1023. * This function is also allowed to inspect any other object's state and
  1024. * can add more state objects to the atomic commit if needed. Care must
  1025. * be taken though to ensure that state check and compute functions for
  1026. * these added states are all called, and derived state in other objects
  1027. * all updated. Again the recommendation is to just call check helpers
  1028. * until a maximal configuration is reached.
  1029. *
  1030. * This callback is used by the atomic modeset helpers and by the
  1031. * transitional plane helpers, but it is optional.
  1032. *
  1033. * NOTE:
  1034. *
  1035. * This function is called in the check phase of an atomic update. The
  1036. * driver is not allowed to change anything outside of the free-standing
  1037. * state objects passed-in or assembled in the overall &drm_atomic_state
  1038. * update tracking structure.
  1039. *
  1040. * RETURNS:
  1041. *
  1042. * 0 on success, -EINVAL if the state or the transition can't be
  1043. * supported, -ENOMEM on memory allocation failure and -EDEADLK if an
  1044. * attempt to obtain another state object ran into a &drm_modeset_lock
  1045. * deadlock.
  1046. */
  1047. int (*atomic_check)(struct drm_plane *plane,
  1048. struct drm_plane_state *state);
  1049. /**
  1050. * @atomic_update:
  1051. *
  1052. * Drivers should use this function to update the plane state. This
  1053. * hook is called in-between the &drm_crtc_helper_funcs.atomic_begin and
  1054. * drm_crtc_helper_funcs.atomic_flush callbacks.
  1055. *
  1056. * Note that the power state of the display pipe when this function is
  1057. * called depends upon the exact helpers and calling sequence the driver
  1058. * has picked. See drm_atomic_helper_commit_planes() for a discussion of
  1059. * the tradeoffs and variants of plane commit helpers.
  1060. *
  1061. * This callback is used by the atomic modeset helpers and by the
  1062. * transitional plane helpers, but it is optional.
  1063. */
  1064. void (*atomic_update)(struct drm_plane *plane,
  1065. struct drm_plane_state *old_state);
  1066. /**
  1067. * @atomic_disable:
  1068. *
  1069. * Drivers should use this function to unconditionally disable a plane.
  1070. * This hook is called in-between the
  1071. * &drm_crtc_helper_funcs.atomic_begin and
  1072. * drm_crtc_helper_funcs.atomic_flush callbacks. It is an alternative to
  1073. * @atomic_update, which will be called for disabling planes, too, if
  1074. * the @atomic_disable hook isn't implemented.
  1075. *
  1076. * This hook is also useful to disable planes in preparation of a modeset,
  1077. * by calling drm_atomic_helper_disable_planes_on_crtc() from the
  1078. * &drm_crtc_helper_funcs.disable hook.
  1079. *
  1080. * Note that the power state of the display pipe when this function is
  1081. * called depends upon the exact helpers and calling sequence the driver
  1082. * has picked. See drm_atomic_helper_commit_planes() for a discussion of
  1083. * the tradeoffs and variants of plane commit helpers.
  1084. *
  1085. * This callback is used by the atomic modeset helpers and by the
  1086. * transitional plane helpers, but it is optional.
  1087. */
  1088. void (*atomic_disable)(struct drm_plane *plane,
  1089. struct drm_plane_state *old_state);
  1090. };
  1091. /**
  1092. * drm_plane_helper_add - sets the helper vtable for a plane
  1093. * @plane: DRM plane
  1094. * @funcs: helper vtable to set for @plane
  1095. */
  1096. static inline void drm_plane_helper_add(struct drm_plane *plane,
  1097. const struct drm_plane_helper_funcs *funcs)
  1098. {
  1099. plane->helper_private = funcs;
  1100. }
  1101. /**
  1102. * struct drm_mode_config_helper_funcs - global modeset helper operations
  1103. *
  1104. * These helper functions are used by the atomic helpers.
  1105. */
  1106. struct drm_mode_config_helper_funcs {
  1107. /**
  1108. * @atomic_commit_tail:
  1109. *
  1110. * This hook is used by the default atomic_commit() hook implemented in
  1111. * drm_atomic_helper_commit() together with the nonblocking commit
  1112. * helpers (see drm_atomic_helper_setup_commit() for a starting point)
  1113. * to implement blocking and nonblocking commits easily. It is not used
  1114. * by the atomic helpers
  1115. *
  1116. * This function is called when the new atomic state has already been
  1117. * swapped into the various state pointers. The passed in state
  1118. * therefore contains copies of the old/previous state. This hook should
  1119. * commit the new state into hardware. Note that the helpers have
  1120. * already waited for preceeding atomic commits and fences, but drivers
  1121. * can add more waiting calls at the start of their implementation, e.g.
  1122. * to wait for driver-internal request for implicit syncing, before
  1123. * starting to commit the update to the hardware.
  1124. *
  1125. * After the atomic update is committed to the hardware this hook needs
  1126. * to call drm_atomic_helper_commit_hw_done(). Then wait for the upate
  1127. * to be executed by the hardware, for example using
  1128. * drm_atomic_helper_wait_for_vblanks(), and then clean up the old
  1129. * framebuffers using drm_atomic_helper_cleanup_planes().
  1130. *
  1131. * When disabling a CRTC this hook _must_ stall for the commit to
  1132. * complete. Vblank waits don't work on disabled CRTC, hence the core
  1133. * can't take care of this. And it also can't rely on the vblank event,
  1134. * since that can be signalled already when the screen shows black,
  1135. * which can happen much earlier than the last hardware access needed to
  1136. * shut off the display pipeline completely.
  1137. *
  1138. * This hook is optional, the default implementation is
  1139. * drm_atomic_helper_commit_tail().
  1140. */
  1141. void (*atomic_commit_tail)(struct drm_atomic_state *state);
  1142. };
  1143. #endif