From nobody Wed Apr 8 00:00:35 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6A7CC433FE for ; Thu, 20 Oct 2022 22:11:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229621AbiJTWLP (ORCPT ); Thu, 20 Oct 2022 18:11:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbiJTWLM (ORCPT ); Thu, 20 Oct 2022 18:11:12 -0400 Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B2EF1DCCCB for ; Thu, 20 Oct 2022 15:11:11 -0700 (PDT) Received: by mail-oi1-x22b.google.com with SMTP id g10so1188510oif.10 for ; Thu, 20 Oct 2022 15:11:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ZNcH8NNQ6H+ucEIDfZ6GtfiM1CXoewou+C4DHO1ovk4=; b=a8E5Qd8N1dlsyq39Y+t7APU29CWKcb7GobXv9R3jGBeT+H82d9SSPjSLUB/v69b7uF mqwmmTJ1EPc57abpt4vdRG5PbC8xgd6MbJNgmxCX8ICCgbFH+2dKiHZnKhuBTQlplydV 9b0mw5gmn3c9UQWwicPLknL6TcFstS67+HPa5KN/3oT8SkgjHOJc/Zo7wtPmAWlsLQdd iK6IQQv1OiWYoWl7+55pSyKaFZ9g3863K4WbXS0K+HSZKeLN7lofg0puzpCuSYVlQD+O T6u63lM3pyamlEp9D8zul2+J2WNfiTiu6tdOgMNJlJ4TH9vn6lob21UhvVaTzpU39uR9 PdzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZNcH8NNQ6H+ucEIDfZ6GtfiM1CXoewou+C4DHO1ovk4=; b=0UjoLGEUiknfYoEtBACDpdDCXXGKuE93Iw2AppRwMXQH5d7bbv0dMUzG6XlCA2AF8s 2uuX77q1Lo/JNdgPgTtZNdndbOFlw7a1ofjE5n/Gl6w1APeQ/TCTO0QHvcz7wm1Q+NSm FTdk87tegXy3k/PGDjBxNSzxH06xCkPIfi/iWW3iBrCNbRnZRJV2FCd1Yzd54Zu7YqV+ 2LirUvCEpf9WHlgeyKdz0WDT2p2F13U6lOHVMZeu7C1wfIjtt4FZwDc9XmN6rZDTxav3 NfiJSqLRvne28kSvOci7sX6RAGw+yDHUAlU8TdeIJ5v2aE05ADjMhSnRwduoUvyeB/cF Cy6g== X-Gm-Message-State: ACrzQf3JFypcqu02+A45CQ+GWs065lScRlaKLhgWsB6JaZjBZ7RRBzR1 tLxWaoKYdWP1ALAtTF9fNCaWszw7WRoerQ== X-Google-Smtp-Source: AMsMyM7UfZbFJXOnTdCHew1dUKSWIPUiHwIJV3yBwwrPBaBfYg6ojijf0+vWLbd/8EzlK+0HDSR0TQ== X-Received: by 2002:a05:6808:16ac:b0:353:b7d7:5fef with SMTP id bb44-20020a05680816ac00b00353b7d75fefmr8925133oib.293.1666303870481; Thu, 20 Oct 2022 15:11:10 -0700 (PDT) Received: from macondo.. ([2804:431:e7cc:1855:2215:4175:ce03:9ed3]) by smtp.gmail.com with ESMTPSA id cp27-20020a056830661b00b006605883eae6sm385512otb.63.2022.10.20.15.11.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 15:11:10 -0700 (PDT) From: Rafael Mendonca To: Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter Cc: Rafael Mendonca , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/amd/display: Remove duplicate code for DCN314 DML calculation Date: Thu, 20 Oct 2022 19:10:50 -0300 Message-Id: <20221020221051.919704-1-rafaelmendsr@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This is an extension of commit fd3bc691fc7b ("drm/amd/display: Remove duplicate code across dcn30 and dcn31"), which removed duplicate code for the function CalculateBytePerPixelAnd256BBlockSizes() across dcn30 and dcn31. At the time the aforementioned commit was introduced, support for DCN 3.1.4 was still not merged. Thus, this deletes duplicate code for CalculateBytePerPixelAnd256BBlockSizes(), that was introduced later in DCN314, in favor of using the respective functionality from 'display_mode_vba_30.h'. Additionally, by doing that, we also fix a duplicate argument issue reported by coccinelle in 'display_rq_dlg_calc_314.c': static bool CalculateBytePerPixelAnd256BBlockSizes(...) { ... } else if (SourcePixelFormat =3D=3D dm_444_16 || SourcePixelFormat =3D= =3D dm_444_16) { ... } Signed-off-by: Rafael Mendonca --- .../dc/dml/dcn314/display_mode_vba_314.c | 106 +----------------- .../dc/dml/dcn314/display_rq_dlg_calc_314.c | 91 +-------------- 2 files changed, 6 insertions(+), 191 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn314/display_mode_vba_314= .c b/drivers/gpu/drm/amd/display/dc/dml/dcn314/display_mode_vba_314.c index 0d12fd079cd6..6e43cd21a7d3 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/dcn314/display_mode_vba_314.c +++ b/drivers/gpu/drm/amd/display/dc/dml/dcn314/display_mode_vba_314.c @@ -32,6 +32,7 @@ #include "../display_mode_lib.h" #include "display_mode_vba_314.h" #include "../dml_inline_defs.h" +#include "dml/dcn30/display_mode_vba_30.h" =20 /* * NOTE: @@ -90,17 +91,6 @@ typedef struct { #define BPP_INVALID 0 #define BPP_BLENDED_PIPE 0xffffffff =20 -static bool CalculateBytePerPixelAnd256BBlockSizes( - enum source_format_class SourcePixelFormat, - enum dm_swizzle_mode SurfaceTiling, - unsigned int *BytePerPixelY, - unsigned int *BytePerPixelC, - double *BytePerPixelDETY, - double *BytePerPixelDETC, - unsigned int *BlockHeight256BytesY, - unsigned int *BlockHeight256BytesC, - unsigned int *BlockWidth256BytesY, - unsigned int *BlockWidth256BytesC); static void DisplayPipeConfiguration(struct display_mode_lib *mode_lib); static void DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPer= formanceCalculation(struct display_mode_lib *mode_lib); static unsigned int dscceComputeDelay( @@ -2178,7 +2168,7 @@ static void DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParam= etersWatermarksAndPerforman DTRACE(" return_bus_bw =3D %f", v->ReturnBW); =20 for (k =3D 0; k < v->NumberOfActivePlanes; ++k) { - CalculateBytePerPixelAnd256BBlockSizes( + dml30_CalculateBytePerPixelAnd256BBlockSizes( v->SourcePixelFormat[k], v->SurfaceTiling[k], &v->BytePerPixelY[k], @@ -3317,7 +3307,7 @@ static void DisplayPipeConfiguration(struct display_m= ode_lib *mode_lib) =20 for (k =3D 0; k < v->NumberOfActivePlanes; ++k) { =20 - CalculateBytePerPixelAnd256BBlockSizes( + dml30_CalculateBytePerPixelAnd256BBlockSizes( v->SourcePixelFormat[k], v->SurfaceTiling[k], &BytePerPixY[k], @@ -3371,94 +3361,6 @@ static void DisplayPipeConfiguration(struct display_= mode_lib *mode_lib) &dummysinglestring); } =20 -static bool CalculateBytePerPixelAnd256BBlockSizes( - enum source_format_class SourcePixelFormat, - enum dm_swizzle_mode SurfaceTiling, - unsigned int *BytePerPixelY, - unsigned int *BytePerPixelC, - double *BytePerPixelDETY, - double *BytePerPixelDETC, - unsigned int *BlockHeight256BytesY, - unsigned int *BlockHeight256BytesC, - unsigned int *BlockWidth256BytesY, - unsigned int *BlockWidth256BytesC) -{ - if (SourcePixelFormat =3D=3D dm_444_64) { - *BytePerPixelDETY =3D 8; - *BytePerPixelDETC =3D 0; - *BytePerPixelY =3D 8; - *BytePerPixelC =3D 0; - } else if (SourcePixelFormat =3D=3D dm_444_32 || SourcePixelFormat =3D=3D= dm_rgbe) { - *BytePerPixelDETY =3D 4; - *BytePerPixelDETC =3D 0; - *BytePerPixelY =3D 4; - *BytePerPixelC =3D 0; - } else if (SourcePixelFormat =3D=3D dm_444_16) { - *BytePerPixelDETY =3D 2; - *BytePerPixelDETC =3D 0; - *BytePerPixelY =3D 2; - *BytePerPixelC =3D 0; - } else if (SourcePixelFormat =3D=3D dm_444_8) { - *BytePerPixelDETY =3D 1; - *BytePerPixelDETC =3D 0; - *BytePerPixelY =3D 1; - *BytePerPixelC =3D 0; - } else if (SourcePixelFormat =3D=3D dm_rgbe_alpha) { - *BytePerPixelDETY =3D 4; - *BytePerPixelDETC =3D 1; - *BytePerPixelY =3D 4; - *BytePerPixelC =3D 1; - } else if (SourcePixelFormat =3D=3D dm_420_8) { - *BytePerPixelDETY =3D 1; - *BytePerPixelDETC =3D 2; - *BytePerPixelY =3D 1; - *BytePerPixelC =3D 2; - } else if (SourcePixelFormat =3D=3D dm_420_12) { - *BytePerPixelDETY =3D 2; - *BytePerPixelDETC =3D 4; - *BytePerPixelY =3D 2; - *BytePerPixelC =3D 4; - } else { - *BytePerPixelDETY =3D 4.0 / 3; - *BytePerPixelDETC =3D 8.0 / 3; - *BytePerPixelY =3D 2; - *BytePerPixelC =3D 4; - } - - if ((SourcePixelFormat =3D=3D dm_444_64 || SourcePixelFormat =3D=3D dm_44= 4_32 || SourcePixelFormat =3D=3D dm_444_16 || SourcePixelFormat =3D=3D dm_4= 44_8 || SourcePixelFormat =3D=3D dm_mono_16 - || SourcePixelFormat =3D=3D dm_mono_8 || SourcePixelFormat =3D=3D dm_rg= be)) { - if (SurfaceTiling =3D=3D dm_sw_linear) { - *BlockHeight256BytesY =3D 1; - } else if (SourcePixelFormat =3D=3D dm_444_64) { - *BlockHeight256BytesY =3D 4; - } else if (SourcePixelFormat =3D=3D dm_444_8) { - *BlockHeight256BytesY =3D 16; - } else { - *BlockHeight256BytesY =3D 8; - } - *BlockWidth256BytesY =3D 256U / *BytePerPixelY / *BlockHeight256BytesY; - *BlockHeight256BytesC =3D 0; - *BlockWidth256BytesC =3D 0; - } else { - if (SurfaceTiling =3D=3D dm_sw_linear) { - *BlockHeight256BytesY =3D 1; - *BlockHeight256BytesC =3D 1; - } else if (SourcePixelFormat =3D=3D dm_rgbe_alpha) { - *BlockHeight256BytesY =3D 8; - *BlockHeight256BytesC =3D 16; - } else if (SourcePixelFormat =3D=3D dm_420_8) { - *BlockHeight256BytesY =3D 16; - *BlockHeight256BytesC =3D 8; - } else { - *BlockHeight256BytesY =3D 8; - *BlockHeight256BytesC =3D 8; - } - *BlockWidth256BytesY =3D 256U / *BytePerPixelY / *BlockHeight256BytesY; - *BlockWidth256BytesC =3D 256U / *BytePerPixelC / *BlockHeight256BytesC; - } - return true; -} - static double CalculateTWait(unsigned int PrefetchMode, double DRAMClockCh= angeLatency, double UrgentLatency, double SREnterPlusExitTime) { if (PrefetchMode =3D=3D 0) { @@ -3948,7 +3850,7 @@ void dml314_ModeSupportAndSystemConfigurationFull(str= uct display_mode_lib *mode_ /*Bandwidth Support Check*/ =20 for (k =3D 0; k < v->NumberOfActivePlanes; k++) { - CalculateBytePerPixelAnd256BBlockSizes( + dml30_CalculateBytePerPixelAnd256BBlockSizes( v->SourcePixelFormat[k], v->SurfaceTiling[k], &v->BytePerPixelY[k], diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn314/display_rq_dlg_calc_= 314.c b/drivers/gpu/drm/amd/display/dc/dml/dcn314/display_rq_dlg_calc_314.c index 61ee9ba063a7..a373d35dd473 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/dcn314/display_rq_dlg_calc_314.c +++ b/drivers/gpu/drm/amd/display/dc/dml/dcn314/display_rq_dlg_calc_314.c @@ -28,94 +28,7 @@ #include "../display_mode_vba.h" #include "../dml_inline_defs.h" #include "display_rq_dlg_calc_314.h" - -static bool CalculateBytePerPixelAnd256BBlockSizes( - enum source_format_class SourcePixelFormat, - enum dm_swizzle_mode SurfaceTiling, - unsigned int *BytePerPixelY, - unsigned int *BytePerPixelC, - double *BytePerPixelDETY, - double *BytePerPixelDETC, - unsigned int *BlockHeight256BytesY, - unsigned int *BlockHeight256BytesC, - unsigned int *BlockWidth256BytesY, - unsigned int *BlockWidth256BytesC) -{ - if (SourcePixelFormat =3D=3D dm_444_64) { - *BytePerPixelDETY =3D 8; - *BytePerPixelDETC =3D 0; - *BytePerPixelY =3D 8; - *BytePerPixelC =3D 0; - } else if (SourcePixelFormat =3D=3D dm_444_32 || SourcePixelFormat =3D=3D= dm_rgbe) { - *BytePerPixelDETY =3D 4; - *BytePerPixelDETC =3D 0; - *BytePerPixelY =3D 4; - *BytePerPixelC =3D 0; - } else if (SourcePixelFormat =3D=3D dm_444_16 || SourcePixelFormat =3D=3D= dm_444_16) { - *BytePerPixelDETY =3D 2; - *BytePerPixelDETC =3D 0; - *BytePerPixelY =3D 2; - *BytePerPixelC =3D 0; - } else if (SourcePixelFormat =3D=3D dm_444_8) { - *BytePerPixelDETY =3D 1; - *BytePerPixelDETC =3D 0; - *BytePerPixelY =3D 1; - *BytePerPixelC =3D 0; - } else if (SourcePixelFormat =3D=3D dm_rgbe_alpha) { - *BytePerPixelDETY =3D 4; - *BytePerPixelDETC =3D 1; - *BytePerPixelY =3D 4; - *BytePerPixelC =3D 1; - } else if (SourcePixelFormat =3D=3D dm_420_8) { - *BytePerPixelDETY =3D 1; - *BytePerPixelDETC =3D 2; - *BytePerPixelY =3D 1; - *BytePerPixelC =3D 2; - } else if (SourcePixelFormat =3D=3D dm_420_12) { - *BytePerPixelDETY =3D 2; - *BytePerPixelDETC =3D 4; - *BytePerPixelY =3D 2; - *BytePerPixelC =3D 4; - } else { - *BytePerPixelDETY =3D 4.0 / 3; - *BytePerPixelDETC =3D 8.0 / 3; - *BytePerPixelY =3D 2; - *BytePerPixelC =3D 4; - } - - if ((SourcePixelFormat =3D=3D dm_444_64 || SourcePixelFormat =3D=3D dm_44= 4_32 || SourcePixelFormat =3D=3D dm_444_16 || SourcePixelFormat =3D=3D dm_4= 44_8 || SourcePixelFormat =3D=3D dm_mono_16 - || SourcePixelFormat =3D=3D dm_mono_8 || SourcePixelFormat =3D=3D dm_rg= be)) { - if (SurfaceTiling =3D=3D dm_sw_linear) - *BlockHeight256BytesY =3D 1; - else if (SourcePixelFormat =3D=3D dm_444_64) - *BlockHeight256BytesY =3D 4; - else if (SourcePixelFormat =3D=3D dm_444_8) - *BlockHeight256BytesY =3D 16; - else - *BlockHeight256BytesY =3D 8; - - *BlockWidth256BytesY =3D 256U / *BytePerPixelY / *BlockHeight256BytesY; - *BlockHeight256BytesC =3D 0; - *BlockWidth256BytesC =3D 0; - } else { - if (SurfaceTiling =3D=3D dm_sw_linear) { - *BlockHeight256BytesY =3D 1; - *BlockHeight256BytesC =3D 1; - } else if (SourcePixelFormat =3D=3D dm_rgbe_alpha) { - *BlockHeight256BytesY =3D 8; - *BlockHeight256BytesC =3D 16; - } else if (SourcePixelFormat =3D=3D dm_420_8) { - *BlockHeight256BytesY =3D 16; - *BlockHeight256BytesC =3D 8; - } else { - *BlockHeight256BytesY =3D 8; - *BlockHeight256BytesC =3D 8; - } - *BlockWidth256BytesY =3D 256U / *BytePerPixelY / *BlockHeight256BytesY; - *BlockWidth256BytesC =3D 256U / *BytePerPixelC / *BlockHeight256BytesC; - } - return true; -} +#include "dml/dcn30/display_mode_vba_30.h" =20 static bool is_dual_plane(enum source_format_class source_format) { @@ -468,7 +381,7 @@ static void get_meta_and_pte_attr( double byte_per_pixel_det_y; double byte_per_pixel_det_c; =20 - CalculateBytePerPixelAnd256BBlockSizes( + dml30_CalculateBytePerPixelAnd256BBlockSizes( (enum source_format_class) (source_format), (enum dm_swizzle_mode) (tiling), &bytes_per_element_y, --=20 2.34.1