<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
      charset=windows-1252">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Agreed, just wanted to reply as well
      since I think something is not correctly understood here.<br>
      <br>
      The <font size="2"><span style="font-size:11pt;">cpu_to_be16()
          and be16_to_cpu() functions work different depending on which
          architecture/endianess your are.<br>
          <br>
          So they should be a NO-OP on x86 if everything is done right.<br>
          <br>
          Christian.<br>
        </span></font><br>
      Am 17.04.20 um 04:32 schrieb Deucher, Alexander:<br>
    </div>
    <blockquote type="cite"
cite="mid:MN2PR12MB4488B2003904110CAE92E166F7D90@MN2PR12MB4488.namprd12.prod.outlook.com">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
      <p
        style="font-family:Arial;font-size:10pt;color:#317100;margin:15pt;"
        align="Left">
        [AMD Public Use]<br>
      </p>
      <br>
      <div>
        <div style="font-family: Calibri, Arial, Helvetica, sans-serif;
          font-size: 12pt; color: rgb(0, 0, 0);">
          I would drop this patch unless it only applies to APUs.  On
          Linux, people may run the driver on big endian systems.</div>
        <div style="font-family: Calibri, Arial, Helvetica, sans-serif;
          font-size: 12pt; color: rgb(0, 0, 0);">
          <br>
        </div>
        <div style="font-family: Calibri, Arial, Helvetica, sans-serif;
          font-size: 12pt; color: rgb(0, 0, 0);">
          Alex<br>
        </div>
        <hr style="display:inline-block;width:98%" tabindex="-1">
        <div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt"
            face="Calibri, sans-serif" color="#000000"><b>From:</b>
            amd-gfx <a class="moz-txt-link-rfc2396E" href="mailto:amd-gfx-bounces@lists.freedesktop.org"><amd-gfx-bounces@lists.freedesktop.org></a> on
            behalf of Rodrigo Siqueira <a class="moz-txt-link-rfc2396E" href="mailto:Rodrigo.Siqueira@amd.com"><Rodrigo.Siqueira@amd.com></a><br>
            <b>Sent:</b> Thursday, April 16, 2020 7:40 PM<br>
            <b>To:</b> <a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a>
            <a class="moz-txt-link-rfc2396E" href="mailto:amd-gfx@lists.freedesktop.org"><amd-gfx@lists.freedesktop.org></a><br>
            <b>Cc:</b> Li, Sun peng (Leo) <a class="moz-txt-link-rfc2396E" href="mailto:Sunpeng.Li@amd.com"><Sunpeng.Li@amd.com></a>;
            Wentland, Harry <a class="moz-txt-link-rfc2396E" href="mailto:Harry.Wentland@amd.com"><Harry.Wentland@amd.com></a>; Siqueira,
            Rodrigo <a class="moz-txt-link-rfc2396E" href="mailto:Rodrigo.Siqueira@amd.com"><Rodrigo.Siqueira@amd.com></a>; Wood, Wyatt
            <a class="moz-txt-link-rfc2396E" href="mailto:Wyatt.Wood@amd.com"><Wyatt.Wood@amd.com></a>; Lakha, Bhawanpreet
            <a class="moz-txt-link-rfc2396E" href="mailto:Bhawanpreet.Lakha@amd.com"><Bhawanpreet.Lakha@amd.com></a>; Koo, Anthony
            <a class="moz-txt-link-rfc2396E" href="mailto:Anthony.Koo@amd.com"><Anthony.Koo@amd.com></a><br>
            <b>Subject:</b> [PATCH 05/35] drm/amd/display: Remove byte
            swapping for dmcub abm config table</font>
          <div> </div>
        </div>
        <div class="BodyFragment"><font size="2"><span
              style="font-size:11pt;">
              <div class="PlainText">From: Wyatt Wood
                <a class="moz-txt-link-rfc2396E" href="mailto:wyatt.wood@amd.com"><wyatt.wood@amd.com></a><br>
                <br>
                [Why]<br>
                Since x86 and dmcub are both little endian, byte
                swapping isn't<br>
                necessary. Dmcu requires byte swapping as it is big
                endian.<br>
                <br>
                [How]<br>
                Add flag to function definitions to determine if byte
                swapping is<br>
                necessary.<br>
                <br>
                Signed-off-by: Wyatt Wood <a class="moz-txt-link-rfc2396E" href="mailto:wyatt.wood@amd.com"><wyatt.wood@amd.com></a><br>
                Reviewed-by: Anthony Koo <a class="moz-txt-link-rfc2396E" href="mailto:Anthony.Koo@amd.com"><Anthony.Koo@amd.com></a><br>
                Acked-by: Rodrigo Siqueira
                <a class="moz-txt-link-rfc2396E" href="mailto:Rodrigo.Siqueira@amd.com"><Rodrigo.Siqueira@amd.com></a><br>
                ---<br>
                 .../amd/display/modules/power/power_helpers.c | 74
                +++++++++----------<br>
                 1 file changed, 36 insertions(+), 38 deletions(-)<br>
                <br>
                diff --git
                a/drivers/gpu/drm/amd/display/modules/power/power_helpers.c
b/drivers/gpu/drm/amd/display/modules/power/power_helpers.c<br>
                index dd1517684c90..edb446455f6b 100644<br>
                ---
                a/drivers/gpu/drm/amd/display/modules/power/power_helpers.c<br>
                +++
                b/drivers/gpu/drm/amd/display/modules/power/power_helpers.c<br>
                @@ -240,7 +240,7 @@ static void
                fill_backlight_transform_table(struct
                dmcu_iram_parameters params,<br>
                 }<br>
                 <br>
                 static void fill_backlight_transform_table_v_2_2(struct
                dmcu_iram_parameters params,<br>
                -               struct iram_table_v_2_2 *table)<br>
                +               struct iram_table_v_2_2 *table, bool
                big_endian)<br>
                 {<br>
                         unsigned int i;<br>
                         unsigned int num_entries = NUM_BL_CURVE_SEGS;<br>
                @@ -264,10 +264,10 @@ static void
                fill_backlight_transform_table_v_2_2(struct
                dmcu_iram_parameters par<br>
                                 lut_index =
                (params.backlight_lut_array_size - 1) * i / (num_entries
                - 1);<br>
                                 ASSERT(lut_index <
                params.backlight_lut_array_size);<br>
                 <br>
                -               table->backlight_thresholds[i] =<br>
                -                       cpu_to_be16(DIV_ROUNDUP((i *
                65536), num_entries));<br>
                -               table->backlight_offsets[i] =<br>
                -                      
                cpu_to_be16(params.backlight_lut_array[lut_index]);<br>
                +               table->backlight_thresholds[i] =
                (big_endian) ?<br>
                +                       cpu_to_be16(DIV_ROUNDUP((i *
                65536), num_entries)) : DIV_ROUNDUP((i * 65536),
                num_entries);<br>
                +               table->backlight_offsets[i] =
                (big_endian) ?<br>
                +                      
                cpu_to_be16(params.backlight_lut_array[lut_index]) :
                params.backlight_lut_array[lut_index];<br>
                         }<br>
                 }<br>
                 <br>
                @@ -587,18 +587,16 @@ void fill_iram_v_2_2(struct
                iram_table_v_2_2 *ram_table, struct dmcu_iram_parame<br>
                         ram_table->crgb_slope[7]  =
                cpu_to_be16(0x1910);<br>
                 <br>
                         fill_backlight_transform_table_v_2_2(<br>
                -                       params, ram_table);<br>
                +                       params, ram_table, true);<br>
                 }<br>
                 <br>
                -void fill_iram_v_2_3(struct iram_table_v_2_2
                *ram_table, struct dmcu_iram_parameters params)<br>
                +void fill_iram_v_2_3(struct iram_table_v_2_2
                *ram_table, struct dmcu_iram_parameters params, bool
                big_endian)<br>
                 {<br>
                         unsigned int i, j;<br>
                         unsigned int set = params.set;<br>
                 <br>
                         ram_table->flags = 0x0;<br>
                -<br>
                -       ram_table->min_abm_backlight =<br>
                -                      
                cpu_to_be16(params.min_abm_backlight);<br>
                +       ram_table->min_abm_backlight = (big_endian) ?
                cpu_to_be16(params.min_abm_backlight) :
                params.min_abm_backlight;<br>
                 <br>
                         for (i = 0; i < NUM_AGGR_LEVEL; i++) {<br>
                                 ram_table->hybrid_factor[i] =
                abm_settings[set][i].brightness_gain;<br>
                @@ -622,33 +620,33 @@ void fill_iram_v_2_3(struct
                iram_table_v_2_2 *ram_table, struct dmcu_iram_parame<br>
                         ram_table->iir_curve[4] = 0x65;<br>
                 <br>
                         //Gamma 2.2<br>
                -       ram_table->crgb_thresh[0] =
                cpu_to_be16(0x127c);<br>
                -       ram_table->crgb_thresh[1] =
                cpu_to_be16(0x151b);<br>
                -       ram_table->crgb_thresh[2] =
                cpu_to_be16(0x17d5);<br>
                -       ram_table->crgb_thresh[3] =
                cpu_to_be16(0x1a56);<br>
                -       ram_table->crgb_thresh[4] =
                cpu_to_be16(0x1c83);<br>
                -       ram_table->crgb_thresh[5] =
                cpu_to_be16(0x1e72);<br>
                -       ram_table->crgb_thresh[6] =
                cpu_to_be16(0x20f0);<br>
                -       ram_table->crgb_thresh[7] =
                cpu_to_be16(0x232b);<br>
                -       ram_table->crgb_offset[0] =
                cpu_to_be16(0x2999);<br>
                -       ram_table->crgb_offset[1] =
                cpu_to_be16(0x3999);<br>
                -       ram_table->crgb_offset[2] =
                cpu_to_be16(0x4666);<br>
                -       ram_table->crgb_offset[3] =
                cpu_to_be16(0x5999);<br>
                -       ram_table->crgb_offset[4] =
                cpu_to_be16(0x6333);<br>
                -       ram_table->crgb_offset[5] =
                cpu_to_be16(0x7800);<br>
                -       ram_table->crgb_offset[6] =
                cpu_to_be16(0x8c00);<br>
                -       ram_table->crgb_offset[7] =
                cpu_to_be16(0xa000);<br>
                -       ram_table->crgb_slope[0]  =
                cpu_to_be16(0x3609);<br>
                -       ram_table->crgb_slope[1]  =
                cpu_to_be16(0x2dfa);<br>
                -       ram_table->crgb_slope[2]  =
                cpu_to_be16(0x27ea);<br>
                -       ram_table->crgb_slope[3]  =
                cpu_to_be16(0x235d);<br>
                -       ram_table->crgb_slope[4]  =
                cpu_to_be16(0x2042);<br>
                -       ram_table->crgb_slope[5]  =
                cpu_to_be16(0x1dc3);<br>
                -       ram_table->crgb_slope[6]  =
                cpu_to_be16(0x1b1a);<br>
                -       ram_table->crgb_slope[7]  =
                cpu_to_be16(0x1910);<br>
                +       ram_table->crgb_thresh[0] = (big_endian) ?
                cpu_to_be16(0x127c) : 0x127c;<br>
                +       ram_table->crgb_thresh[1] = (big_endian) ?
                cpu_to_be16(0x151b) : 0x151b;<br>
                +       ram_table->crgb_thresh[2] = (big_endian) ?
                cpu_to_be16(0x17d5) : 0x17d5;<br>
                +       ram_table->crgb_thresh[3] = (big_endian) ?
                cpu_to_be16(0x1a56) : 0x1a56;<br>
                +       ram_table->crgb_thresh[4] = (big_endian) ?
                cpu_to_be16(0x1c83) : 0x1c83;<br>
                +       ram_table->crgb_thresh[5] = (big_endian) ?
                cpu_to_be16(0x1e72) : 0x1e72;<br>
                +       ram_table->crgb_thresh[6] = (big_endian) ?
                cpu_to_be16(0x20f0) : 0x20f0;<br>
                +       ram_table->crgb_thresh[7] = (big_endian) ?
                cpu_to_be16(0x232b) : 0x232b;<br>
                +       ram_table->crgb_offset[0] = (big_endian) ?
                cpu_to_be16(0x2999) : 0x2999;<br>
                +       ram_table->crgb_offset[1] = (big_endian) ?
                cpu_to_be16(0x3999) : 0x3999;<br>
                +       ram_table->crgb_offset[2] = (big_endian) ?
                cpu_to_be16(0x4666) : 0x4666;<br>
                +       ram_table->crgb_offset[3] = (big_endian) ?
                cpu_to_be16(0x5999) : 0x5999;<br>
                +       ram_table->crgb_offset[4] = (big_endian) ?
                cpu_to_be16(0x6333) : 0x6333;<br>
                +       ram_table->crgb_offset[5] = (big_endian) ?
                cpu_to_be16(0x7800) : 0x7800;<br>
                +       ram_table->crgb_offset[6] = (big_endian) ?
                cpu_to_be16(0x8c00) : 0x8c00;<br>
                +       ram_table->crgb_offset[7] = (big_endian) ?
                cpu_to_be16(0xa000) : 0xa000;<br>
                +       ram_table->crgb_slope[0]  = (big_endian) ?
                cpu_to_be16(0x3609) : 0x3609;<br>
                +       ram_table->crgb_slope[1]  = (big_endian) ?
                cpu_to_be16(0x2dfa) : 0x2dfa;<br>
                +       ram_table->crgb_slope[2]  = (big_endian) ?
                cpu_to_be16(0x27ea) : 0x27ea;<br>
                +       ram_table->crgb_slope[3]  = (big_endian) ?
                cpu_to_be16(0x235d) : 0x235d;<br>
                +       ram_table->crgb_slope[4]  = (big_endian) ?
                cpu_to_be16(0x2042) : 0x2042;<br>
                +       ram_table->crgb_slope[5]  = (big_endian) ?
                cpu_to_be16(0x1dc3) : 0x1dc3;<br>
                +       ram_table->crgb_slope[6]  = (big_endian) ?
                cpu_to_be16(0x1b1a) : 0x1b1a;<br>
                +       ram_table->crgb_slope[7]  = (big_endian) ?
                cpu_to_be16(0x1910) : 0x1910;<br>
                 <br>
                         fill_backlight_transform_table_v_2_2(<br>
                -                       params, ram_table);<br>
                +                       params, ram_table, big_endian);<br>
                 }<br>
                 <br>
                 bool dmub_init_abm_config(struct abm *abm,<br>
                @@ -662,7 +660,7 @@ bool dmub_init_abm_config(struct abm
                *abm,<br>
                 <br>
                         memset(&ram_table, 0, sizeof(ram_table));<br>
                 <br>
                -       fill_iram_v_2_3((struct iram_table_v_2_2
                *)ram_table, params);<br>
                +       fill_iram_v_2_3((struct iram_table_v_2_2
                *)ram_table, params, false);<br>
                         result = abm->funcs->init_abm_config(<br>
                                 abm, (char *)(&ram_table),
                IRAM_RESERVE_AREA_START_V2_2);<br>
                 <br>
                @@ -684,11 +682,11 @@ bool dmcu_load_iram(struct dmcu
                *dmcu,<br>
                         memset(&ram_table, 0, sizeof(ram_table));<br>
                 <br>
                         if (dmcu->dmcu_version.abm_version == 0x24)
                {<br>
                -               fill_iram_v_2_3((struct iram_table_v_2_2
                *)ram_table, params);<br>
                +               fill_iram_v_2_3((struct iram_table_v_2_2
                *)ram_table, params, true);<br>
                                         result =
                dmcu->funcs->load_iram(<br>
                                                         dmcu, 0, (char
                *)(&ram_table), IRAM_RESERVE_AREA_START_V2_2);<br>
                         } else if (dmcu->dmcu_version.abm_version ==
                0x23) {<br>
                -               fill_iram_v_2_3((struct iram_table_v_2_2
                *)ram_table, params);<br>
                +               fill_iram_v_2_3((struct iram_table_v_2_2
                *)ram_table, params, true);<br>
                 <br>
                                 result = dmcu->funcs->load_iram(<br>
                                                 dmcu, 0, (char
                *)(&ram_table), IRAM_RESERVE_AREA_START_V2_2);<br>
                -- <br>
                2.26.0<br>
                <br>
                _______________________________________________<br>
                amd-gfx mailing list<br>
                <a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
                <a
href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Calexander.deucher%40amd.com%7C71bc54a1a7b7444439c208d7e25fab51%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637226772877797082&amp;sdata=sa4MJoUY%2FjVgW3f4Qx1N4KYpFY3QyqZPWVDbRoUmTxs%3D&amp;reserved=0"
                  moz-do-not-send="true">https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Calexander.deucher%40amd.com%7C71bc54a1a7b7444439c208d7e25fab51%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637226772877797082&amp;sdata=sa4MJoUY%2FjVgW3f4Qx1N4KYpFY3QyqZPWVDbRoUmTxs%3D&amp;reserved=0</a><br>
              </div>
            </span></font></div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
amd-gfx mailing list
<a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>