Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3679648rwd; Mon, 22 May 2023 18:40:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4XYNe7JILsQ+Hmt0FKxDMjS4CkQVLHlkDi/J4pHMJZIxgivquu1S1ArEpj/VzePk3dXURL X-Received: by 2002:a05:6a00:14c4:b0:644:d220:64ac with SMTP id w4-20020a056a0014c400b00644d22064acmr17011102pfu.2.1684806053624; Mon, 22 May 2023 18:40:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684806053; cv=none; d=google.com; s=arc-20160816; b=Le7VZo7nwIhzquilczZypVGAogAu3S6BcGIKIHE5FIOBNGVsA7CE8TPJsqsrwTr1E8 4gSplGappgNttcPJJxSVM/B27q50rRjcx8rHigNXCSvPJo1jLzZceimnsJbA4UqWeSpR oRbF3iyZ5k2QNxLrbkkjFdy6FwsMyD9nADK4UILwY3av22sq8dOWEBXf+1snl8mWVYzi O9mdD+OG95y2M8xyGmC+4NbKMbZOV03N+8WLoV74IJk1P6tkHZZrydNVdY1lq8TX7Qwx oDSPjpkhZPDfZ7oC0oiL6wNTMFrHI2olDjJJrhYT72Thqu/fPWzKdQIRPZRItFK8FEir lyAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=XUZc7JQnN6RD/SnLLsDhKlL79isjK/uJbf01n5mM2us=; b=jyZ3DqxAtkzhoh6kNHQ88XyKJBtOXSWBMX+jG3Q9oe37UhDiWXqgg5bcPbjXb0vctr ivz8kTBp+AJXd6H7alMs4Y+UN85HFv2qeWJE96pqp3pP2dTE6GO3AvPMr31ut4j23H6b DA6P2GxyejysuPfJO7yozi6eruMRQ8+N9EdvKwesVXMhpvgBFs5rGGg7Vd4PKL7LeaNF dnUHtglPUt1BgKvGm73ReFy4XDJgtjZURO9iC8E29ZE7P9RSmwSX479aYDTwZJ9uJe3c Ehk3DsvBF2VuclCWyT1lXNG7OtuOI0V4Pxhr7g4S8kXoAS1szk4/N8AhVtyL1HTTjNNV 50lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=jQHr8xpj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q22-20020aa79616000000b00643b4daa91esi1984394pfg.331.2023.05.22.18.40.40; Mon, 22 May 2023 18:40:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=jQHr8xpj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232642AbjEWBJj (ORCPT + 99 others); Mon, 22 May 2023 21:09:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231720AbjEWBJh (ORCPT ); Mon, 22 May 2023 21:09:37 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE9A7E9; Mon, 22 May 2023 18:09:32 -0700 (PDT) Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34N0TexM016764; Tue, 23 May 2023 01:09:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : date : subject : mime-version : content-type : content-transfer-encoding : message-id : references : in-reply-to : to : cc; s=qcppdkim1; bh=XUZc7JQnN6RD/SnLLsDhKlL79isjK/uJbf01n5mM2us=; b=jQHr8xpjb89kfCVg++hCuXyD710CzLIrJWCNmdMnXu80IwR+aT2JAnaHsdRLbEhQPGPt YPupOLD5uI2Mr1C620tpkx7QJ8lL0q96Tmhn+bX1XznP3z2H/v2AcBtQ7Wonnre6dv3t +6uHlcsDmVovNOrGM0diNrNAjgwrPhsVTw3ii5P/+GgQonTTBlJ1uRkeI9+Hp6+vkiDh Gqs5K1Mwfm+lY3AbxSBNLN5yQiUa6RQtkuMkh1IZktB1W+t7vmaCze9naHUGgOrGA3a/ 7BSS1IWBI8G8LK8gE/IgZm8KkXDuI5IbIkOJYYrxKObwWTrrClFUsmfbltc3Wg6lF3Z+ Rg== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3qracsh3e3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 May 2023 01:09:27 +0000 Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 34N1955S017271 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 May 2023 01:09:05 GMT Received: from jesszhan-linux.qualcomm.com (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Mon, 22 May 2023 18:09:05 -0700 From: Jessica Zhang Date: Mon, 22 May 2023 18:08:56 -0700 Subject: [PATCH v5 2/5] drm/msm/dsi: Adjust pclk rate for compression MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <20230405-add-dsc-support-v5-2-028c10850491@quicinc.com> References: <20230405-add-dsc-support-v5-0-028c10850491@quicinc.com> In-Reply-To: <20230405-add-dsc-support-v5-0-028c10850491@quicinc.com> To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , David Airlie , Daniel Vetter , Marijn Suijten CC: Konrad Dybcio , , , , , Jessica Zhang X-Mailer: b4 0.13-dev-bfdf5 X-Developer-Signature: v=1; a=ed25519-sha256; t=1684804144; l=2483; i=quic_jesszhan@quicinc.com; s=20230329; h=from:subject:message-id; bh=+PWGCHnOt8xcrwyI8eYbnXtnqUPskqBr3FdtKgrONa0=; b=khMn54VJkCmSEcvPmRojkauTVfTyFYz9LGUn2uSvOIO8YjaVQKMvJhbpzbV0TrCDzNNM3hZ2s feWJJUlABjsB5O+C41lMukVmSHa4WJH42qWy5Agzxr+/lsoAMkUMkjl X-Developer-Key: i=quic_jesszhan@quicinc.com; a=ed25519; pk=gAUCgHZ6wTJOzQa3U0GfeCDH7iZLlqIEPo4rrjfDpWE= X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 2IrhBYXKm6SV4D2xbnRCUOtgG_l3q16C X-Proofpoint-ORIG-GUID: 2IrhBYXKm6SV4D2xbnRCUOtgG_l3q16C X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-05-22_18,2023-05-22_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 spamscore=0 malwarescore=0 phishscore=0 impostorscore=0 clxscore=1015 adultscore=0 mlxscore=0 bulkscore=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305230007 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adjust the pclk rate to divide hdisplay by the compression ratio when DSC is enabled. Signed-off-by: Jessica Zhang --- drivers/gpu/drm/msm/dsi/dsi_host.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c index a448931af804..88f370dd2ea1 100644 --- a/drivers/gpu/drm/msm/dsi/dsi_host.c +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c @@ -561,7 +561,18 @@ void dsi_link_clk_disable_v2(struct msm_dsi_host *msm_host) clk_disable_unprepare(msm_host->byte_clk); } -static unsigned long dsi_get_pclk_rate(const struct drm_display_mode *mode, bool is_bonded_dsi) +static unsigned long dsi_adjust_compressed_pclk(const struct drm_display_mode *mode, + const struct drm_dsc_config *dsc) +{ + int new_hdisplay = DIV_ROUND_UP(mode->hdisplay * drm_dsc_get_bpp_int(dsc), + dsc->bits_per_component * 3); + + return (new_hdisplay + (mode->htotal - mode->hdisplay)) + * mode->vtotal * drm_mode_vrefresh(mode); +} + +static unsigned long dsi_get_pclk_rate(const struct drm_display_mode *mode, + const struct drm_dsc_config *dsc, bool is_bonded_dsi) { unsigned long pclk_rate; @@ -576,6 +587,10 @@ static unsigned long dsi_get_pclk_rate(const struct drm_display_mode *mode, bool if (is_bonded_dsi) pclk_rate /= 2; + /* If DSC is enabled, divide hdisplay by compression ratio */ + if (dsc) + pclk_rate = dsi_adjust_compressed_pclk(mode, dsc); + return pclk_rate; } @@ -585,7 +600,7 @@ unsigned long dsi_byte_clk_get_rate(struct mipi_dsi_host *host, bool is_bonded_d struct msm_dsi_host *msm_host = to_msm_dsi_host(host); u8 lanes = msm_host->lanes; u32 bpp = dsi_get_bpp(msm_host->format); - unsigned long pclk_rate = dsi_get_pclk_rate(mode, is_bonded_dsi); + unsigned long pclk_rate = dsi_get_pclk_rate(mode, msm_host->dsc, is_bonded_dsi); unsigned long pclk_bpp; if (lanes == 0) { @@ -604,7 +619,7 @@ unsigned long dsi_byte_clk_get_rate(struct mipi_dsi_host *host, bool is_bonded_d static void dsi_calc_pclk(struct msm_dsi_host *msm_host, bool is_bonded_dsi) { - msm_host->pixel_clk_rate = dsi_get_pclk_rate(msm_host->mode, is_bonded_dsi); + msm_host->pixel_clk_rate = dsi_get_pclk_rate(msm_host->mode, msm_host->dsc, is_bonded_dsi); msm_host->byte_clk_rate = dsi_byte_clk_get_rate(&msm_host->base, is_bonded_dsi, msm_host->mode); -- 2.40.1