From: Ivan Lipski <[email protected]>

[why & how]
DCN60 supports cursor offload to DMU.

Request cursor offload in amdgpu_dm_init and initialize it after DMUB is up
(dc_dmub_srv_cursor_offload_init), which should be picked up by all the
ASICs that support cursor offload in the dcnX_resouce.c.

Signed-off-by: Ivan Lipski <[email protected]>
Signed-off-by: Fangzhi Zuo <[email protected]>
Reviewed-by: Alvin Lee <[email protected]>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +++
 drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c      | 9 ++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 16d1278996f8..b6d7be0c15bc 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -723,6 +723,9 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
 
        dc_hardware_init(adev->dm.dc);
 
+       /* Enable cursor offload if the ASIC supports it. */
+       dc_dmub_srv_cursor_offload_init(adev->dm.dc);
+
        /* GOP/vBIOS may leave an OPTC enabled for a display present at power-on
         * but no longer driven (e.g. an external DP unplugged at boot). Such a
         * dangling pipe keeps DCN out of idle and blocks s0i3. Power it down
diff --git a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c 
b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
index d9af53f720f7..37248ecc3c08 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
+++ b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
@@ -1250,9 +1250,16 @@ void dc_dmub_srv_subvp_save_surf_addr(const struct 
dc_dmub_srv *dc_dmub_srv, con
 void dc_dmub_srv_cursor_offload_init(struct dc *dc)
 {
        struct dmub_rb_cmd_cursor_offload_init *init;
-       struct dc_dmub_srv *dc_dmub_srv = dc->ctx->dmub_srv;
+       struct dc_dmub_srv *dc_dmub_srv;
        union dmub_rb_cmd cmd;
 
+       if (!dc || !dc->ctx)
+               return;
+
+       dc_dmub_srv = dc->ctx->dmub_srv;
+       if (!dc_dmub_srv || !dc_dmub_srv->dmub)
+               return;
+
        if (!dc->config.enable_cursor_offload)
                return;
 
-- 
2.53.0

Reply via email to