drm/amd/display: fix aviInfoFrame bar Info and add set_avMute
authorCharlene Liu <charlene.liu@amd.com>
Mon, 17 Jul 2017 20:04:02 +0000 (16:04 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 26 Sep 2017 22:15:15 +0000 (18:15 -0400)
Signed-off-by: Charlene Liu <charlene.liu@amd.com>
Reviewed-by: Dmytro Laktyushkin <Dmytro.Laktyushkin@amd.com>
Acked-by: Harry Wentland <Harry.Wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc_link.c
drivers/gpu/drm/amd/display/dc/core/dc_resource.c
drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.h
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
drivers/gpu/drm/amd/display/dc/inc/core_types.h
drivers/gpu/drm/amd/display/dc/inc/hw/stream_encoder.h
drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h
drivers/gpu/drm/amd/display/dc/virtual/virtual_stream_encoder.c

index fed38fbab452acdfeacddd900be67a843937ded6..036d22f878b857a27463c2b6bb0d720a2013205c 100644 (file)
@@ -1911,3 +1911,13 @@ void core_link_disable_stream(struct pipe_ctx *pipe_ctx)
        disable_link(pipe_ctx->stream->sink->link, pipe_ctx->stream->signal);
 }
 
+void core_link_set_avmute(struct pipe_ctx *pipe_ctx, bool enable)
+{
+       struct core_dc *core_dc = DC_TO_CORE(pipe_ctx->stream->ctx->dc);
+
+       if (pipe_ctx->stream->signal != SIGNAL_TYPE_HDMI_TYPE_A)
+               return;
+
+       core_dc->hwss.set_avmute(pipe_ctx, enable);
+}
+
index 9d0128e957679b5fe14c01dc7adefd7d221eab43..63056e8c6d78dbe3c944c2f1df2b5213bc8ca7e6 100644 (file)
@@ -1607,6 +1607,8 @@ static void set_avi_info_frame(
        uint8_t *check_sum = NULL;
        uint8_t byte_index = 0;
        union hdmi_info_packet *hdmi_info = &info_frame.avi_info_packet.info_packet_hdmi;
+       unsigned int vic = pipe_ctx->stream->public.timing.vic;
+       enum dc_timing_3d_format format;
 
        color_space = pipe_ctx->stream->public.output_color_space;
        if (color_space == COLOR_SPACE_UNKNOWN)
@@ -1661,8 +1663,7 @@ static void set_avi_info_frame(
 
        /* C0, C1 : Colorimetry */
        if (color_space == COLOR_SPACE_YCBCR709 ||
-                       color_space == COLOR_SPACE_YCBCR709_LIMITED ||
-                       color_space == COLOR_SPACE_2020_YCBCR)
+                       color_space == COLOR_SPACE_YCBCR709_LIMITED)
                hdmi_info->bits.C0_C1 = COLORIMETRY_ITU709;
        else if (color_space == COLOR_SPACE_YCBCR601 ||
                        color_space == COLOR_SPACE_YCBCR601_LIMITED)
@@ -1722,9 +1723,29 @@ static void set_avi_info_frame(
                hdmi_info->bits.Q0_Q1   = RGB_QUANTIZATION_DEFAULT_RANGE;
                hdmi_info->bits.YQ0_YQ1 = YYC_QUANTIZATION_LIMITED_RANGE;
        }
-
-       hdmi_info->bits.VIC0_VIC7 =
-                                       stream->public.timing.vic;
+       ///VIC
+       format = stream->public.timing.timing_3d_format;
+       /*todo, add 3DStereo support*/
+       if (format != TIMING_3D_FORMAT_NONE) {
+               // Based on HDMI specs hdmi vic needs to be converted to cea vic when 3D is enabled
+               switch (pipe_ctx->stream->public.timing.hdmi_vic) {
+               case 1:
+                       vic = 95;
+                       break;
+               case 2:
+                       vic = 94;
+                       break;
+               case 3:
+                       vic = 93;
+                       break;
+               case 4:
+                       vic = 98;
+                       break;
+               default:
+                       break;
+               }
+       }
+       hdmi_info->bits.VIC0_VIC7 = vic;
 
        /* pixel repetition
         * PR0 - PR3 start from 0 whereas pHwPathMode->mode.timing.flags.pixel
@@ -1737,7 +1758,7 @@ static void set_avi_info_frame(
         * barLeft:   Pixel Number of End of Left Bar.
         * barRight:  Pixel Number of Start of Right Bar. */
        hdmi_info->bits.bar_top = stream->public.timing.v_border_top;
-       hdmi_info->bits.bar_bottom = (stream->public.timing.v_border_top
+       hdmi_info->bits.bar_bottom = (stream->public.timing.v_total
                        - stream->public.timing.v_border_bottom + 1);
        hdmi_info->bits.bar_left  = stream->public.timing.h_border_left;
        hdmi_info->bits.bar_right = (stream->public.timing.h_total
@@ -1776,6 +1797,10 @@ static void set_vendor_info_packet(
        uint8_t checksum = 0;
        uint32_t i = 0;
        enum dc_timing_3d_format format;
+       // Can be different depending on packet content /*todo*/
+       // unsigned int length = pPathMode->dolbyVision ? 24 : 5;
+
+       info_packet->valid = false;
 
        format = stream->public.timing.timing_3d_format;
        if (stream->public.view_format == VIEW_3D_FORMAT_NONE)
index daab81bd1773b49d8dea7428a25f771574a85688..532c6e638943ec88149adc1cd3e467a00ebcf4fe 100644 (file)
@@ -1003,6 +1003,16 @@ static void dce110_stream_encoder_dp_unblank(
        REG_UPDATE(DP_VID_STREAM_CNTL, DP_VID_STREAM_ENABLE, true);
 }
 
+static void dce110_stream_encoder_set_avmute(
+       struct stream_encoder *enc,
+       bool enable)
+{
+       struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
+       unsigned int value = enable ? 1 : 0;
+
+       REG_UPDATE(HDMI_GC, HDMI_GC_AVMUTE, value);
+}
+
 
 #define DP_SEC_AUD_N__DP_SEC_AUD_N__DEFAULT 0x8000
 #define DP_SEC_TIMESTAMP__DP_SEC_TIMESTAMP_MODE__AUTO_CALC 1
@@ -1582,7 +1592,6 @@ static const struct stream_encoder_funcs dce110_str_enc_funcs = {
                dce110_stream_encoder_dp_blank,
        .dp_unblank =
                dce110_stream_encoder_dp_unblank,
-
        .audio_mute_control = dce110_se_audio_mute_control,
 
        .dp_audio_setup = dce110_se_dp_audio_setup,
@@ -1592,6 +1601,8 @@ static const struct stream_encoder_funcs dce110_str_enc_funcs = {
        .hdmi_audio_setup = dce110_se_hdmi_audio_setup,
        .hdmi_audio_disable = dce110_se_hdmi_audio_disable,
        .setup_stereo_sync  = setup_stereo_sync,
+       .set_avmute = dce110_stream_encoder_set_avmute,
+
 };
 
 bool dce110_stream_encoder_construct(
index 5d64611eb6a63779b409a74d76aa4e9a2bef44a0..b691ef956d45826055e51a502ff89c6242b805f6 100644 (file)
@@ -801,6 +801,13 @@ void dce110_unblank_stream(struct pipe_ctx *pipe_ctx,
        pipe_ctx->stream_enc->funcs->dp_unblank(pipe_ctx->stream_enc, &params);
 }
 
+
+void dce110_set_avmute(struct pipe_ctx *pipe_ctx, bool enable)
+{
+       if (pipe_ctx != NULL && pipe_ctx->stream_enc != NULL)
+               pipe_ctx->stream_enc->funcs->set_avmute(pipe_ctx->stream_enc, enable);
+}
+
 static enum audio_dto_source translate_to_dto_source(enum controller_id crtc_id)
 {
        switch (crtc_id) {
@@ -1095,10 +1102,11 @@ static enum dc_status apply_single_controller_ctx_to_hw(
                        (pipe_ctx->stream->signal == SIGNAL_TYPE_DVI_DUAL_LINK) ?
                        true : false);
 
+       resource_build_info_frame(pipe_ctx);
+
        if (!pipe_ctx_old->stream) {
                core_link_enable_stream(pipe_ctx);
 
-       resource_build_info_frame(pipe_ctx);
        dce110_update_info_frame(pipe_ctx);
                if (dc_is_dp_signal(pipe_ctx->stream->signal))
                        dce110_unblank_stream(pipe_ctx,
@@ -2600,7 +2608,8 @@ static const struct hw_sequencer_funcs dce110_funcs = {
        .set_static_screen_control = set_static_screen_control,
        .reset_hw_ctx_wrap = reset_hw_ctx_wrap,
        .prog_pixclk_crtc_otg = dce110_prog_pixclk_crtc_otg,
-       .setup_stereo = NULL
+       .setup_stereo = NULL,
+       .set_avmute = dce110_set_avmute,
 };
 
 bool dce110_hw_sequencer_construct(struct core_dc *dc)
index 52462c17b2e985b4bf174d0ce69291be60121dc7..89782ca1917f541180653d68e28878fb60433c0b 100644 (file)
@@ -54,6 +54,7 @@ void dce110_unblank_stream(struct pipe_ctx *pipe_ctx,
 
 void dce110_update_info_frame(struct pipe_ctx *pipe_ctx);
 
+void dce110_set_avmute(struct pipe_ctx *pipe_ctx, bool enable);
 void dce110_enable_accelerated_mode(struct core_dc *dc);
 
 void dce110_power_down(struct core_dc *dc);
index cadc940e7c0e72f5b171c5829c6db303d7411f70..8284837898d24f581a8678dc4ceec86c41dc6c54 100644 (file)
@@ -1867,7 +1867,8 @@ static const struct hw_sequencer_funcs dcn10_funcs = {
        .set_drr = set_drr,
        .get_position = get_position,
        .set_static_screen_control = set_static_screen_control,
-       .setup_stereo = dcn10_setup_stereo
+       .setup_stereo = dcn10_setup_stereo,
+       .set_avmute = dce110_set_avmute,
 };
 
 
index d216522a9989ba6a51fbe2b8deeef7d932dd82d9..d753680309178f444eb0c2d1b9af4fc95c62d858 100644 (file)
@@ -179,6 +179,7 @@ void core_link_enable_stream(struct pipe_ctx *pipe_ctx);
 
 void core_link_disable_stream(struct pipe_ctx *pipe_ctx);
 
+void core_link_set_avmute(struct pipe_ctx *pipe_ctx, bool enable);
 /********** DAL Core*********************/
 #include "display_clock.h"
 #include "transform.h"
index 9fb27bd360ac3e6354206783a15199e19ff207ea..6ff90a0fef24bbb6afef595a048144a03b4ab061 100644 (file)
@@ -123,6 +123,9 @@ struct stream_encoder_funcs {
                        struct stream_encoder *enc,
                        int tg_inst,
                        bool enable);
+
+       void (*set_avmute)(
+               struct stream_encoder *enc, bool enable);
 };
 
 #endif /* STREAM_ENCODER_H_ */
index 97dbd259f66cd4f61cc4b8c07c8b489db0e7b9e6..d94e8e446ce5137861bcc076a7c53c07f62fbfcd 100644 (file)
@@ -152,6 +152,8 @@ struct hw_sequencer_funcs {
        void (*setup_stereo)(
                        struct pipe_ctx *pipe_ctx,
                        struct core_dc *dc);
+
+       void (*set_avmute)(struct pipe_ctx *pipe_ctx, bool enable);
 };
 
 void color_space_to_black_color(
index 8de21d9a8079ec34a238128d7195212cea7ac173..7fe6085e6e37019d1f7dfeba676bc4663c4876f1 100644 (file)
@@ -53,6 +53,9 @@ static void virtual_stream_encoder_update_hdmi_info_packets(
 static void virtual_stream_encoder_stop_hdmi_info_packets(
        struct stream_encoder *enc) {}
 
+static void virtual_stream_encoder_set_avmute(
+       struct stream_encoder *enc,
+       bool enable) {}
 static void virtual_stream_encoder_update_dp_info_packets(
        struct stream_encoder *enc,
        const struct encoder_info_frame *info_frame) {}
@@ -94,6 +97,7 @@ static const struct stream_encoder_funcs virtual_str_enc_funcs = {
                virtual_stream_encoder_dp_unblank,
 
        .audio_mute_control = virtual_audio_mute_control,
+       .set_avmute = virtual_stream_encoder_set_avmute,
 };
 
 bool virtual_stream_encoder_construct(