drm/amd/display: Add new infopacket definition
authorBayan Zabihiyan <Bayan.Zabihiyan@amd.com>
Thu, 27 Dec 2018 13:43:45 +0000 (08:43 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 14 Jan 2019 20:42:12 +0000 (15:42 -0500)
Modify freesync module to build VTEM infopackets when in HdmiVRR mode

Signed-off-by: Bayan Zabihiyan <Bayan.Zabihiyan@amd.com>
Reviewed-by: Jun Lei <Jun.Lei@amd.com>
Acked-by: Leo Li <sunpeng.li@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/modules/freesync/freesync.c
drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h
drivers/gpu/drm/amd/display/modules/inc/mod_shared.h

index d967ac0..94a84bc 100644 (file)
@@ -461,6 +461,26 @@ bool mod_freesync_get_v_position(struct mod_freesync *mod_freesync,
        return false;
 }
 
+static void build_vrr_infopacket_header_vtem(enum signal_type signal,
+               struct dc_info_packet *infopacket)
+{
+       // HEADER
+
+       // HB0, HB1, HB2 indicates PacketType VTEMPacket
+       infopacket->hb0 = 0x7F;
+       infopacket->hb1 = 0xC0;
+       infopacket->hb2 = 0x00;
+       /* HB3 Bit Fields
+        * Reserved :1 = 0
+        * Sync     :1 = 0
+        * VFR      :1 = 1
+        * Ds_Type  :2 = 0
+        * End      :1 = 0
+        * New      :1 = 0
+        */
+       infopacket->hb3 = 0x20;
+}
+
 static void build_vrr_infopacket_header_v1(enum signal_type signal,
                struct dc_info_packet *infopacket,
                unsigned int *payload_size)
@@ -559,6 +579,54 @@ static void build_vrr_infopacket_header_v2(enum signal_type signal,
        }
 }
 
+static void build_vrr_vtem_infopacket_data(const struct dc_stream_state *stream,
+               const struct mod_vrr_params *vrr,
+               struct dc_info_packet *infopacket)
+{
+       /* dc_info_packet to VtemPacket Translation of Bit-fields,
+        * SB[6]
+        * unsigned char VRR_EN        :1
+        * unsigned char M_CONST       :1
+        * unsigned char Reserved2     :2
+        * unsigned char FVA_Factor_M1 :4
+        * SB[7]
+        * unsigned char Base_Vfront   :8
+        * SB[8]
+        * unsigned char Base_Refresh_Rate_98 :2
+        * unsigned char RB                   :1
+        * unsigned char Reserved3            :5
+        * SB[9]
+        * unsigned char Base_RefreshRate_07  :8
+        */
+       unsigned int fieldRateInHz;
+
+       if (vrr->state == VRR_STATE_ACTIVE_VARIABLE ||
+                               vrr->state == VRR_STATE_ACTIVE_FIXED){
+               infopacket->sb[6] |= 0x80; //VRR_EN Bit = 1
+       } else {
+               infopacket->sb[6] &= 0x7F; //VRR_EN Bit = 0
+       }
+
+       if (!stream->timing.vic) {
+               infopacket->sb[7] = stream->timing.v_front_porch;
+
+               /* TODO: In dal2, we check mode flags for a reduced blanking timing.
+                * Need a way to relay that information to this function.
+                * if("ReducedBlanking")
+                * {
+                *   infopacket->sb[8] |= 0x20; //Set 3rd bit to 1
+                * }
+                */
+               fieldRateInHz = (stream->timing.pix_clk_100hz * 100)/
+                               (stream->timing.h_total * stream->timing.v_total);
+
+               infopacket->sb[8] |= ((fieldRateInHz & 0x300) >> 2);
+               infopacket->sb[9] |= fieldRateInHz & 0xFF;
+
+       }
+       infopacket->valid = true;
+}
+
 static void build_vrr_infopacket_data(const struct mod_vrr_params *vrr,
                struct dc_info_packet *infopacket)
 {
@@ -672,6 +740,19 @@ static void build_vrr_infopacket_v2(enum signal_type signal,
        infopacket->valid = true;
 }
 
+static void build_vrr_infopacket_vtem(const struct dc_stream_state *stream,
+               const struct mod_vrr_params *vrr,
+               struct dc_info_packet *infopacket)
+{
+       //VTEM info packet for HdmiVrr
+
+       //VTEM Packet is structured differently
+       build_vrr_infopacket_header_vtem(stream->signal, infopacket);
+       build_vrr_vtem_infopacket_data(stream, vrr, infopacket);
+
+       infopacket->valid = true;
+}
+
 void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync,
                const struct dc_stream_state *stream,
                const struct mod_vrr_params *vrr,
@@ -679,18 +760,21 @@ void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync,
                const enum color_transfer_func *app_tf,
                struct dc_info_packet *infopacket)
 {
-       /* SPD info packet for FreeSync */
-
-       /* Check if Freesync is supported. Return if false. If true,
+       /* SPD info packet for FreeSync
+        * VTEM info packet for HdmiVRR
+        * Check if Freesync is supported. Return if false. If true,
         * set the corresponding bit in the info packet
         */
-       if (!vrr->supported || !vrr->send_vsif)
+       if (!vrr->supported || (!vrr->send_info_frame && packet_type != PACKET_TYPE_VTEM))
                return;
 
        switch (packet_type) {
        case PACKET_TYPE_FS2:
                build_vrr_infopacket_v2(stream->signal, vrr, app_tf, infopacket);
                break;
+       case PACKET_TYPE_VTEM:
+               build_vrr_infopacket_vtem(stream, vrr, infopacket);
+               break;
        case PACKET_TYPE_VRR:
        case PACKET_TYPE_FS1:
        default:
@@ -739,7 +823,7 @@ void mod_freesync_build_vrr_params(struct mod_freesync *mod_freesync,
                return;
 
        in_out_vrr->state = in_config->state;
-       in_out_vrr->send_vsif = in_config->vsif_supported;
+       in_out_vrr->send_info_frame = in_config->vsif_supported;
 
        if (in_config->state == VRR_STATE_UNSUPPORTED) {
                in_out_vrr->state = VRR_STATE_UNSUPPORTED;
index 949a8b6..4222e40 100644 (file)
@@ -104,7 +104,7 @@ struct mod_vrr_params_fixed_refresh {
 
 struct mod_vrr_params {
        bool supported;
-       bool send_vsif;
+       bool send_info_frame;
        enum mod_vrr_state state;
 
        uint32_t min_refresh_in_uhz;
index 1bd02c0..b711e7e 100644 (file)
@@ -41,7 +41,8 @@ enum color_transfer_func {
 enum vrr_packet_type {
        PACKET_TYPE_VRR,
        PACKET_TYPE_FS1,
-       PACKET_TYPE_FS2
+       PACKET_TYPE_FS2,
+       PACKET_TYPE_VTEM
 };