From patchwork Wed Feb 13 14:45:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Francis, David" X-Patchwork-Id: 10810071 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6383E6C2 for ; Wed, 13 Feb 2019 14:45:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 505A5285CC for ; Wed, 13 Feb 2019 14:45:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43BAC28981; Wed, 13 Feb 2019 14:45:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8B385285CC for ; Wed, 13 Feb 2019 14:45:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DE3DF89FBC; Wed, 13 Feb 2019 14:45:47 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-eopbgr810073.outbound.protection.outlook.com [40.107.81.73]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5944689F89; Wed, 13 Feb 2019 14:45:46 +0000 (UTC) Received: from BN4PR12CA0007.namprd12.prod.outlook.com (2603:10b6:403:2::17) by DM6PR12MB2969.namprd12.prod.outlook.com (2603:10b6:5:115::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1622.16; Wed, 13 Feb 2019 14:45:44 +0000 Received: from CO1NAM03FT057.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::202) by BN4PR12CA0007.outlook.office365.com (2603:10b6:403:2::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1622.16 via Frontend Transport; Wed, 13 Feb 2019 14:45:44 +0000 Received-SPF: SoftFail (protection.outlook.com: domain of transitioning amd.com discourages use of 165.204.84.17 as permitted sender) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by CO1NAM03FT057.mail.protection.outlook.com (10.152.81.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1580.10 via Frontend Transport; Wed, 13 Feb 2019 14:45:43 +0000 Received: from localhost.localdomain (10.180.168.240) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.389.1; Wed, 13 Feb 2019 08:45:41 -0600 From: David Francis To: Date: Wed, 13 Feb 2019 09:45:34 -0500 Message-ID: <20190213144536.21661-2-David.Francis@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213144536.21661-1-David.Francis@amd.com> References: <20190213144536.21661-1-David.Francis@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(346002)(376002)(39860400002)(136003)(396003)(2980300002)(189003)(199004)(478600001)(50226002)(72206003)(8936002)(6916009)(81156014)(105596002)(1076003)(8676002)(2351001)(49486002)(81166006)(4326008)(86362001)(356004)(6666004)(106466001)(97736004)(76176011)(2906002)(77096007)(305945005)(446003)(476003)(2616005)(126002)(11346002)(53936002)(36756003)(51416003)(486006)(186003)(26005)(30864003)(68736007)(336012)(104016004)(316002)(54906003)(16586007)(50466002)(47776003)(426003)(48376002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB2969; H:SATLEXCHOV01.amd.com; FPR:; SPF:SoftFail; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT057; 1:B9O/fTKk+jNIXODsWEVCrfp6h9OZaXV+3yz80HsmHntDV/3XFvcHT6mFv5aJP+ziZSx7wp+bC2I3AC7Sro6XEMNkyVj/ZC5idaNHf/RtCy9jhqS9I2fugMJRwnAbtke4md+irYhWMAkd7Nb8eapvag== X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f6ff440d-09ab-405c-10d8-08d691c1ee92 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(2017052603328)(7153060); SRVR:DM6PR12MB2969; X-MS-TrafficTypeDiagnostic: DM6PR12MB2969: X-Microsoft-Exchange-Diagnostics: 1; DM6PR12MB2969; 20:etpv3eBlGhLdLJqKjuOuqIx42T5JJQzv0QxpkMEDZNDTQ2sW02e5ysGi8r4Rj/4Ve3gEJ4Kzd9IApCMhkEjZVrXS0WPYig8ZqRmt/TFLVQot7i+Vk5i8DS6g8l271Yes3Qi5sNDZbn2n+df2sY9OUwa0Rsd6SxgJmcp7JgD0V6nEX2bDuxtR4VpCe3kbJJ/cdXP1an1D4VHBnRhRExJDmx+SlgRYOS1YaGHJsaDQZ4CHFOkuZGNglagvZaRDLYzqcY8ECdiXXRlE9adecCoUmhNNGu3xHdg/Tp9knbK97D1JiZYYCGf+jzvByRCx0YRql103JYNmEvWpkOjchzMx+6YgF0Hs5w/oXzs29VDE9SSjIa22DOVLzBsjtUCXyGFxdfp1I6RSbTcLVWpDacdJYdniUI/DGgd9TUa8nHyDYnKaVxI4iMBqihPHMzoQ68VHPpBmtt7KPuwoAbvaV7k+nnJzwODBHeTFx1MlLdK/Nu5wNyKvBIDksEGQhYBAZ8AP X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 094700CA91 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM6PR12MB2969; 23:AoJEKyafiCIMOBXf2JunjQHwA8ail6kKBHOajUFhG?= OTucn94oY7Xy90H3mtOT6l0ev/TsoYbrHp8yMbbJ8FOd7rOXhexW0QU/EFlhzyuuR+1CWlNmwSWKBxUD/eBs1/W5G0zWOdpAPB6ijVd2VuhrDVYp2uhoLmaK6/U3k8399FmWFQqHeQFJg71zE79c6ryoKWTsaemIVJYeghCDZp/TgQq/ZYNUuOsV62BO1fhUMTO6uWfNN5slMuITm2iwaFlzURTVCLX4zj5til9lMqqTg+Rbp8utLSSs7+LHTnX8oB8eRu2+56nZ024CcwcdXaJcfdtZtFLf3uBboNnEU7pOFD9aJ17NWYLUuI5NKQi5Z+IPOlO89gKl/RKBUrciS+8TCBshOhq0+eGluXGxReglcAB1uKFLSStNd72IA1JToCIXC5KB9JWpWaKx4Roob1Y4BEMFqR0sV9K73c87CJ0AY32igLNI043DGBVwxFIPZ/RrdF31jWKVyjlE1PBaDIgD+qNxheW3L9IYx8bBzLFZB4bpEiCt3iOjURPtJ5TZKLrVudG/I8l3ImnSKLtpi5Q4zy68s9ubZ/e7a8qtDtFv+j+c+FYLbBoFS9y8aDcGrU01QcZkltqmtmDjdasCDEclQti1heVJlWGzGfJlzRrvyZ//V9tTLE43Bj66ActmOrn5xvLntfTGq4YtNcbxI0h9WD70ju5dcd3VUrgup5hcp39balUDrwvtTZY2AC7T705yVAs2XFuI6GzumYarE6jLQ1wJgiLRfScJurN5QjJFkp8YahMfQRr8SfxRiCbPntdTYZ6aRmUhgx6zISvVTdG/XkHE9FjhXoy2VeCce2w/BCveBdLaAVtneHjeQ7+Uv7oC9I9qr4VH1YdfnS2OsumiKqZZ0lcQxYDaQHR5Oq7BYC/GeGoeHHTD+irzGGF3V1OLZDUqiTIr28y1ucukW5webI0933nqUHYQIy8f8894ahRZoqa1zUuWfg2Cb30LnnvRzIwjTyE7Niq7GNz8eTQkZ8zActZ3wm7LkZJ9z5yGodQP/6EEw2Qy78JXfvZ+K91uI+u9w4cnp9MKRmmM/8Fcv1Hwo5MFc0jr8MO42+fwJfv4rfLyaHdqemtwb7A9thaoX9NGteTQhewJAhSzbyy X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: dCMxv6WLqAg6XdCI7fNpcFwrA6K5jVLRAGiP+Xjq0M8ip4Pf+sQbtgckEcG5Oiz1+t/bhKtNQ43VyrJrBPd9upW3sk5klP3J3O4b5TUB0Gtz9HBKUoqrUBa+4W31Gk22XyPHN8V1z2Q2UL3zfJ8X47UFbc+L7IZq+UhfYLsdafVteE0pM2na+jB4Z0UELlAH4BGJo4VUt84/y7/8ZZ0n7fotXMLikC+GXm8efOgoFq+Wci0fI6hRUDkdD7Cq/WKEjiTqWC5IW28W8ctK+w6DR4RKwjgRsJornPsAl90YItWVH0EevtBm4g7upDKPDheMRa6mt+/LjsWomlXnMOceZt+TDJYsIRe4ZHVixdQJ3aTq+18WpY2P0iydsS82WV2P40JGftsTnE6wlRe/SpZJoRsQJwE6ArV4wv1BVxS5hso= X-Microsoft-Exchange-Diagnostics: 1; DM6PR12MB2969; 20:r6tIybALbaN6HvlSAxkuLPQ+kOnwMkQ9xgig9mpokaDLkuKfwMgio1jIc0UdBAJrKWE1Zbw09njM1KLkk8Kslp3K2cag9CoxRtk7UknOwv4J2WUEzLivWAb3xQ+H8A5CIGnOfVCukiv2HdGl8SP8BzWSivZX671wAVdGYinvBCcrD7sjB4paO7MAHlZyHudhvbERHgyO8LWa/2Je6jtDKalVPUIazaWNWYz2RUa4SsU80BUXeil6tkzU116ohyZ4 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2019 14:45:43.3867 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f6ff440d-09ab-405c-10d8-08d691c1ee92 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2969 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Z4f2j3Vdw27gcxwfvJh2PhwMcsnX+sXwzv/Qpszodh8=; b=S1sujK1GKzNxCXli05APEMk+u6womwG7vhjro3i0ey07vOsQpGzomnOFWAfut9KFHRaeVW57TrdtW4D1C+4xvJyfsYDmIUp7DD/S8dPNLfyRpF6k/Pp1aa1sxZyI9Rg4Db+07NZy24K3P3dLkaRy1UGntQHxhdysTwPoizonYjU= X-Mailman-Original-Authentication-Results: spf=softfail (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=permerror action=none header.from=amd.com; Subject: [Intel-gfx] [PATCH 1/3] drm/i915: Move dsc rate params compute into drm X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, nikola.cornij@amd.com, harry.wentland@amd.com, David Francis Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP The function intel_compute_rc_parameters is part of the dsc spec and is not driver-specific. Other drm drivers might like to use it. The function is not changed; just moved and renamed. Signed-off-by: David Francis Reviewed-by: Harry Wentland --- drivers/gpu/drm/drm_dsc.c | 133 ++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_vdsc.c | 125 +--------------------------- include/drm/drm_dsc.h | 1 + 3 files changed, 135 insertions(+), 124 deletions(-) diff --git a/drivers/gpu/drm/drm_dsc.c b/drivers/gpu/drm/drm_dsc.c index bc2b23adb072..4b0e3c9c3ff8 100644 --- a/drivers/gpu/drm/drm_dsc.c +++ b/drivers/gpu/drm/drm_dsc.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -226,3 +227,135 @@ void drm_dsc_pps_infoframe_pack(struct drm_dsc_pps_infoframe *pps_sdp, /* PPS 94 - 127 are O */ } EXPORT_SYMBOL(drm_dsc_pps_infoframe_pack); + +/** + * drm_dsc_compute_rc_parameters() - Write rate control + * parameters to the dsc configuration. Some configuration + * fields must be present beforehand. + * + * @dsc_cfg: + * DSC Configuration data partially filled by driver + */ +int drm_dsc_compute_rc_parameters(struct drm_dsc_config *vdsc_cfg) +{ + unsigned long groups_per_line = 0; + unsigned long groups_total = 0; + unsigned long num_extra_mux_bits = 0; + unsigned long slice_bits = 0; + unsigned long hrd_delay = 0; + unsigned long final_scale = 0; + unsigned long rbs_min = 0; + + /* Number of groups used to code each line of a slice */ + groups_per_line = DIV_ROUND_UP(vdsc_cfg->slice_width, + DSC_RC_PIXELS_PER_GROUP); + + /* chunksize in Bytes */ + vdsc_cfg->slice_chunk_size = DIV_ROUND_UP(vdsc_cfg->slice_width * + vdsc_cfg->bits_per_pixel, + (8 * 16)); + + if (vdsc_cfg->convert_rgb) + num_extra_mux_bits = 3 * (vdsc_cfg->mux_word_size + + (4 * vdsc_cfg->bits_per_component + 4) + - 2); + else + num_extra_mux_bits = 3 * vdsc_cfg->mux_word_size + + (4 * vdsc_cfg->bits_per_component + 4) + + 2 * (4 * vdsc_cfg->bits_per_component) - 2; + /* Number of bits in one Slice */ + slice_bits = 8 * vdsc_cfg->slice_chunk_size * vdsc_cfg->slice_height; + + while ((num_extra_mux_bits > 0) && + ((slice_bits - num_extra_mux_bits) % vdsc_cfg->mux_word_size)) + num_extra_mux_bits--; + + if (groups_per_line < vdsc_cfg->initial_scale_value - 8) + vdsc_cfg->initial_scale_value = groups_per_line + 8; + + /* scale_decrement_interval calculation according to DSC spec 1.11 */ + if (vdsc_cfg->initial_scale_value > 8) + vdsc_cfg->scale_decrement_interval = groups_per_line / + (vdsc_cfg->initial_scale_value - 8); + else + vdsc_cfg->scale_decrement_interval = DSC_SCALE_DECREMENT_INTERVAL_MAX; + + vdsc_cfg->final_offset = vdsc_cfg->rc_model_size - + (vdsc_cfg->initial_xmit_delay * + vdsc_cfg->bits_per_pixel + 8) / 16 + num_extra_mux_bits; + + if (vdsc_cfg->final_offset >= vdsc_cfg->rc_model_size) { + DRM_DEBUG_KMS("FinalOfs < RcModelSze for this InitialXmitDelay\n"); + return -ERANGE; + } + + final_scale = (vdsc_cfg->rc_model_size * 8) / + (vdsc_cfg->rc_model_size - vdsc_cfg->final_offset); + if (vdsc_cfg->slice_height > 1) + /* + * NflBpgOffset is 16 bit value with 11 fractional bits + * hence we multiply by 2^11 for preserving the + * fractional part + */ + vdsc_cfg->nfl_bpg_offset = DIV_ROUND_UP((vdsc_cfg->first_line_bpg_offset << 11), + (vdsc_cfg->slice_height - 1)); + else + vdsc_cfg->nfl_bpg_offset = 0; + + /* 2^16 - 1 */ + if (vdsc_cfg->nfl_bpg_offset > 65535) { + DRM_DEBUG_KMS("NflBpgOffset is too large for this slice height\n"); + return -ERANGE; + } + + /* Number of groups used to code the entire slice */ + groups_total = groups_per_line * vdsc_cfg->slice_height; + + /* slice_bpg_offset is 16 bit value with 11 fractional bits */ + vdsc_cfg->slice_bpg_offset = DIV_ROUND_UP(((vdsc_cfg->rc_model_size - + vdsc_cfg->initial_offset + + num_extra_mux_bits) << 11), + groups_total); + + if (final_scale > 9) { + /* + * ScaleIncrementInterval = + * finaloffset/((NflBpgOffset + SliceBpgOffset)*8(finalscale - 1.125)) + * as (NflBpgOffset + SliceBpgOffset) has 11 bit fractional value, + * we need divide by 2^11 from pstDscCfg values + */ + vdsc_cfg->scale_increment_interval = + (vdsc_cfg->final_offset * (1 << 11)) / + ((vdsc_cfg->nfl_bpg_offset + + vdsc_cfg->slice_bpg_offset) * + (final_scale - 9)); + } else { + /* + * If finalScaleValue is less than or equal to 9, a value of 0 should + * be used to disable the scale increment at the end of the slice + */ + vdsc_cfg->scale_increment_interval = 0; + } + + if (vdsc_cfg->scale_increment_interval > 65535) { + DRM_DEBUG_KMS("ScaleIncrementInterval is large for slice height\n"); + return -ERANGE; + } + + /* + * DSC spec mentions that bits_per_pixel specifies the target + * bits/pixel (bpp) rate that is used by the encoder, + * in steps of 1/16 of a bit per pixel + */ + rbs_min = vdsc_cfg->rc_model_size - vdsc_cfg->initial_offset + + DIV_ROUND_UP(vdsc_cfg->initial_xmit_delay * + vdsc_cfg->bits_per_pixel, 16) + + groups_per_line * vdsc_cfg->first_line_bpg_offset; + + hrd_delay = DIV_ROUND_UP((rbs_min * 16), vdsc_cfg->bits_per_pixel); + vdsc_cfg->rc_bits = (hrd_delay * vdsc_cfg->bits_per_pixel) / 16; + vdsc_cfg->initial_dec_delay = hrd_delay - vdsc_cfg->initial_xmit_delay; + + return 0; +} +EXPORT_SYMBOL(drm_dsc_compute_rc_parameters); diff --git a/drivers/gpu/drm/i915/intel_vdsc.c b/drivers/gpu/drm/i915/intel_vdsc.c index c56ba0e04044..c76cec8bfb74 100644 --- a/drivers/gpu/drm/i915/intel_vdsc.c +++ b/drivers/gpu/drm/i915/intel_vdsc.c @@ -318,129 +318,6 @@ static int get_column_index_for_rc_params(u8 bits_per_component) } } -static int intel_compute_rc_parameters(struct drm_dsc_config *vdsc_cfg) -{ - unsigned long groups_per_line = 0; - unsigned long groups_total = 0; - unsigned long num_extra_mux_bits = 0; - unsigned long slice_bits = 0; - unsigned long hrd_delay = 0; - unsigned long final_scale = 0; - unsigned long rbs_min = 0; - - /* Number of groups used to code each line of a slice */ - groups_per_line = DIV_ROUND_UP(vdsc_cfg->slice_width, - DSC_RC_PIXELS_PER_GROUP); - - /* chunksize in Bytes */ - vdsc_cfg->slice_chunk_size = DIV_ROUND_UP(vdsc_cfg->slice_width * - vdsc_cfg->bits_per_pixel, - (8 * 16)); - - if (vdsc_cfg->convert_rgb) - num_extra_mux_bits = 3 * (vdsc_cfg->mux_word_size + - (4 * vdsc_cfg->bits_per_component + 4) - - 2); - else - num_extra_mux_bits = 3 * vdsc_cfg->mux_word_size + - (4 * vdsc_cfg->bits_per_component + 4) + - 2 * (4 * vdsc_cfg->bits_per_component) - 2; - /* Number of bits in one Slice */ - slice_bits = 8 * vdsc_cfg->slice_chunk_size * vdsc_cfg->slice_height; - - while ((num_extra_mux_bits > 0) && - ((slice_bits - num_extra_mux_bits) % vdsc_cfg->mux_word_size)) - num_extra_mux_bits--; - - if (groups_per_line < vdsc_cfg->initial_scale_value - 8) - vdsc_cfg->initial_scale_value = groups_per_line + 8; - - /* scale_decrement_interval calculation according to DSC spec 1.11 */ - if (vdsc_cfg->initial_scale_value > 8) - vdsc_cfg->scale_decrement_interval = groups_per_line / - (vdsc_cfg->initial_scale_value - 8); - else - vdsc_cfg->scale_decrement_interval = DSC_SCALE_DECREMENT_INTERVAL_MAX; - - vdsc_cfg->final_offset = vdsc_cfg->rc_model_size - - (vdsc_cfg->initial_xmit_delay * - vdsc_cfg->bits_per_pixel + 8) / 16 + num_extra_mux_bits; - - if (vdsc_cfg->final_offset >= vdsc_cfg->rc_model_size) { - DRM_DEBUG_KMS("FinalOfs < RcModelSze for this InitialXmitDelay\n"); - return -ERANGE; - } - - final_scale = (vdsc_cfg->rc_model_size * 8) / - (vdsc_cfg->rc_model_size - vdsc_cfg->final_offset); - if (vdsc_cfg->slice_height > 1) - /* - * NflBpgOffset is 16 bit value with 11 fractional bits - * hence we multiply by 2^11 for preserving the - * fractional part - */ - vdsc_cfg->nfl_bpg_offset = DIV_ROUND_UP((vdsc_cfg->first_line_bpg_offset << 11), - (vdsc_cfg->slice_height - 1)); - else - vdsc_cfg->nfl_bpg_offset = 0; - - /* 2^16 - 1 */ - if (vdsc_cfg->nfl_bpg_offset > 65535) { - DRM_DEBUG_KMS("NflBpgOffset is too large for this slice height\n"); - return -ERANGE; - } - - /* Number of groups used to code the entire slice */ - groups_total = groups_per_line * vdsc_cfg->slice_height; - - /* slice_bpg_offset is 16 bit value with 11 fractional bits */ - vdsc_cfg->slice_bpg_offset = DIV_ROUND_UP(((vdsc_cfg->rc_model_size - - vdsc_cfg->initial_offset + - num_extra_mux_bits) << 11), - groups_total); - - if (final_scale > 9) { - /* - * ScaleIncrementInterval = - * finaloffset/((NflBpgOffset + SliceBpgOffset)*8(finalscale - 1.125)) - * as (NflBpgOffset + SliceBpgOffset) has 11 bit fractional value, - * we need divide by 2^11 from pstDscCfg values - */ - vdsc_cfg->scale_increment_interval = - (vdsc_cfg->final_offset * (1 << 11)) / - ((vdsc_cfg->nfl_bpg_offset + - vdsc_cfg->slice_bpg_offset) * - (final_scale - 9)); - } else { - /* - * If finalScaleValue is less than or equal to 9, a value of 0 should - * be used to disable the scale increment at the end of the slice - */ - vdsc_cfg->scale_increment_interval = 0; - } - - if (vdsc_cfg->scale_increment_interval > 65535) { - DRM_DEBUG_KMS("ScaleIncrementInterval is large for slice height\n"); - return -ERANGE; - } - - /* - * DSC spec mentions that bits_per_pixel specifies the target - * bits/pixel (bpp) rate that is used by the encoder, - * in steps of 1/16 of a bit per pixel - */ - rbs_min = vdsc_cfg->rc_model_size - vdsc_cfg->initial_offset + - DIV_ROUND_UP(vdsc_cfg->initial_xmit_delay * - vdsc_cfg->bits_per_pixel, 16) + - groups_per_line * vdsc_cfg->first_line_bpg_offset; - - hrd_delay = DIV_ROUND_UP((rbs_min * 16), vdsc_cfg->bits_per_pixel); - vdsc_cfg->rc_bits = (hrd_delay * vdsc_cfg->bits_per_pixel) / 16; - vdsc_cfg->initial_dec_delay = hrd_delay - vdsc_cfg->initial_xmit_delay; - - return 0; -} - int intel_dp_compute_dsc_params(struct intel_dp *intel_dp, struct intel_crtc_state *pipe_config) { @@ -575,7 +452,7 @@ int intel_dp_compute_dsc_params(struct intel_dp *intel_dp, vdsc_cfg->initial_scale_value = (vdsc_cfg->rc_model_size << 3) / (vdsc_cfg->rc_model_size - vdsc_cfg->initial_offset); - return intel_compute_rc_parameters(vdsc_cfg); + return drm_dsc_compute_rc_parameters(vdsc_cfg); } enum intel_display_power_domain diff --git a/include/drm/drm_dsc.h b/include/drm/drm_dsc.h index d03f1b83421a..ad43494f1cc8 100644 --- a/include/drm/drm_dsc.h +++ b/include/drm/drm_dsc.h @@ -481,5 +481,6 @@ struct drm_dsc_pps_infoframe { void drm_dsc_dp_pps_header_init(struct drm_dsc_pps_infoframe *pps_sdp); void drm_dsc_pps_infoframe_pack(struct drm_dsc_pps_infoframe *pps_sdp, const struct drm_dsc_config *dsc_cfg); +int drm_dsc_compute_rc_parameters(struct drm_dsc_config *vdsc_cfg); #endif /* _DRM_DSC_H_ */