drm_plane_helper.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. /*
  2. * Copyright (C) 2014 Intel Corporation
  3. *
  4. * DRM universal plane helper functions
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the "Software"),
  8. * to deal in the Software without restriction, including without limitation
  9. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice (including the next
  14. * paragraph) shall be included in all copies or substantial portions of the
  15. * Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  20. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  23. * SOFTWARE.
  24. */
  25. #include <linux/list.h>
  26. #include <drm/drmP.h>
  27. #include <drm/drm_plane_helper.h>
  28. #include <drm/drm_rect.h>
  29. #include <drm/drm_atomic.h>
  30. #include <drm/drm_crtc_helper.h>
  31. #include <drm/drm_atomic_helper.h>
  32. #define SUBPIXEL_MASK 0xffff
  33. /**
  34. * DOC: overview
  35. *
  36. * This helper library has two parts. The first part has support to implement
  37. * primary plane support on top of the normal CRTC configuration interface.
  38. * Since the legacy ->set_config interface ties the primary plane together with
  39. * the CRTC state this does not allow userspace to disable the primary plane
  40. * itself. To avoid too much duplicated code use
  41. * drm_plane_helper_check_update() which can be used to enforce the same
  42. * restrictions as primary planes had thus. The default primary plane only
  43. * expose XRBG8888 and ARGB8888 as valid pixel formats for the attached
  44. * framebuffer.
  45. *
  46. * Drivers are highly recommended to implement proper support for primary
  47. * planes, and newly merged drivers must not rely upon these transitional
  48. * helpers.
  49. *
  50. * The second part also implements transitional helpers which allow drivers to
  51. * gradually switch to the atomic helper infrastructure for plane updates. Once
  52. * that switch is complete drivers shouldn't use these any longer, instead using
  53. * the proper legacy implementations for update and disable plane hooks provided
  54. * by the atomic helpers.
  55. *
  56. * Again drivers are strongly urged to switch to the new interfaces.
  57. *
  58. * The plane helpers share the function table structures with other helpers,
  59. * specifically also the atomic helpers. See struct &drm_plane_helper_funcs for
  60. * the details.
  61. */
  62. /*
  63. * Returns the connectors currently associated with a CRTC. This function
  64. * should be called twice: once with a NULL connector list to retrieve
  65. * the list size, and once with the properly allocated list to be filled in.
  66. */
  67. static int get_connectors_for_crtc(struct drm_crtc *crtc,
  68. struct drm_connector **connector_list,
  69. int num_connectors)
  70. {
  71. struct drm_device *dev = crtc->dev;
  72. struct drm_connector *connector;
  73. int count = 0;
  74. /*
  75. * Note: Once we change the plane hooks to more fine-grained locking we
  76. * need to grab the connection_mutex here to be able to make these
  77. * checks.
  78. */
  79. WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex));
  80. drm_for_each_connector(connector, dev) {
  81. if (connector->encoder && connector->encoder->crtc == crtc) {
  82. if (connector_list != NULL && count < num_connectors)
  83. *(connector_list++) = connector;
  84. count++;
  85. }
  86. }
  87. return count;
  88. }
  89. /**
  90. * drm_plane_helper_check_state() - Check plane state for validity
  91. * @state: plane state to check
  92. * @clip: integer clipping coordinates
  93. * @min_scale: minimum @src:@dest scaling factor in 16.16 fixed point
  94. * @max_scale: maximum @src:@dest scaling factor in 16.16 fixed point
  95. * @can_position: is it legal to position the plane such that it
  96. * doesn't cover the entire crtc? This will generally
  97. * only be false for primary planes.
  98. * @can_update_disabled: can the plane be updated while the crtc
  99. * is disabled?
  100. *
  101. * Checks that a desired plane update is valid, and updates various
  102. * bits of derived state (clipped coordinates etc.). Drivers that provide
  103. * their own plane handling rather than helper-provided implementations may
  104. * still wish to call this function to avoid duplication of error checking
  105. * code.
  106. *
  107. * RETURNS:
  108. * Zero if update appears valid, error code on failure
  109. */
  110. int drm_plane_helper_check_state(struct drm_plane_state *state,
  111. const struct drm_rect *clip,
  112. int min_scale,
  113. int max_scale,
  114. bool can_position,
  115. bool can_update_disabled)
  116. {
  117. struct drm_crtc *crtc = state->crtc;
  118. struct drm_framebuffer *fb = state->fb;
  119. struct drm_rect *src = &state->src;
  120. struct drm_rect *dst = &state->dst;
  121. unsigned int rotation = state->rotation;
  122. int hscale, vscale;
  123. *src = drm_plane_state_src(state);
  124. *dst = drm_plane_state_dest(state);
  125. if (!fb) {
  126. state->visible = false;
  127. return 0;
  128. }
  129. /* crtc should only be NULL when disabling (i.e., !fb) */
  130. if (WARN_ON(!crtc)) {
  131. state->visible = false;
  132. return 0;
  133. }
  134. if (!crtc->enabled && !can_update_disabled) {
  135. DRM_DEBUG_KMS("Cannot update plane of a disabled CRTC.\n");
  136. return -EINVAL;
  137. }
  138. drm_rect_rotate(src, fb->width << 16, fb->height << 16, rotation);
  139. /* Check scaling */
  140. hscale = drm_rect_calc_hscale(src, dst, min_scale, max_scale);
  141. vscale = drm_rect_calc_vscale(src, dst, min_scale, max_scale);
  142. if (hscale < 0 || vscale < 0) {
  143. DRM_DEBUG_KMS("Invalid scaling of plane\n");
  144. drm_rect_debug_print("src: ", &state->src, true);
  145. drm_rect_debug_print("dst: ", &state->dst, false);
  146. return -ERANGE;
  147. }
  148. state->visible = drm_rect_clip_scaled(src, dst, clip, hscale, vscale);
  149. drm_rect_rotate_inv(src, fb->width << 16, fb->height << 16, rotation);
  150. if (!state->visible)
  151. /*
  152. * Plane isn't visible; some drivers can handle this
  153. * so we just return success here. Drivers that can't
  154. * (including those that use the primary plane helper's
  155. * update function) will return an error from their
  156. * update_plane handler.
  157. */
  158. return 0;
  159. if (!can_position && !drm_rect_equals(dst, clip)) {
  160. DRM_DEBUG_KMS("Plane must cover entire CRTC\n");
  161. drm_rect_debug_print("dst: ", dst, false);
  162. drm_rect_debug_print("clip: ", clip, false);
  163. return -EINVAL;
  164. }
  165. return 0;
  166. }
  167. EXPORT_SYMBOL(drm_plane_helper_check_state);
  168. /**
  169. * drm_plane_helper_check_update() - Check plane update for validity
  170. * @plane: plane object to update
  171. * @crtc: owning CRTC of owning plane
  172. * @fb: framebuffer to flip onto plane
  173. * @src: source coordinates in 16.16 fixed point
  174. * @dst: integer destination coordinates
  175. * @clip: integer clipping coordinates
  176. * @rotation: plane rotation
  177. * @min_scale: minimum @src:@dest scaling factor in 16.16 fixed point
  178. * @max_scale: maximum @src:@dest scaling factor in 16.16 fixed point
  179. * @can_position: is it legal to position the plane such that it
  180. * doesn't cover the entire crtc? This will generally
  181. * only be false for primary planes.
  182. * @can_update_disabled: can the plane be updated while the crtc
  183. * is disabled?
  184. * @visible: output parameter indicating whether plane is still visible after
  185. * clipping
  186. *
  187. * Checks that a desired plane update is valid. Drivers that provide
  188. * their own plane handling rather than helper-provided implementations may
  189. * still wish to call this function to avoid duplication of error checking
  190. * code.
  191. *
  192. * RETURNS:
  193. * Zero if update appears valid, error code on failure
  194. */
  195. int drm_plane_helper_check_update(struct drm_plane *plane,
  196. struct drm_crtc *crtc,
  197. struct drm_framebuffer *fb,
  198. struct drm_rect *src,
  199. struct drm_rect *dst,
  200. const struct drm_rect *clip,
  201. unsigned int rotation,
  202. int min_scale,
  203. int max_scale,
  204. bool can_position,
  205. bool can_update_disabled,
  206. bool *visible)
  207. {
  208. struct drm_plane_state state = {
  209. .plane = plane,
  210. .crtc = crtc,
  211. .fb = fb,
  212. .src_x = src->x1,
  213. .src_y = src->y1,
  214. .src_w = drm_rect_width(src),
  215. .src_h = drm_rect_height(src),
  216. .crtc_x = dst->x1,
  217. .crtc_y = dst->y1,
  218. .crtc_w = drm_rect_width(dst),
  219. .crtc_h = drm_rect_height(dst),
  220. .rotation = rotation,
  221. .visible = *visible,
  222. };
  223. int ret;
  224. ret = drm_plane_helper_check_state(&state, clip,
  225. min_scale, max_scale,
  226. can_position,
  227. can_update_disabled);
  228. if (ret)
  229. return ret;
  230. *src = state.src;
  231. *dst = state.dst;
  232. *visible = state.visible;
  233. return 0;
  234. }
  235. EXPORT_SYMBOL(drm_plane_helper_check_update);
  236. /**
  237. * drm_primary_helper_update() - Helper for primary plane update
  238. * @plane: plane object to update
  239. * @crtc: owning CRTC of owning plane
  240. * @fb: framebuffer to flip onto plane
  241. * @crtc_x: x offset of primary plane on crtc
  242. * @crtc_y: y offset of primary plane on crtc
  243. * @crtc_w: width of primary plane rectangle on crtc
  244. * @crtc_h: height of primary plane rectangle on crtc
  245. * @src_x: x offset of @fb for panning
  246. * @src_y: y offset of @fb for panning
  247. * @src_w: width of source rectangle in @fb
  248. * @src_h: height of source rectangle in @fb
  249. *
  250. * Provides a default plane update handler for primary planes. This is handler
  251. * is called in response to a userspace SetPlane operation on the plane with a
  252. * non-NULL framebuffer. We call the driver's modeset handler to update the
  253. * framebuffer.
  254. *
  255. * SetPlane() on a primary plane of a disabled CRTC is not supported, and will
  256. * return an error.
  257. *
  258. * Note that we make some assumptions about hardware limitations that may not be
  259. * true for all hardware --
  260. *
  261. * 1. Primary plane cannot be repositioned.
  262. * 2. Primary plane cannot be scaled.
  263. * 3. Primary plane must cover the entire CRTC.
  264. * 4. Subpixel positioning is not supported.
  265. *
  266. * Drivers for hardware that don't have these restrictions can provide their
  267. * own implementation rather than using this helper.
  268. *
  269. * RETURNS:
  270. * Zero on success, error code on failure
  271. */
  272. int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc,
  273. struct drm_framebuffer *fb,
  274. int crtc_x, int crtc_y,
  275. unsigned int crtc_w, unsigned int crtc_h,
  276. uint32_t src_x, uint32_t src_y,
  277. uint32_t src_w, uint32_t src_h)
  278. {
  279. struct drm_mode_set set = {
  280. .crtc = crtc,
  281. .fb = fb,
  282. .mode = &crtc->mode,
  283. .x = src_x >> 16,
  284. .y = src_y >> 16,
  285. };
  286. struct drm_rect src = {
  287. .x1 = src_x,
  288. .y1 = src_y,
  289. .x2 = src_x + src_w,
  290. .y2 = src_y + src_h,
  291. };
  292. struct drm_rect dest = {
  293. .x1 = crtc_x,
  294. .y1 = crtc_y,
  295. .x2 = crtc_x + crtc_w,
  296. .y2 = crtc_y + crtc_h,
  297. };
  298. const struct drm_rect clip = {
  299. .x2 = crtc->mode.hdisplay,
  300. .y2 = crtc->mode.vdisplay,
  301. };
  302. struct drm_connector **connector_list;
  303. int num_connectors, ret;
  304. bool visible;
  305. ret = drm_plane_helper_check_update(plane, crtc, fb,
  306. &src, &dest, &clip,
  307. DRM_ROTATE_0,
  308. DRM_PLANE_HELPER_NO_SCALING,
  309. DRM_PLANE_HELPER_NO_SCALING,
  310. false, false, &visible);
  311. if (ret)
  312. return ret;
  313. if (!visible)
  314. /*
  315. * Primary plane isn't visible. Note that unless a driver
  316. * provides their own disable function, this will just
  317. * wind up returning -EINVAL to userspace.
  318. */
  319. return plane->funcs->disable_plane(plane);
  320. /* Find current connectors for CRTC */
  321. num_connectors = get_connectors_for_crtc(crtc, NULL, 0);
  322. BUG_ON(num_connectors == 0);
  323. connector_list = kzalloc(num_connectors * sizeof(*connector_list),
  324. GFP_KERNEL);
  325. if (!connector_list)
  326. return -ENOMEM;
  327. get_connectors_for_crtc(crtc, connector_list, num_connectors);
  328. set.connectors = connector_list;
  329. set.num_connectors = num_connectors;
  330. /*
  331. * We call set_config() directly here rather than using
  332. * drm_mode_set_config_internal. We're reprogramming the same
  333. * connectors that were already in use, so we shouldn't need the extra
  334. * cross-CRTC fb refcounting to accomodate stealing connectors.
  335. * drm_mode_setplane() already handles the basic refcounting for the
  336. * framebuffers involved in this operation.
  337. */
  338. ret = crtc->funcs->set_config(&set);
  339. kfree(connector_list);
  340. return ret;
  341. }
  342. EXPORT_SYMBOL(drm_primary_helper_update);
  343. /**
  344. * drm_primary_helper_disable() - Helper for primary plane disable
  345. * @plane: plane to disable
  346. *
  347. * Provides a default plane disable handler for primary planes. This is handler
  348. * is called in response to a userspace SetPlane operation on the plane with a
  349. * NULL framebuffer parameter. It unconditionally fails the disable call with
  350. * -EINVAL the only way to disable the primary plane without driver support is
  351. * to disable the entier CRTC. Which does not match the plane ->disable hook.
  352. *
  353. * Note that some hardware may be able to disable the primary plane without
  354. * disabling the whole CRTC. Drivers for such hardware should provide their
  355. * own disable handler that disables just the primary plane (and they'll likely
  356. * need to provide their own update handler as well to properly re-enable a
  357. * disabled primary plane).
  358. *
  359. * RETURNS:
  360. * Unconditionally returns -EINVAL.
  361. */
  362. int drm_primary_helper_disable(struct drm_plane *plane)
  363. {
  364. return -EINVAL;
  365. }
  366. EXPORT_SYMBOL(drm_primary_helper_disable);
  367. /**
  368. * drm_primary_helper_destroy() - Helper for primary plane destruction
  369. * @plane: plane to destroy
  370. *
  371. * Provides a default plane destroy handler for primary planes. This handler
  372. * is called during CRTC destruction. We disable the primary plane, remove
  373. * it from the DRM plane list, and deallocate the plane structure.
  374. */
  375. void drm_primary_helper_destroy(struct drm_plane *plane)
  376. {
  377. drm_plane_cleanup(plane);
  378. kfree(plane);
  379. }
  380. EXPORT_SYMBOL(drm_primary_helper_destroy);
  381. const struct drm_plane_funcs drm_primary_helper_funcs = {
  382. .update_plane = drm_primary_helper_update,
  383. .disable_plane = drm_primary_helper_disable,
  384. .destroy = drm_primary_helper_destroy,
  385. };
  386. EXPORT_SYMBOL(drm_primary_helper_funcs);
  387. int drm_plane_helper_commit(struct drm_plane *plane,
  388. struct drm_plane_state *plane_state,
  389. struct drm_framebuffer *old_fb)
  390. {
  391. const struct drm_plane_helper_funcs *plane_funcs;
  392. struct drm_crtc *crtc[2];
  393. const struct drm_crtc_helper_funcs *crtc_funcs[2];
  394. int i, ret = 0;
  395. plane_funcs = plane->helper_private;
  396. /* Since this is a transitional helper we can't assume that plane->state
  397. * is always valid. Hence we need to use plane->crtc instead of
  398. * plane->state->crtc as the old crtc. */
  399. crtc[0] = plane->crtc;
  400. crtc[1] = crtc[0] != plane_state->crtc ? plane_state->crtc : NULL;
  401. for (i = 0; i < 2; i++)
  402. crtc_funcs[i] = crtc[i] ? crtc[i]->helper_private : NULL;
  403. if (plane_funcs->atomic_check) {
  404. ret = plane_funcs->atomic_check(plane, plane_state);
  405. if (ret)
  406. goto out;
  407. }
  408. if (plane_funcs->prepare_fb && plane_state->fb &&
  409. plane_state->fb != old_fb) {
  410. ret = plane_funcs->prepare_fb(plane,
  411. plane_state);
  412. if (ret)
  413. goto out;
  414. }
  415. /* Point of no return, commit sw state. */
  416. swap(plane->state, plane_state);
  417. for (i = 0; i < 2; i++) {
  418. if (crtc_funcs[i] && crtc_funcs[i]->atomic_begin)
  419. crtc_funcs[i]->atomic_begin(crtc[i], crtc[i]->state);
  420. }
  421. /*
  422. * Drivers may optionally implement the ->atomic_disable callback, so
  423. * special-case that here.
  424. */
  425. if (drm_atomic_plane_disabling(plane, plane_state) &&
  426. plane_funcs->atomic_disable)
  427. plane_funcs->atomic_disable(plane, plane_state);
  428. else
  429. plane_funcs->atomic_update(plane, plane_state);
  430. for (i = 0; i < 2; i++) {
  431. if (crtc_funcs[i] && crtc_funcs[i]->atomic_flush)
  432. crtc_funcs[i]->atomic_flush(crtc[i], crtc[i]->state);
  433. }
  434. /*
  435. * If we only moved the plane and didn't change fb's, there's no need to
  436. * wait for vblank.
  437. */
  438. if (plane->state->fb == old_fb)
  439. goto out;
  440. for (i = 0; i < 2; i++) {
  441. if (!crtc[i])
  442. continue;
  443. if (crtc[i]->cursor == plane)
  444. continue;
  445. /* There's no other way to figure out whether the crtc is running. */
  446. ret = drm_crtc_vblank_get(crtc[i]);
  447. if (ret == 0) {
  448. drm_crtc_wait_one_vblank(crtc[i]);
  449. drm_crtc_vblank_put(crtc[i]);
  450. }
  451. ret = 0;
  452. }
  453. if (plane_funcs->cleanup_fb)
  454. plane_funcs->cleanup_fb(plane, plane_state);
  455. out:
  456. if (plane_state) {
  457. if (plane->funcs->atomic_destroy_state)
  458. plane->funcs->atomic_destroy_state(plane, plane_state);
  459. else
  460. drm_atomic_helper_plane_destroy_state(plane, plane_state);
  461. }
  462. return ret;
  463. }
  464. /**
  465. * drm_plane_helper_update() - Transitional helper for plane update
  466. * @plane: plane object to update
  467. * @crtc: owning CRTC of owning plane
  468. * @fb: framebuffer to flip onto plane
  469. * @crtc_x: x offset of primary plane on crtc
  470. * @crtc_y: y offset of primary plane on crtc
  471. * @crtc_w: width of primary plane rectangle on crtc
  472. * @crtc_h: height of primary plane rectangle on crtc
  473. * @src_x: x offset of @fb for panning
  474. * @src_y: y offset of @fb for panning
  475. * @src_w: width of source rectangle in @fb
  476. * @src_h: height of source rectangle in @fb
  477. *
  478. * Provides a default plane update handler using the atomic plane update
  479. * functions. It is fully left to the driver to check plane constraints and
  480. * handle corner-cases like a fully occluded or otherwise invisible plane.
  481. *
  482. * This is useful for piecewise transitioning of a driver to the atomic helpers.
  483. *
  484. * RETURNS:
  485. * Zero on success, error code on failure
  486. */
  487. int drm_plane_helper_update(struct drm_plane *plane, struct drm_crtc *crtc,
  488. struct drm_framebuffer *fb,
  489. int crtc_x, int crtc_y,
  490. unsigned int crtc_w, unsigned int crtc_h,
  491. uint32_t src_x, uint32_t src_y,
  492. uint32_t src_w, uint32_t src_h)
  493. {
  494. struct drm_plane_state *plane_state;
  495. if (plane->funcs->atomic_duplicate_state)
  496. plane_state = plane->funcs->atomic_duplicate_state(plane);
  497. else {
  498. if (!plane->state)
  499. drm_atomic_helper_plane_reset(plane);
  500. plane_state = drm_atomic_helper_plane_duplicate_state(plane);
  501. }
  502. if (!plane_state)
  503. return -ENOMEM;
  504. plane_state->plane = plane;
  505. plane_state->crtc = crtc;
  506. drm_atomic_set_fb_for_plane(plane_state, fb);
  507. plane_state->crtc_x = crtc_x;
  508. plane_state->crtc_y = crtc_y;
  509. plane_state->crtc_h = crtc_h;
  510. plane_state->crtc_w = crtc_w;
  511. plane_state->src_x = src_x;
  512. plane_state->src_y = src_y;
  513. plane_state->src_h = src_h;
  514. plane_state->src_w = src_w;
  515. return drm_plane_helper_commit(plane, plane_state, plane->fb);
  516. }
  517. EXPORT_SYMBOL(drm_plane_helper_update);
  518. /**
  519. * drm_plane_helper_disable() - Transitional helper for plane disable
  520. * @plane: plane to disable
  521. *
  522. * Provides a default plane disable handler using the atomic plane update
  523. * functions. It is fully left to the driver to check plane constraints and
  524. * handle corner-cases like a fully occluded or otherwise invisible plane.
  525. *
  526. * This is useful for piecewise transitioning of a driver to the atomic helpers.
  527. *
  528. * RETURNS:
  529. * Zero on success, error code on failure
  530. */
  531. int drm_plane_helper_disable(struct drm_plane *plane)
  532. {
  533. struct drm_plane_state *plane_state;
  534. /* crtc helpers love to call disable functions for already disabled hw
  535. * functions. So cope with that. */
  536. if (!plane->crtc)
  537. return 0;
  538. if (plane->funcs->atomic_duplicate_state)
  539. plane_state = plane->funcs->atomic_duplicate_state(plane);
  540. else {
  541. if (!plane->state)
  542. drm_atomic_helper_plane_reset(plane);
  543. plane_state = drm_atomic_helper_plane_duplicate_state(plane);
  544. }
  545. if (!plane_state)
  546. return -ENOMEM;
  547. plane_state->plane = plane;
  548. plane_state->crtc = NULL;
  549. drm_atomic_set_fb_for_plane(plane_state, NULL);
  550. return drm_plane_helper_commit(plane, plane_state, plane->fb);
  551. }
  552. EXPORT_SYMBOL(drm_plane_helper_disable);