@@ -281,6 +281,10 @@ EXPORT_SYMBOL(__drm_atomic_state_free);
281281 * needed. It will also grab the relevant CRTC lock to make sure that the state
282282 * is consistent.
283283 *
284+ * This function is deprecated,
285+ * @drm_atomic_get_old_or_current_crtc_state or
286+ * @drm_atomic_get_new_or_current_crtc_state should be used instead.
287+ *
284288 * Returns:
285289 *
286290 * Either the allocated state or the error code encoded into the pointer. When
@@ -321,6 +325,106 @@ drm_atomic_get_crtc_state(struct drm_atomic_state *state,
321325}
322326EXPORT_SYMBOL (drm_atomic_get_crtc_state );
323327
328+ /**
329+ * drm_atomic_get_old_or_current_crtc_state - get CRTC state
330+ * @state: global atomic state object
331+ * @crtc: CRTC to get state object for
332+ *
333+ * This function returns the old CRTC state for the given CRTC if it's
334+ * part of the state, or allocating a copy of the current state
335+ * otherwise. It will also grab the relevant CRTC lock to make sure that
336+ * the state is consistent.
337+ *
338+ * Returns:
339+ *
340+ * Either the allocated state or the error code encoded into the pointer. When
341+ * the error is EDEADLK then the w/w mutex code has detected a deadlock and the
342+ * entire atomic sequence must be restarted. All other errors are fatal.
343+ */
344+ struct drm_crtc_state *
345+ drm_atomic_get_old_or_current_crtc_state (struct drm_atomic_state * state ,
346+ struct drm_crtc * crtc )
347+ {
348+ int ret , index = drm_crtc_index (crtc );
349+ struct drm_crtc_state * crtc_state ;
350+
351+ WARN_ON (!state -> acquire_ctx );
352+
353+ crtc_state = drm_atomic_get_old_crtc_state (state , crtc );
354+ if (crtc_state )
355+ return crtc_state ;
356+
357+ ret = drm_modeset_lock (& crtc -> mutex , state -> acquire_ctx );
358+ if (ret )
359+ return ERR_PTR (ret );
360+
361+ crtc_state = crtc -> funcs -> atomic_duplicate_state (crtc );
362+ if (!crtc_state )
363+ return ERR_PTR (- ENOMEM );
364+
365+ state -> crtcs [index ].state = crtc_state ;
366+ state -> crtcs [index ].old_state = crtc -> state ;
367+ state -> crtcs [index ].new_state = crtc_state ;
368+ state -> crtcs [index ].ptr = crtc ;
369+ crtc_state -> state = state ;
370+
371+ DRM_DEBUG_ATOMIC ("Added [CRTC:%d:%s] %p state to %p\n" ,
372+ crtc -> base .id , crtc -> name , crtc_state , state );
373+
374+ return crtc_state ;
375+ }
376+ EXPORT_SYMBOL (drm_atomic_get_old_or_current_crtc_state );
377+
378+ /**
379+ * drm_atomic_get_new_or_current_crtc_state - get CRTC state
380+ * @state: global atomic state object
381+ * @crtc: CRTC to get state object for
382+ *
383+ * This function returns the new CRTC state for the given CRTC if it's
384+ * part of the state, or allocating a copy of the current state
385+ * otherwise. It will also grab the relevant CRTC lock to make sure that
386+ * the state is consistent.
387+ *
388+ * Returns:
389+ *
390+ * Either the allocated state or the error code encoded into the pointer. When
391+ * the error is EDEADLK then the w/w mutex code has detected a deadlock and the
392+ * entire atomic sequence must be restarted. All other errors are fatal.
393+ */
394+ struct drm_crtc_state *
395+ drm_atomic_get_new_or_current_crtc_state (struct drm_atomic_state * state ,
396+ struct drm_crtc * crtc )
397+ {
398+ int ret , index = drm_crtc_index (crtc );
399+ struct drm_crtc_state * crtc_state ;
400+
401+ WARN_ON (!state -> acquire_ctx );
402+
403+ crtc_state = drm_atomic_get_new_crtc_state (state , crtc );
404+ if (crtc_state )
405+ return crtc_state ;
406+
407+ ret = drm_modeset_lock (& crtc -> mutex , state -> acquire_ctx );
408+ if (ret )
409+ return ERR_PTR (ret );
410+
411+ crtc_state = crtc -> funcs -> atomic_duplicate_state (crtc );
412+ if (!crtc_state )
413+ return ERR_PTR (- ENOMEM );
414+
415+ state -> crtcs [index ].state = crtc_state ;
416+ state -> crtcs [index ].old_state = crtc -> state ;
417+ state -> crtcs [index ].new_state = crtc_state ;
418+ state -> crtcs [index ].ptr = crtc ;
419+ crtc_state -> state = state ;
420+
421+ DRM_DEBUG_ATOMIC ("Added [CRTC:%d:%s] %p state to %p\n" ,
422+ crtc -> base .id , crtc -> name , crtc_state , state );
423+
424+ return crtc_state ;
425+ }
426+ EXPORT_SYMBOL (drm_atomic_get_new_or_current_crtc_state );
427+
324428static int drm_atomic_crtc_check (const struct drm_crtc_state * old_crtc_state ,
325429 const struct drm_crtc_state * new_crtc_state )
326430{
0 commit comments