drivers/gpu/drm/drm_atomic_state_helper.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_atomic_state_helper.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/drm_atomic_state_helper.c
Extension
.c
Size
27000 bytes
Lines
855
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

#include <drm/drm_atomic.h>
#include <drm/drm_atomic_state_helper.h>
#include <drm/drm_blend.h>
#include <drm/drm_bridge.h>
#include <drm/drm_connector.h>
#include <drm/drm_crtc.h>
#include <drm/drm_device.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_plane.h>
#include <drm/drm_print.h>
#include <drm/drm_vblank.h>
#include <drm/drm_writeback.h>

#include <linux/export.h>
#include <linux/slab.h>
#include <linux/dma-fence.h>

/**
 * DOC: atomic state reset and initialization
 *
 * Both the drm core and the atomic helpers assume that there is always the full
 * and correct atomic software state for all connectors, CRTCs and planes
 * available. Which is a bit a problem on driver load and also after system
 * suspend. One way to solve this is to have a hardware state read-out
 * infrastructure which reconstructs the full software state (e.g. the i915
 * driver).
 *
 * The simpler solution is to just reset the software state to everything off,
 * which is easiest to do by calling drm_mode_config_reset(). To facilitate this
 * the atomic helpers provide default reset implementations for all hooks.
 *
 * On the upside the precise state tracking of atomic simplifies system suspend
 * and resume a lot. For drivers using drm_mode_config_reset() a complete recipe
 * is implemented in drm_atomic_helper_suspend() and drm_atomic_helper_resume().
 * For other drivers the building blocks are split out, see the documentation
 * for these functions.
 */

/**
 * __drm_atomic_helper_crtc_state_reset - reset the CRTC state
 * @crtc_state: atomic CRTC state, must not be NULL
 * @crtc: CRTC object, must not be NULL
 *
 * Initializes the newly allocated @crtc_state with default
 * values. This is useful for drivers that subclass the CRTC state.
 */
void
__drm_atomic_helper_crtc_state_reset(struct drm_crtc_state *crtc_state,
				     struct drm_crtc *crtc)
{
	crtc_state->crtc = crtc;
	crtc_state->background_color = DRM_ARGB64_PREP(0xffff, 0, 0, 0);
}
EXPORT_SYMBOL(__drm_atomic_helper_crtc_state_reset);

/**
 * __drm_atomic_helper_crtc_reset - reset state on CRTC
 * @crtc: drm CRTC
 * @crtc_state: CRTC state to assign
 *
 * Initializes the newly allocated @crtc_state and assigns it to
 * the &drm_crtc->state pointer of @crtc, usually required when
 * initializing the drivers or when called from the &drm_crtc_funcs.reset
 * hook.
 *
 * This is useful for drivers that subclass the CRTC state.
 */
void
__drm_atomic_helper_crtc_reset(struct drm_crtc *crtc,
			       struct drm_crtc_state *crtc_state)
{
	if (crtc_state)
		__drm_atomic_helper_crtc_state_reset(crtc_state, crtc);

	if (drm_dev_has_vblank(crtc->dev))
		drm_crtc_vblank_reset(crtc);

	crtc->state = crtc_state;
}
EXPORT_SYMBOL(__drm_atomic_helper_crtc_reset);

/**
 * drm_atomic_helper_crtc_reset - default &drm_crtc_funcs.reset hook for CRTCs
 * @crtc: drm CRTC
 *
 * Resets the atomic state for @crtc by freeing the state pointer (which might
 * be NULL, e.g. at driver load time) and allocating a new empty state object.
 */
void drm_atomic_helper_crtc_reset(struct drm_crtc *crtc)
{

Annotation

Implementation Notes