drm/amd/display:Use Pixel clock in 100Hz units for HDMI Audio wall clock DTO
authorNevenko Stupar <Nevenko.Stupar@amd.com>
Tue, 11 Jun 2019 21:35:16 +0000 (17:35 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 18 Jul 2019 19:18:09 +0000 (14:18 -0500)
[Why]
-Pass and use pixel clock in 100 Hz to Audio for HDMI
audio DTO for Audio wall clock programming so audio DTO gets
increased precision for timings with /1001 factor.
-For HDMI TMDS for N and CTS ACR tables are based on 10 KHz
units, these does not need to be modified as N and CTS values
are still valid using current tables.

Signed-off-by: Nevenko Stupar <Nevenko.Stupar@amd.com>
Reviewed-by: Charlene Liu <Charlene.Liu@amd.com>
Acked-by: Leo Li <sunpeng.li@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dce/dce_audio.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/dcn10/dcn10_stream_encoder.c
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.h
drivers/gpu/drm/amd/display/include/audio_types.h

index 4a10a5d22c90bef8fd4ae3b14f9460482cef3f92..6147530144eb84e5912c81e7f8e19c3d715be2bb 100644 (file)
@@ -145,20 +145,20 @@ static void check_audio_bandwidth_hdmi(
        if (channel_count > 2) {
 
                /* Based on HDMI spec 1.3 Table 7.5 */
-               if ((crtc_info->requested_pixel_clock <= 27000) &&
+               if ((crtc_info->requested_pixel_clock_100Hz <= 270000) &&
                (crtc_info->v_active <= 576) &&
                !(crtc_info->interlaced) &&
                !(crtc_info->pixel_repetition == 2 ||
                crtc_info->pixel_repetition == 4)) {
                        limit_freq_to_48_khz = true;
 
-               } else if ((crtc_info->requested_pixel_clock <= 27000) &&
+               } else if ((crtc_info->requested_pixel_clock_100Hz <= 270000) &&
                                (crtc_info->v_active <= 576) &&
                                (crtc_info->interlaced) &&
                                (crtc_info->pixel_repetition == 2)) {
                        limit_freq_to_88_2_khz = true;
 
-               } else if ((crtc_info->requested_pixel_clock <= 54000) &&
+               } else if ((crtc_info->requested_pixel_clock_100Hz <= 540000) &&
                                (crtc_info->v_active <= 576) &&
                                !(crtc_info->interlaced)) {
                        limit_freq_to_174_4_khz = true;
@@ -737,8 +737,8 @@ void dce_aud_az_configure(
 
 /* search pixel clock value for Azalia HDMI Audio */
 static void get_azalia_clock_info_hdmi(
-       uint32_t crtc_pixel_clock_in_khz,
-       uint32_t actual_pixel_clock_in_khz,
+       uint32_t crtc_pixel_clock_100hz,
+       uint32_t actual_pixel_clock_100Hz,
        struct azalia_clock_info *azalia_clock_info)
 {
        /* audio_dto_phase= 24 * 10,000;
@@ -749,11 +749,11 @@ static void get_azalia_clock_info_hdmi(
        /* audio_dto_module = PCLKFrequency * 10,000;
         *  [khz] -> [100Hz] */
        azalia_clock_info->audio_dto_module =
-                       actual_pixel_clock_in_khz * 10;
+                       actual_pixel_clock_100Hz;
 }
 
 static void get_azalia_clock_info_dp(
-       uint32_t requested_pixel_clock_in_khz,
+       uint32_t requested_pixel_clock_100Hz,
        const struct audio_pll_info *pll_info,
        struct azalia_clock_info *azalia_clock_info)
 {
@@ -792,15 +792,15 @@ void dce_aud_wall_dto_setup(
 
                /* calculate DTO settings */
                get_azalia_clock_info_hdmi(
-                       crtc_info->requested_pixel_clock,
-                       crtc_info->calculated_pixel_clock,
+                       crtc_info->requested_pixel_clock_100Hz,
+                       crtc_info->calculated_pixel_clock_100Hz,
                        &clock_info);
 
-               DC_LOG_HW_AUDIO("\n%s:Input::requested_pixel_clock = %d"\
-                               "calculated_pixel_clock =%d\n"\
+               DC_LOG_HW_AUDIO("\n%s:Input::requested_pixel_clock_100Hz = %d"\
+                               "calculated_pixel_clock_100Hz =%d\n"\
                                "audio_dto_module = %d audio_dto_phase =%d \n\n", __func__,\
-                               crtc_info->requested_pixel_clock,\
-                               crtc_info->calculated_pixel_clock,\
+                               crtc_info->requested_pixel_clock_100Hz,\
+                               crtc_info->calculated_pixel_clock_100Hz,\
                                clock_info.audio_dto_module,\
                                clock_info.audio_dto_phase);
 
@@ -833,7 +833,7 @@ void dce_aud_wall_dto_setup(
 
                calculate DTO settings */
                get_azalia_clock_info_dp(
-                       crtc_info->requested_pixel_clock,
+                       crtc_info->requested_pixel_clock_100Hz,
                        pll_info,
                        &clock_info);
 
index 5e2b4d47c5482014f4da41f30ef54fb281f7bfce..84bbff665be9831189eb3843cf0b49e2e434ee55 100644 (file)
@@ -1251,13 +1251,13 @@ static uint32_t calc_max_audio_packets_per_line(
 
 static void get_audio_clock_info(
        enum dc_color_depth color_depth,
-       uint32_t crtc_pixel_clock_in_khz,
-       uint32_t actual_pixel_clock_in_khz,
+       uint32_t crtc_pixel_clock_100Hz,
+       uint32_t actual_pixel_clock_100Hz,
        struct audio_clock_info *audio_clock_info)
 {
        const struct audio_clock_info *clock_info;
        uint32_t index;
-       uint32_t crtc_pixel_clock_in_10khz = crtc_pixel_clock_in_khz / 10;
+       uint32_t crtc_pixel_clock_in_10khz = crtc_pixel_clock_100Hz / 100;
        uint32_t audio_array_size;
 
        switch (color_depth) {
@@ -1294,16 +1294,16 @@ static void get_audio_clock_info(
        }
 
        /* not found */
-       if (actual_pixel_clock_in_khz == 0)
-               actual_pixel_clock_in_khz = crtc_pixel_clock_in_khz;
+       if (actual_pixel_clock_100Hz == 0)
+               actual_pixel_clock_100Hz = crtc_pixel_clock_100Hz;
 
        /* See HDMI spec  the table entry under
         *  pixel clock of "Other". */
        audio_clock_info->pixel_clock_in_10khz =
-                       actual_pixel_clock_in_khz / 10;
-       audio_clock_info->cts_32khz = actual_pixel_clock_in_khz;
-       audio_clock_info->cts_44khz = actual_pixel_clock_in_khz;
-       audio_clock_info->cts_48khz = actual_pixel_clock_in_khz;
+                       actual_pixel_clock_100Hz / 100;
+       audio_clock_info->cts_32khz = actual_pixel_clock_100Hz / 10;
+       audio_clock_info->cts_44khz = actual_pixel_clock_100Hz / 10;
+       audio_clock_info->cts_48khz = actual_pixel_clock_100Hz / 10;
 
        audio_clock_info->n_32khz = 4096;
        audio_clock_info->n_44khz = 6272;
@@ -1369,14 +1369,14 @@ static void dce110_se_setup_hdmi_audio(
 
        /* Program audio clock sample/regeneration parameters */
        get_audio_clock_info(crtc_info->color_depth,
-                            crtc_info->requested_pixel_clock,
-                            crtc_info->calculated_pixel_clock,
+                            crtc_info->requested_pixel_clock_100Hz,
+                            crtc_info->calculated_pixel_clock_100Hz,
                             &audio_clock_info);
        DC_LOG_HW_AUDIO(
-                       "\n%s:Input::requested_pixel_clock = %d"        \
-                       "calculated_pixel_clock = %d \n", __func__,     \
-                       crtc_info->requested_pixel_clock,               \
-                       crtc_info->calculated_pixel_clock);
+                       "\n%s:Input::requested_pixel_clock_100Hz = %d"  \
+                       "calculated_pixel_clock_100Hz = %d \n", __func__,       \
+                       crtc_info->requested_pixel_clock_100Hz,         \
+                       crtc_info->calculated_pixel_clock_100Hz);
 
        /* HDMI_ACR_32_0__HDMI_ACR_CTS_32_MASK */
        REG_UPDATE(HDMI_ACR_32_0, HDMI_ACR_CTS_32, audio_clock_info.cts_32khz);
index 858a58856ebd0c2cf98df0508c7f6d8376070503..3a937e297a8970069ff686ce5101b27d80ce587c 100644 (file)
@@ -1162,27 +1162,27 @@ static void build_audio_output(
                        stream->timing.flags.INTERLACE;
 
        audio_output->crtc_info.refresh_rate =
-               (stream->timing.pix_clk_100hz*10000)/
+               (stream->timing.pix_clk_100hz*100)/
                (stream->timing.h_total*stream->timing.v_total);
 
        audio_output->crtc_info.color_depth =
                stream->timing.display_color_depth;
 
-       audio_output->crtc_info.requested_pixel_clock =
-                       pipe_ctx->stream_res.pix_clk_params.requested_pix_clk_100hz / 10;
+       audio_output->crtc_info.requested_pixel_clock_100Hz =
+                       pipe_ctx->stream_res.pix_clk_params.requested_pix_clk_100hz;
 
-       audio_output->crtc_info.calculated_pixel_clock =
-                       pipe_ctx->stream_res.pix_clk_params.requested_pix_clk_100hz / 10;
+       audio_output->crtc_info.calculated_pixel_clock_100Hz =
+                       pipe_ctx->stream_res.pix_clk_params.requested_pix_clk_100hz;
 
 /*for HDMI, audio ACR is with deep color ratio factor*/
        if (dc_is_hdmi_signal(pipe_ctx->stream->signal) &&
-               audio_output->crtc_info.requested_pixel_clock ==
-                               (stream->timing.pix_clk_100hz / 10)) {
+               audio_output->crtc_info.requested_pixel_clock_100Hz ==
+                               (stream->timing.pix_clk_100hz)) {
                if (pipe_ctx->stream_res.pix_clk_params.pixel_encoding == PIXEL_ENCODING_YCBCR420) {
-                       audio_output->crtc_info.requested_pixel_clock =
-                                       audio_output->crtc_info.requested_pixel_clock/2;
-                       audio_output->crtc_info.calculated_pixel_clock =
-                                       pipe_ctx->stream_res.pix_clk_params.requested_pix_clk_100hz/20;
+                       audio_output->crtc_info.requested_pixel_clock_100Hz =
+                                       audio_output->crtc_info.requested_pixel_clock_100Hz/2;
+                       audio_output->crtc_info.calculated_pixel_clock_100Hz =
+                                       pipe_ctx->stream_res.pix_clk_params.requested_pix_clk_100hz/2;
 
                }
        }
index b9ffbf6b58ff23ed4e63bfe50a3f8aae86c21cd1..128e040b784824da2f78bb0e38f12102c06e4a1d 100644 (file)
@@ -1196,13 +1196,13 @@ static union audio_cea_channels speakers_to_channels(
 
 void get_audio_clock_info(
        enum dc_color_depth color_depth,
-       uint32_t crtc_pixel_clock_in_khz,
-       uint32_t actual_pixel_clock_in_khz,
+       uint32_t crtc_pixel_clock_100Hz,
+       uint32_t actual_pixel_clock_100Hz,
        struct audio_clock_info *audio_clock_info)
 {
        const struct audio_clock_info *clock_info;
        uint32_t index;
-       uint32_t crtc_pixel_clock_in_10khz = crtc_pixel_clock_in_khz / 10;
+       uint32_t crtc_pixel_clock_in_10khz = crtc_pixel_clock_100Hz / 100;
        uint32_t audio_array_size;
 
        switch (color_depth) {
@@ -1239,16 +1239,16 @@ void get_audio_clock_info(
        }
 
        /* not found */
-       if (actual_pixel_clock_in_khz == 0)
-               actual_pixel_clock_in_khz = crtc_pixel_clock_in_khz;
+       if (actual_pixel_clock_100Hz == 0)
+               actual_pixel_clock_100Hz = crtc_pixel_clock_100Hz;
 
        /* See HDMI spec  the table entry under
         *  pixel clock of "Other". */
        audio_clock_info->pixel_clock_in_10khz =
-                       actual_pixel_clock_in_khz / 10;
-       audio_clock_info->cts_32khz = actual_pixel_clock_in_khz;
-       audio_clock_info->cts_44khz = actual_pixel_clock_in_khz;
-       audio_clock_info->cts_48khz = actual_pixel_clock_in_khz;
+                       actual_pixel_clock_100Hz / 100;
+       audio_clock_info->cts_32khz = actual_pixel_clock_100Hz / 10;
+       audio_clock_info->cts_44khz = actual_pixel_clock_100Hz / 10;
+       audio_clock_info->cts_48khz = actual_pixel_clock_100Hz / 10;
 
        audio_clock_info->n_32khz = 4096;
        audio_clock_info->n_44khz = 6272;
@@ -1308,14 +1308,14 @@ static void enc1_se_setup_hdmi_audio(
 
        /* Program audio clock sample/regeneration parameters */
        get_audio_clock_info(crtc_info->color_depth,
-                            crtc_info->requested_pixel_clock,
-                            crtc_info->calculated_pixel_clock,
+                            crtc_info->requested_pixel_clock_100Hz,
+                            crtc_info->calculated_pixel_clock_100Hz,
                             &audio_clock_info);
        DC_LOG_HW_AUDIO(
-                       "\n%s:Input::requested_pixel_clock = %d"        \
-                       "calculated_pixel_clock = %d \n", __func__,     \
-                       crtc_info->requested_pixel_clock,               \
-                       crtc_info->calculated_pixel_clock);
+                       "\n%s:Input::requested_pixel_clock_100Hz = %d"  \
+                       "calculated_pixel_clock_100Hz = %d \n", __func__,       \
+                       crtc_info->requested_pixel_clock_100Hz,         \
+                       crtc_info->calculated_pixel_clock_100Hz);
 
        /* HDMI_ACR_32_0__HDMI_ACR_CTS_32_MASK */
        REG_UPDATE(HDMI_ACR_32_0, HDMI_ACR_CTS_32, audio_clock_info.cts_32khz);
index bc2b4af9543b6af00062e448859dc3f5b9949a7d..075e49c1283a524e47c9c8fb5a86b62b927a9ba9 100644 (file)
@@ -605,8 +605,8 @@ void enc1_se_enable_dp_audio(
 
 void get_audio_clock_info(
        enum dc_color_depth color_depth,
-       uint32_t crtc_pixel_clock_in_khz,
-       uint32_t actual_pixel_clock_in_khz,
+       uint32_t crtc_pixel_clock_100Hz,
+       uint32_t actual_pixel_clock_100Hz,
        struct audio_clock_info *audio_clock_info);
 
 #endif /* __DC_STREAM_ENCODER_DCN10_H__ */
index 6364fbc24cfe08fa04d77455a010b44d1dc28f14..66a54da0641ce11feb10e1d777395f9bcd85f658 100644 (file)
@@ -38,8 +38,8 @@ struct audio_crtc_info {
        uint32_t h_active;
        uint32_t v_active;
        uint32_t pixel_repetition;
-       uint32_t requested_pixel_clock; /* in KHz */
-       uint32_t calculated_pixel_clock; /* in KHz */
+       uint32_t requested_pixel_clock_100Hz; /* in 100Hz */
+       uint32_t calculated_pixel_clock_100Hz; /* in 100Hz */
        uint32_t refresh_rate;
        enum dc_color_depth color_depth;
        bool interlaced;