<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-CA" link="blue" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Hi Lyude,</p>
<p class="MsoNormal">Thanks for the review.</p>
<p class="MsoNormal">I’ve updated this patch in a v9 iteration of it, I’ve sent separately from the series this past Monday. The new version has the updated selftest.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,</p>
<p class="MsoNormal">Mikita </p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="border:none;padding:0cm"><b>From: </b><a href="mailto:lyude@redhat.com">Lyude Paul</a><br>
<b>Sent: </b>December 6, 2019 7:17 PM<br>
<b>To: </b><a href="mailto:Mikita.Lipski@amd.com">Lipski, Mikita</a>; <a href="mailto:amd-gfx@lists.freedesktop.org">
amd-gfx@lists.freedesktop.org</a><br>
<b>Cc: </b><a href="mailto:dri-devel@lists.freedesktop.org">dri-devel@lists.freedesktop.org</a>;
<a href="mailto:David.Francis@amd.com">David Francis</a><br>
<b>Subject: </b>Re: [PATCH v8 01/17] drm/dp_mst: Add PBN calculation for DSC modes</p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">This patch still needs to be rebased, and the selftests for the PBN<br>
calculation that got added still need to be updated to reflect the changes for<br>
dsc. The code for PBN calculation changed quite a bit upstream since this<br>
series started.<br>
<br>
On Tue, 2019-12-03 at 09:35 -0500, mikita.lipski@amd.com wrote:<br>
> From: David Francis <David.Francis@amd.com><br>
> <br>
> With DSC, bpp can be fractional in multiples of 1/16.<br>
> <br>
> Change drm_dp_calc_pbn_mode to reflect this, adding a new<br>
> parameter bool dsc. When this parameter is true, treat the<br>
> bpp parameter as having units not of bits per pixel, but<br>
> 1/16 of a bit per pixel<br>
> <br>
> v2: Don't add separate function for this<br>
> <br>
> v3: Keep the calculation in a single equation<br>
> <br>
> Cc: Lyude Paul <lyude@redhat.com><br>
> Reviewed-by: Manasi Navare <manasi.d.navare@intel.com><br>
> Reviewed-by: Lyude Paul <lyude@redhat.com><br>
> Reviewed-by: Harry Wentland <harry.wentland@amd.com><br>
> Signed-off-by: David Francis <David.Francis@amd.com><br>
> Signed-off-by: Mikita Lipski <mikita.lipski@amd.com><br>
> ---<br>
>  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  2 +-<br>
>  drivers/gpu/drm/drm_dp_mst_topology.c         | 38 ++++++++++++++++++-<br>
>  drivers/gpu/drm/i915/display/intel_dp_mst.c   |  3 +-<br>
>  drivers/gpu/drm/nouveau/dispnv50/disp.c       |  2 +-<br>
>  drivers/gpu/drm/radeon/radeon_dp_mst.c        |  2 +-<br>
>  include/drm/drm_dp_mst_helper.h               |  3 +-<br>
>  6 files changed, 43 insertions(+), 7 deletions(-)<br>
> <br>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
> index 455c51c38720..9fc03fc1017d 100644<br>
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
> @@ -4967,7 +4967,7 @@ static int dm_encoder_helper_atomic_check(struct<br>
> drm_encoder *encoder,<br>
>                                                                    is_y420);<br>
>                bpp = convert_dc_color_depth_into_bpc(color_depth) * 3;<br>
>                clock = adjusted_mode->clock;<br>
> -             dm_new_connector_state->pbn = drm_dp_calc_pbn_mode(clock,<br>
> bpp);<br>
> +             dm_new_connector_state->pbn = drm_dp_calc_pbn_mode(clock, bpp,<br>
> false);<br>
>        }<br>
>        dm_new_connector_state->vcpi_slots =<br>
> drm_dp_atomic_find_vcpi_slots(state,<br>
>                                                                           mst<br>
> _mgr,<br>
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c<br>
> b/drivers/gpu/drm/drm_dp_mst_topology.c<br>
> index ae5809a1f19a..261e2c1828c6 100644<br>
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c<br>
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c<br>
> @@ -4342,10 +4342,11 @@ EXPORT_SYMBOL(drm_dp_check_act_status);<br>
>   * drm_dp_calc_pbn_mode() - Calculate the PBN for a mode.<br>
>   * @clock: dot clock for the mode<br>
>   * @bpp: bpp for the mode.<br>
> + * @dsc: DSC mode. If true, bpp has units of 1/16 of a bit per pixel<br>
>   *<br>
>   * This uses the formula in the spec to calculate the PBN value for a mode.<br>
>   */<br>
> -int drm_dp_calc_pbn_mode(int clock, int bpp)<br>
> +int drm_dp_calc_pbn_mode(int clock, int bpp, bool dsc)<br>
>  {<br>
>        /*<br>
>         * margin 5300ppm + 300ppm ~ 0.6% as per spec, factor is 1.006<br>
> @@ -4356,12 +4357,47 @@ int drm_dp_calc_pbn_mode(int clock, int bpp)<br>
>         * peak_kbps *= (1006/1000)<br>
>         * peak_kbps *= (64/54)<br>
>         * peak_kbps *= 8    convert to bytes<br>
> +      *<br>
> +      * If the bpp is in units of 1/16, further divide by 16. Put this<br>
> +      * factor in the numerator rather than the denominator to avoid<br>
> +      * integer overflow<br>
>         */<br>
> +<br>
> +     if (dsc)<br>
> +             return DIV_ROUND_UP_ULL(mul_u32_u32(clock * bpp, 64 * 1006 /<br>
> 16),<br>
> +                                     8 * 54 * 1000 * 1000);<br>
> +<br>
>        return DIV_ROUND_UP_ULL(mul_u32_u32(clock * bpp, 64 * 1006),<br>
>                                8 * 54 * 1000 * 1000);<br>
> +<br>
>  }<br>
>  EXPORT_SYMBOL(drm_dp_calc_pbn_mode);<br>
>  <br>
> +static int test_calc_pbn_mode(void)<br>
> +{<br>
> +     int ret;<br>
> +     ret = drm_dp_calc_pbn_mode(154000, 30, false);<br>
> +     if (ret != 689) {<br>
> +             DRM_ERROR("PBN calculation test failed - clock %d, bpp %d,<br>
> expected PBN %d, actual PBN %d.\n",<br>
> +                             154000, 30, 689, ret);<br>
> +             return -EINVAL;<br>
> +     }<br>
> +     ret = drm_dp_calc_pbn_mode(234000, 30, false);<br>
> +     if (ret != 1047) {<br>
> +             DRM_ERROR("PBN calculation test failed - clock %d, bpp %d,<br>
> expected PBN %d, actual PBN %d.\n",<br>
> +                             234000, 30, 1047, ret);<br>
> +             return -EINVAL;<br>
> +     }<br>
> +     ret = drm_dp_calc_pbn_mode(297000, 24, false);<br>
> +     if (ret != 1063) {<br>
> +             DRM_ERROR("PBN calculation test failed - clock %d, bpp %d,<br>
> expected PBN %d, actual PBN %d.\n",<br>
> +                             297000, 24, 1063, ret);<br>
> +             return -EINVAL;<br>
> +     }<br>
> +     return 0;<br>
> +}<br>
> +<br>
> +<br>
>  /* we want to kick the TX after we've ack the up/down IRQs. */<br>
>  static void drm_dp_mst_kick_tx(struct drm_dp_mst_topology_mgr *mgr)<br>
>  {<br>
> diff --git a/drivers/gpu/drm/i915/display/intel_dp_mst.c<br>
> b/drivers/gpu/drm/i915/display/intel_dp_mst.c<br>
> index 03d1cba0b696..92be17711287 100644<br>
> --- a/drivers/gpu/drm/i915/display/intel_dp_mst.c<br>
> +++ b/drivers/gpu/drm/i915/display/intel_dp_mst.c<br>
> @@ -61,7 +61,8 @@ static int intel_dp_mst_compute_link_config(struct<br>
> intel_encoder *encoder,<br>
>                crtc_state->pipe_bpp = bpp;<br>
>  <br>
>                crtc_state->pbn = drm_dp_calc_pbn_mode(adjusted_mode-<br>
> >crtc_clock,<br>
> -                                                    crtc_state->pipe_bpp);<br>
> +                                                    crtc_state->pipe_bpp,<br>
> +                                                    false);<br>
>  <br>
>                slots = drm_dp_atomic_find_vcpi_slots(state, &intel_dp-<br>
> >mst_mgr,<br>
>                                                      port, crtc_state->pbn);<br>
> diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c<br>
> b/drivers/gpu/drm/nouveau/dispnv50/disp.c<br>
> index 549486f1d937..1c9e23d5a6fd 100644<br>
> --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c<br>
> +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c<br>
> @@ -782,7 +782,7 @@ nv50_msto_atomic_check(struct drm_encoder *encoder,<br>
>                        const int bpp = connector->display_info.bpc * 3;<br>
>                        const int clock = crtc_state->adjusted_mode.clock;<br>
>  <br>
> -                     asyh->dp.pbn = drm_dp_calc_pbn_mode(clock, bpp);<br>
> +                     asyh->dp.pbn = drm_dp_calc_pbn_mode(clock, bpp,<br>
> false);<br>
>                }<br>
>  <br>
>                slots = drm_dp_atomic_find_vcpi_slots(state, &mstm->mgr,<br>
> diff --git a/drivers/gpu/drm/radeon/radeon_dp_mst.c<br>
> b/drivers/gpu/drm/radeon/radeon_dp_mst.c<br>
> index ee28f5b3785e..28eef9282874 100644<br>
> --- a/drivers/gpu/drm/radeon/radeon_dp_mst.c<br>
> +++ b/drivers/gpu/drm/radeon/radeon_dp_mst.c<br>
> @@ -518,7 +518,7 @@ static bool radeon_mst_mode_fixup(struct drm_encoder<br>
> *encoder,<br>
>  <br>
>        mst_enc = radeon_encoder->enc_priv;<br>
>  <br>
> -     mst_enc->pbn = drm_dp_calc_pbn_mode(adjusted_mode->clock, bpp);<br>
> +     mst_enc->pbn = drm_dp_calc_pbn_mode(adjusted_mode->clock, bpp, false);<br>
>  <br>
>        mst_enc->primary->active_device = mst_enc->primary->devices & mst_enc-<br>
> >connector->devices;<br>
>        DRM_DEBUG_KMS("setting active device to %08x from %08x %08x for<br>
> encoder %d\n",<br>
> diff --git a/include/drm/drm_dp_mst_helper.h<br>
> b/include/drm/drm_dp_mst_helper.h<br>
> index d5fc90b30487..68656913cfe5 100644<br>
> --- a/include/drm/drm_dp_mst_helper.h<br>
> +++ b/include/drm/drm_dp_mst_helper.h<br>
> @@ -719,8 +719,7 @@ bool drm_dp_mst_port_has_audio(struct<br>
> drm_dp_mst_topology_mgr *mgr,<br>
>  struct edid *drm_dp_mst_get_edid(struct drm_connector *connector, struct<br>
> drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port);<br>
>  <br>
>  <br>
> -int drm_dp_calc_pbn_mode(int clock, int bpp);<br>
> -<br>
> +int drm_dp_calc_pbn_mode(int clock, int bpp, bool dsc);<br>
>  <br>
>  bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr,<br>
>                              struct drm_dp_mst_port *port, int pbn, int<br>
> slots);<br>
-- <br>
Cheers,<br>
        Lyude Paul<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>