drm/amd/display: Expose generic SDP message access interface
authorLeo (Hanghong) Ma <hanghong.ma@amd.com>
Thu, 7 Mar 2019 20:31:11 +0000 (15:31 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 21 Mar 2019 04:39:49 +0000 (23:39 -0500)
[Why]
We need to add DP SDP message test debugfs to make sdp message test
more convenient and efficient.

[How]
Add a DM accessible SDP interface for custom data.

Signed-off-by: Leo (Hanghong) Ma <hanghong.ma@amd.com>
Reviewed-by: Harry Wentland <Harry.Wentland@amd.com>
Reviewed-by: Roman Li <Roman.Li@amd.com>
Acked-by: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc_resource.c
drivers/gpu/drm/amd/display/dc/core/dc_stream.c
drivers/gpu/drm/amd/display/dc/dc_stream.h
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.c
drivers/gpu/drm/amd/display/dc/inc/hw/stream_encoder.h

index 3c9df3703e46dcb5a6f0f5cd18bbb1c7b760cadb..374ce43096ac5436ca61253e52c168d50cd1df40 100644 (file)
@@ -2394,6 +2394,21 @@ static void set_spd_info_packet(
        *info_packet = stream->vrr_infopacket;
 }
 
+static void set_dp_sdp_info_packet(
+               struct dc_info_packet *info_packet,
+               struct dc_stream_state *stream)
+{
+       /* SPD info packet for custom sdp message */
+
+       /* Return if false. If true,
+        * set the corresponding bit in the info packet
+        */
+       if (!stream->dpsdp_infopacket.valid)
+               return;
+
+       *info_packet = stream->dpsdp_infopacket;
+}
+
 static void set_hdr_static_info_packet(
                struct dc_info_packet *info_packet,
                struct dc_stream_state *stream)
@@ -2490,6 +2505,7 @@ void resource_build_info_frame(struct pipe_ctx *pipe_ctx)
        info->spd.valid = false;
        info->hdrsmd.valid = false;
        info->vsc.valid = false;
+       info->dpsdp.valid = false;
 
        signal = pipe_ctx->stream->signal;
 
@@ -2509,6 +2525,8 @@ void resource_build_info_frame(struct pipe_ctx *pipe_ctx)
                set_spd_info_packet(&info->spd, pipe_ctx->stream);
 
                set_hdr_static_info_packet(&info->hdrsmd, pipe_ctx->stream);
+
+               set_dp_sdp_info_packet(&info->dpsdp, pipe_ctx->stream);
        }
 
        patch_gamut_packet_checksum(&info->gamut);
index 59ccab36dab87ac360c2e0a5f5b887cd3e4433bf..4af3545fc414bf858149b92ea285cbe434939fc1 100644 (file)
@@ -345,6 +345,68 @@ uint32_t dc_stream_get_vblank_counter(const struct dc_stream_state *stream)
        return 0;
 }
 
+static void build_dp_sdp_info_frame(struct pipe_ctx *pipe_ctx,
+               const uint8_t  *custom_sdp_message,
+               unsigned int sdp_message_size)
+{
+       uint8_t i;
+       struct encoder_info_frame *info = &pipe_ctx->stream_res.encoder_info_frame;
+
+       /* set valid info */
+       info->dpsdp.valid = true;
+
+       /* set sdp message header */
+       info->dpsdp.hb0 = custom_sdp_message[0]; /* package id */
+       info->dpsdp.hb1 = custom_sdp_message[1]; /* package type */
+       info->dpsdp.hb2 = custom_sdp_message[2]; /* package specific byte 0 any data */
+       info->dpsdp.hb3 = custom_sdp_message[3]; /* package specific byte 0 any data */
+
+       /* set sdp message data */
+       for (i = 0; i < 32; i++)
+               info->dpsdp.sb[i] = (custom_sdp_message[i+4]);
+
+}
+
+static void invalid_dp_sdp_info_frame(struct pipe_ctx *pipe_ctx)
+{
+       struct encoder_info_frame *info = &pipe_ctx->stream_res.encoder_info_frame;
+
+       /* in-valid info */
+       info->dpsdp.valid = false;
+}
+
+bool dc_stream_send_dp_sdp(const struct dc_stream_state *stream,
+               const uint8_t *custom_sdp_message,
+               unsigned int sdp_message_size)
+{
+       int i;
+       struct dc  *core_dc;
+       struct resource_context *res_ctx;
+
+       if (stream == NULL) {
+               dm_error("DC: dc_stream is NULL!\n");
+               return false;
+       }
+
+       core_dc = stream->ctx->dc;
+       res_ctx = &core_dc->current_state->res_ctx;
+
+       for (i = 0; i < MAX_PIPES; i++) {
+               struct pipe_ctx *pipe_ctx = &res_ctx->pipe_ctx[i];
+
+               if (pipe_ctx->stream != stream)
+                       continue;
+
+               build_dp_sdp_info_frame(pipe_ctx, custom_sdp_message, sdp_message_size);
+
+               core_dc->hwss.update_info_frame(pipe_ctx);
+
+               invalid_dp_sdp_info_frame(pipe_ctx);
+       }
+
+       return true;
+}
+
 bool dc_stream_get_scanoutpos(const struct dc_stream_state *stream,
                                  uint32_t *v_blank_start,
                                  uint32_t *v_blank_end,
index 5657cb3a2ad358c6729cacb9529d4cbfb857389b..17fa3bf6cf7b03a1f4d930b33608bf05f83eddd5 100644 (file)
@@ -80,6 +80,7 @@ struct dc_stream_state {
        struct dc_info_packet vrr_infopacket;
        struct dc_info_packet vsc_infopacket;
        struct dc_info_packet vsp_infopacket;
+       struct dc_info_packet dpsdp_infopacket;
 
        struct rect src; /* composition area */
        struct rect dst; /* stream addressable area */
@@ -221,6 +222,13 @@ struct dc_stream_state *dc_get_stream_at_index(struct dc *dc, uint8_t i);
  */
 uint32_t dc_stream_get_vblank_counter(const struct dc_stream_state *stream);
 
+/*
+ * Send dp sdp message.
+ */
+bool dc_stream_send_dp_sdp(const struct dc_stream_state *stream,
+               const uint8_t *custom_sdp_message,
+               unsigned int sdp_message_size);
+
 /* TODO: Return parsed values rather than direct register read
  * This has a dependency on the caller (amdgpu_display_get_crtc_scanoutpos)
  * being refactored properly to be dce-specific
index 0d46aa75361b028b07f92fdc745fbf4d7b8ef063..6a0e748f0e57ffcf76356d2a5cd10a2fa615a662 100644 (file)
@@ -725,13 +725,19 @@ void enc1_stream_encoder_update_dp_info_packets(
                                3,  /* packetIndex */
                                &info_frame->hdrsmd);
 
+       if (info_frame->dpsdp.valid)
+               enc1_update_generic_info_packet(
+                               enc1,
+                               4,/* packetIndex */
+                               &info_frame->dpsdp);
+
        /* enable/disable transmission of packet(s).
         * If enabled, packet transmission begins on the next frame
         */
        REG_UPDATE(DP_SEC_CNTL, DP_SEC_GSP0_ENABLE, info_frame->vsc.valid);
        REG_UPDATE(DP_SEC_CNTL, DP_SEC_GSP2_ENABLE, info_frame->spd.valid);
        REG_UPDATE(DP_SEC_CNTL, DP_SEC_GSP3_ENABLE, info_frame->hdrsmd.valid);
-
+       REG_UPDATE(DP_SEC_CNTL, DP_SEC_GSP4_ENABLE, info_frame->dpsdp.valid);
 
        /* This bit is the master enable bit.
         * When enabling secondary stream engine,
index 8aafed8793df899f5c49fa5a433dd54da87db49a..ce3c4ecd9c24a91203adf1e6c91a833d7d62c6ed 100644 (file)
@@ -63,6 +63,8 @@ struct encoder_info_frame {
        struct dc_info_packet vsc;
        /* HDR Static MetaData */
        struct dc_info_packet hdrsmd;
+       /* custom sdp message */
+       struct dc_info_packet dpsdp;
 };
 
 struct encoder_unblank_param {