7676#define FIRMWARE_RAVEN_DMCU "amdgpu/raven_dmcu.bin"
7777MODULE_FIRMWARE (FIRMWARE_RAVEN_DMCU );
7878
79+ /**
80+ * DOC: overview
81+ *
82+ * The AMDgpu display manager, **amdgpu_dm** (or even simpler,
83+ * **dm**) sits between DRM and DC. It acts as a liason, converting DRM
84+ * requests into DC requests, and DC responses into DRM responses.
85+ *
86+ * The root control structure is &struct amdgpu_display_manager.
87+ */
88+
7989/* basic init/fini API */
8090static int amdgpu_dm_init (struct amdgpu_device * adev );
8191static void amdgpu_dm_fini (struct amdgpu_device * adev );
@@ -379,11 +389,6 @@ static void amdgpu_dm_fbc_init(struct drm_connector *connector)
379389
380390}
381391
382- /*
383- * Init display KMS
384- *
385- * Returns 0 on success
386- */
387392static int amdgpu_dm_init (struct amdgpu_device * adev )
388393{
389394 struct dc_init_data init_data ;
@@ -660,6 +665,26 @@ static void s3_handle_mst(struct drm_device *dev, bool suspend)
660665 drm_modeset_unlock (& dev -> mode_config .connection_mutex );
661666}
662667
668+ /**
669+ * dm_hw_init() - Initialize DC device
670+ * @handle: The base driver device containing the amdpgu_dm device.
671+ *
672+ * Initialize the &struct amdgpu_display_manager device. This involves calling
673+ * the initializers of each DM component, then populating the struct with them.
674+ *
675+ * Although the function implies hardware initialization, both hardware and
676+ * software are initialized here. Splitting them out to their relevant init
677+ * hooks is a future TODO item.
678+ *
679+ * Some notable things that are initialized here:
680+ *
681+ * - Display Core, both software and hardware
682+ * - DC modules that we need (freesync and color management)
683+ * - DRM software states
684+ * - Interrupt sources and handlers
685+ * - Vblank support
686+ * - Debug FS entries, if enabled
687+ */
663688static int dm_hw_init (void * handle )
664689{
665690 struct amdgpu_device * adev = (struct amdgpu_device * )handle ;
@@ -670,6 +695,14 @@ static int dm_hw_init(void *handle)
670695 return 0 ;
671696}
672697
698+ /**
699+ * dm_hw_fini() - Teardown DC device
700+ * @handle: The base driver device containing the amdpgu_dm device.
701+ *
702+ * Teardown components within &struct amdgpu_display_manager that require
703+ * cleanup. This involves cleaning up the DRM device, DC, and any modules that
704+ * were loaded. Also flush IRQ workqueues and disable them.
705+ */
673706static int dm_hw_fini (void * handle )
674707{
675708 struct amdgpu_device * adev = (struct amdgpu_device * )handle ;
@@ -895,6 +928,16 @@ static int dm_resume(void *handle)
895928 return ret ;
896929}
897930
931+ /**
932+ * DOC: DM Lifecycle
933+ *
934+ * DM (and consequently DC) is registered in the amdgpu base driver as a IP
935+ * block. When CONFIG_DRM_AMD_DC is enabled, the DM device IP block is added to
936+ * the base driver's device list to be initialized and torn down accordingly.
937+ *
938+ * The functions to do so are provided as hooks in &struct amd_ip_funcs.
939+ */
940+
898941static const struct amd_ip_funcs amdgpu_dm_funcs = {
899942 .name = "dm" ,
900943 .early_init = dm_early_init ,
@@ -962,6 +1005,12 @@ dm_atomic_state_alloc_free(struct drm_atomic_state *state)
9621005 kfree (dm_state );
9631006}
9641007
1008+ /**
1009+ * DOC: atomic
1010+ *
1011+ * *WIP*
1012+ */
1013+
9651014static const struct drm_mode_config_funcs amdgpu_dm_mode_funcs = {
9661015 .fb_create = amdgpu_display_user_framebuffer_create ,
9671016 .output_poll_changed = drm_fb_helper_output_poll_changed ,
@@ -4542,6 +4591,14 @@ static int amdgpu_dm_atomic_commit(struct drm_device *dev,
45424591 /*TODO Handle EINTR, reenable IRQ*/
45434592}
45444593
4594+ /**
4595+ * amdgpu_dm_atomic_commit_tail() - AMDgpu DM's commit tail implementation.
4596+ * @state: The atomic state to commit
4597+ *
4598+ * This will tell DC to commit the constructed DC state from atomic_check,
4599+ * programming the hardware. Any failures here implies a hardware failure, since
4600+ * atomic check should have filtered anything non-kosher.
4601+ */
45454602static void amdgpu_dm_atomic_commit_tail (struct drm_atomic_state * state )
45464603{
45474604 struct drm_device * dev = state -> dev ;
@@ -5394,6 +5451,31 @@ enum surface_update_type dm_determine_update_type_for_commit(struct dc *dc, stru
53945451 return update_type ;
53955452}
53965453
5454+ /**
5455+ * amdgpu_dm_atomic_check() - Atomic check implementation for AMDgpu DM.
5456+ * @dev: The DRM device
5457+ * @state: The atomic state to commit
5458+ *
5459+ * Validate that the given atomic state is programmable by DC into hardware.
5460+ * This involves constructing a &struct dc_state reflecting the new hardware
5461+ * state we wish to commit, then querying DC to see if it is programmable. It's
5462+ * important not to modify the existing DC state. Otherwise, atomic_check
5463+ * may unexpectedly commit hardware changes.
5464+ *
5465+ * When validating the DC state, it's important that the right locks are
5466+ * acquired. For full updates case which removes/adds/updates streams on one
5467+ * CRTC while flipping on another CRTC, acquiring global lock will guarantee
5468+ * that any such full update commit will wait for completion of any outstanding
5469+ * flip using DRMs synchronization events. See
5470+ * dm_determine_update_type_for_commit()
5471+ *
5472+ * Note that DM adds the affected connectors for all CRTCs in state, when that
5473+ * might not seem necessary. This is because DC stream creation requires the
5474+ * DC sink, which is tied to the DRM connector state. Cleaning this up should
5475+ * be possible but non-trivial - a possible TODO item.
5476+ *
5477+ * Return: -Error code if validation failed.
5478+ */
53975479static int amdgpu_dm_atomic_check (struct drm_device * dev ,
53985480 struct drm_atomic_state * state )
53995481{
@@ -5496,15 +5578,6 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
54965578 lock_and_validation_needed = true;
54975579 }
54985580
5499- /*
5500- * For full updates case when
5501- * removing/adding/updating streams on one CRTC while flipping
5502- * on another CRTC,
5503- * acquiring global lock will guarantee that any such full
5504- * update commit
5505- * will wait for completion of any outstanding flip using DRMs
5506- * synchronization events.
5507- */
55085581 update_type = dm_determine_update_type_for_commit (dc , state );
55095582
55105583 if (overall_update_type < update_type )
0 commit comments