Message ID | 20231114225857.19702-2-jonathan@marek.ca |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:a59:b0:164:83eb:24d7 with SMTP id 25csp2254984rwb; Tue, 14 Nov 2023 15:01:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFqwqIK6B0fFzDcvAodOG75yMNFJSqmU/i1Js2PvHRboJI1r8YXZzAngXES6taIlhnITKfv X-Received: by 2002:a05:6871:3786:b0:1e9:64f1:9c30 with SMTP id nq6-20020a056871378600b001e964f19c30mr12922187oac.18.1700002886095; Tue, 14 Nov 2023 15:01:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700002886; cv=none; d=google.com; s=arc-20160816; b=vtz0JZQYlijCIjqfAqfWbJD61T3qc+XyzE+Q917BX4Gm4IUcbiDmUP1hi/T+wAFNY5 49S8JXC0U8kRQKeyUGqvcJVM6BpLg3UlazbC/gTStex4BErakuzwnw05nOefHqthRG0G Uv//5hYWY5ZjhSvHjg/x1tudBZn+gLiYr74HETTqnp/yIXB6dD+T5U8WhKer4J6gN7k1 n3crDIgoaRYsHOXZRrCJGfJUakBFyCz77ybgu/gxFK0kjn7wU2JcXe/uQWRBSsoO0ecc Rw4ZT7V9vAW4LMEB7qMCaEZ1PUwC5bj1Xl8dpPCDiWGIQm5rA46iok8BpaFfkuZeD/W8 EDgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HCsm7VCedF16OrkkHsKZ3GlEGsmWacvBMw8jR+/V2pU=; fh=WCIgNCBhnJ/TxrIq60Z0fQX2r4KhuKDT6zoPysYcy7c=; b=AlG9+Sg8DONOFDNP6s8JexnvvK6bYa8O33qIkg1qCDit3tCeBb/1YWS50J+BRl28W9 l+hGfQY4amEeA4F1oFU0KHb4NBlRgK66zRuJDSuQ2QWYdsbzPWKLoNxvvN1MNNuCyzNN Nxb1BDJETKLJx7wsHz4iXb/tRmb+kzUB7FRCKUbQkZAaHeobxQ1g0CF9+GdWjP7w9fqJ GchYUlmviib3GgJwa9WSQgsOgyMmP+8UAFktv7OKJPxjHrwZeZibRwLdVkO6oNAinydL PIGLlen1RM3SmnLYMwtpGWZ9vCuufeAj6ZR1cyfRHgyfJcICbebTtoU41mYj8QP9oWpN K7Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marek.ca header.s=google header.b="I/lWWWwA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id mm24-20020a0568700e9800b001e107019f92si3179392oab.123.2023.11.14.15.01.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 15:01:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@marek.ca header.s=google header.b="I/lWWWwA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id C32DC808E56B; Tue, 14 Nov 2023 15:01:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234112AbjKNXAg (ORCPT <rfc822;lhua1029@gmail.com> + 29 others); Tue, 14 Nov 2023 18:00:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233920AbjKNXAd (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 14 Nov 2023 18:00:33 -0500 Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D07CDB for <linux-kernel@vger.kernel.org>; Tue, 14 Nov 2023 15:00:28 -0800 (PST) Received: by mail-qv1-xf34.google.com with SMTP id 6a1803df08f44-66d122e0c85so35843386d6.3 for <linux-kernel@vger.kernel.org>; Tue, 14 Nov 2023 15:00:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marek.ca; s=google; t=1700002827; x=1700607627; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HCsm7VCedF16OrkkHsKZ3GlEGsmWacvBMw8jR+/V2pU=; b=I/lWWWwAR4elrbtN89w7VqSMtCkx3kQYTC+bfalx4c+YY+iwWL2T0ADaN08nPgTgqY 4+s7gCEZaWk/OJLv7FJmQun+M3KycBI7DWNREapELvaX8098ckeAjlO5VG8bwo6Vi0yQ 4mXhZCYalsBg98MQF7R0bzADg7NZm49v/aLJPaceqm9PUMX4eOM0V9Z0IPiNY51kbQcJ QtyM1kXh91majHRz67vX1YH+UmPTb7gtpuxsb4p5g6HL91prNeglhu5RMvSx6TukXtcI kfjMGT3kyHig/G4toLn+Jh8Zc15ulufkbbxIr3wpKcKe/l3CRJCSbj9lP94sIkTCqMcI yNFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700002827; x=1700607627; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HCsm7VCedF16OrkkHsKZ3GlEGsmWacvBMw8jR+/V2pU=; b=qZoWCSWHOuKzxsfo3k0Kozw4BbB0ih4MSF7OHoVhep1o+Z+vWx9e1K6BOPIo3dZTf5 M42osKyqpR3bOOKWrBZPiNoIgRLYuKVXiPYfkIE947FBprA7y+7mE4VxFi/+E9vQyT0j ZWopjAqzot/HILTmKPSWqBWvA3iTh3tmEdeYXa92h8bBCZWOjzrC/7ThB6zLoPno0K1H mkGbDHoMWbYTOfljjeFlAt5nXpu+WnFYvN1zmUKwJcvlnRUpHslb+vJiL17whcIQFAuB nqq660hF2fFUYHd8/pn4Dzp+Z40W0/wL7ewmFD6quYBH5PMqfLnXZRCV3z9pZdVvt7io uu0Q== X-Gm-Message-State: AOJu0Yyhyh964fQhQsQYPzuVnPOML1xnak7ZJS+VF88+FUHASPexeY9S ejYjUIzZX/CA0ofg89dxi4qH1g== X-Received: by 2002:a0c:be88:0:b0:677:9fb2:26e9 with SMTP id n8-20020a0cbe88000000b006779fb226e9mr3489562qvi.14.1700002827707; Tue, 14 Nov 2023 15:00:27 -0800 (PST) Received: from localhost.localdomain (modemcable125.110-19-135.mc.videotron.ca. [135.19.110.125]) by smtp.gmail.com with ESMTPSA id u2-20020a05621411a200b00674a45499dcsm25274qvv.88.2023.11.14.15.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 15:00:27 -0800 (PST) From: Jonathan Marek <jonathan@marek.ca> To: freedreno@lists.freedesktop.org Cc: Rob Clark <robdclark@gmail.com>, Abhinav Kumar <quic_abhinavk@quicinc.com>, Dmitry Baryshkov <dmitry.baryshkov@linaro.org>, Sean Paul <sean@poorly.run>, Marijn Suijten <marijn.suijten@somainline.org>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, Kuogee Hsieh <quic_khsieh@quicinc.com>, Jessica Zhang <quic_jesszhan@quicinc.com>, Vinod Polimera <quic_vpolimer@quicinc.com>, Kalyan Thota <quic_kalyant@quicinc.com>, Konrad Dybcio <konrad.dybcio@linaro.org>, Arnaud Vrac <rawoul@gmail.com>, linux-arm-msm@vger.kernel.org (open list:DRM DRIVER FOR MSM ADRENO GPU), dri-devel@lists.freedesktop.org (open list:DRM DRIVER FOR MSM ADRENO GPU), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 1/6] drm/msm/dpu: fix video mode DSC for DSI Date: Tue, 14 Nov 2023 17:58:29 -0500 Message-Id: <20231114225857.19702-2-jonathan@marek.ca> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20231114225857.19702-1-jonathan@marek.ca> References: <20231114225857.19702-1-jonathan@marek.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 14 Nov 2023 15:01:03 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782582226306616461 X-GMAIL-MSGID: 1782582226306616461 |
Series |
drm/msm: DSI DSC video mode fixes
|
|
Commit Message
Jonathan Marek
Nov. 14, 2023, 10:58 p.m. UTC
Add necessary DPU changes for DSC to work with DSI video mode.
Note this changes the logic to enable HCTL to match downstream, it will
now be enabled for the no-DSC no-widebus case.
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
---
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 2 +-
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h | 2 +-
.../gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 11 +++++++++++
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c | 13 ++++++++++++-
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h | 1 +
5 files changed, 26 insertions(+), 3 deletions(-)
Comments
On Wed, 15 Nov 2023 at 01:00, Jonathan Marek <jonathan@marek.ca> wrote: > > Add necessary DPU changes for DSC to work with DSI video mode. > > Note this changes the logic to enable HCTL to match downstream, it will > now be enabled for the no-DSC no-widebus case. > > Signed-off-by: Jonathan Marek <jonathan@marek.ca> > --- > drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 2 +- > drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h | 2 +- > .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 11 +++++++++++ > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c | 13 ++++++++++++- > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h | 1 + > 5 files changed, 26 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c > index 1cf7ff6caff4..d745c8678b9d 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c > @@ -2477,7 +2477,7 @@ enum dpu_intf_mode dpu_encoder_get_intf_mode(struct drm_encoder *encoder) > return INTF_MODE_NONE; > } > > -unsigned int dpu_encoder_helper_get_dsc(struct dpu_encoder_phys *phys_enc) > +unsigned int dpu_encoder_helper_get_dsc(const struct dpu_encoder_phys *phys_enc) Why? > { > struct drm_encoder *encoder = phys_enc->parent; > struct dpu_encoder_virt *dpu_enc = to_dpu_encoder_virt(encoder); > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h > index 6f04c3d56e77..7e27a7da0887 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h > @@ -332,7 +332,7 @@ static inline enum dpu_3d_blend_mode dpu_encoder_helper_get_3d_blend_mode( > * used for this encoder. > * @phys_enc: Pointer to physical encoder structure > */ > -unsigned int dpu_encoder_helper_get_dsc(struct dpu_encoder_phys *phys_enc); > +unsigned int dpu_encoder_helper_get_dsc(const struct dpu_encoder_phys *phys_enc); > > /** > * dpu_encoder_helper_split_config - split display configuration helper function > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c > index a01fda711883..df10800a9615 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c > @@ -100,6 +100,8 @@ static void drm_mode_to_intf_timing_params( > } > > timing->wide_bus_en = dpu_encoder_is_widebus_enabled(phys_enc->parent); > + if (dpu_encoder_helper_get_dsc(phys_enc)) > + timing->compression_en = true; > > /* > * for DP, divide the horizonal parameters by 2 when > @@ -112,6 +114,15 @@ static void drm_mode_to_intf_timing_params( > timing->h_front_porch = timing->h_front_porch >> 1; > timing->hsync_pulse_width = timing->hsync_pulse_width >> 1; > } > + > + /* > + * for DSI, if compression is enabled, then divide the horizonal active > + * timing parameters by compression ratio. > + */ > + if (phys_enc->hw_intf->cap->type != INTF_DP && timing->compression_en) { > + timing->width = timing->width / 3; /* XXX: don't assume 3:1 compression ratio */ Is this /3 from bpp / compressed_bpp? > + timing->xres = timing->width; > + } > } > > static u32 get_horizontal_total(const struct dpu_hw_intf_timing_params *timing) > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c > index e8b8908d3e12..d6fe45a6da2d 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c > @@ -166,10 +166,21 @@ static void dpu_hw_intf_setup_timing_engine(struct dpu_hw_intf *ctx, > * video timing. It is recommended to enable it for all cases, except > * if compression is enabled in 1 pixel per clock mode > */ > + if (!p->compression_en || p->wide_bus_en) > + intf_cfg2 |= INTF_CFG2_DATA_HCTL_EN; > + > if (p->wide_bus_en) > - intf_cfg2 |= INTF_CFG2_DATABUS_WIDEN | INTF_CFG2_DATA_HCTL_EN; > + intf_cfg2 |= INTF_CFG2_DATABUS_WIDEN; > > data_width = p->width; > + if (p->wide_bus_en && !dp_intf) > + data_width = p->width >> 1; > + > + if (p->compression_en) > + intf_cfg2 |= INTF_CFG2_DCE_DATA_COMPRESS; > + > + if (p->compression_en && dp_intf) > + DPU_ERROR("missing adjustments for DSC+DP\n"); > > hsync_data_start_x = hsync_start_x; > hsync_data_end_x = hsync_start_x + data_width - 1; This should go into a separate commit with the proper justification. > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h > index c539025c418b..15a5fdadd0a0 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h > @@ -33,6 +33,7 @@ struct dpu_hw_intf_timing_params { > u32 hsync_skew; > > bool wide_bus_en; > + bool compression_en; > }; > > struct dpu_hw_intf_prog_fetch { > -- > 2.26.1 >
On 11/15/23 3:53 AM, Dmitry Baryshkov wrote: > On Wed, 15 Nov 2023 at 01:00, Jonathan Marek <jonathan@marek.ca> wrote: >> >> Add necessary DPU changes for DSC to work with DSI video mode. >> >> Note this changes the logic to enable HCTL to match downstream, it will >> now be enabled for the no-DSC no-widebus case. >> >> Signed-off-by: Jonathan Marek <jonathan@marek.ca> >> --- >> drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 2 +- >> drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h | 2 +- >> .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 11 +++++++++++ >> drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c | 13 ++++++++++++- >> drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h | 1 + >> 5 files changed, 26 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c >> index 1cf7ff6caff4..d745c8678b9d 100644 >> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c >> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c >> @@ -2477,7 +2477,7 @@ enum dpu_intf_mode dpu_encoder_get_intf_mode(struct drm_encoder *encoder) >> return INTF_MODE_NONE; >> } >> >> -unsigned int dpu_encoder_helper_get_dsc(struct dpu_encoder_phys *phys_enc) >> +unsigned int dpu_encoder_helper_get_dsc(const struct dpu_encoder_phys *phys_enc) > > Why? > drm_mode_to_intf_timing_params has "phys_enc" pointer declared as const, so one of them needs to change to call dpu_encoder_helper_get_dsc >> { >> struct drm_encoder *encoder = phys_enc->parent; >> struct dpu_encoder_virt *dpu_enc = to_dpu_encoder_virt(encoder); >> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h >> index 6f04c3d56e77..7e27a7da0887 100644 >> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h >> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h >> @@ -332,7 +332,7 @@ static inline enum dpu_3d_blend_mode dpu_encoder_helper_get_3d_blend_mode( >> * used for this encoder. >> * @phys_enc: Pointer to physical encoder structure >> */ >> -unsigned int dpu_encoder_helper_get_dsc(struct dpu_encoder_phys *phys_enc); >> +unsigned int dpu_encoder_helper_get_dsc(const struct dpu_encoder_phys *phys_enc); >> >> /** >> * dpu_encoder_helper_split_config - split display configuration helper function >> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c >> index a01fda711883..df10800a9615 100644 >> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c >> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c >> @@ -100,6 +100,8 @@ static void drm_mode_to_intf_timing_params( >> } >> >> timing->wide_bus_en = dpu_encoder_is_widebus_enabled(phys_enc->parent); >> + if (dpu_encoder_helper_get_dsc(phys_enc)) >> + timing->compression_en = true; >> >> /* >> * for DP, divide the horizonal parameters by 2 when >> @@ -112,6 +114,15 @@ static void drm_mode_to_intf_timing_params( >> timing->h_front_porch = timing->h_front_porch >> 1; >> timing->hsync_pulse_width = timing->hsync_pulse_width >> 1; >> } >> + >> + /* >> + * for DSI, if compression is enabled, then divide the horizonal active >> + * timing parameters by compression ratio. >> + */ >> + if (phys_enc->hw_intf->cap->type != INTF_DP && timing->compression_en) { >> + timing->width = timing->width / 3; /* XXX: don't assume 3:1 compression ratio */ > > Is this /3 from bpp / compressed_bpp? > It is the compression ratio of DSC for 8bpc (24bpp) compressed to 8bpp. DSI driver doesn't support any other cases so this assumption should be OK for now (the other common ratio is 3.75 for 10bpc compressed to 8bpp - from downstream driver it appears this would mean a division by 3.75 here). >> + timing->xres = timing->width; >> + } >> } >> >> static u32 get_horizontal_total(const struct dpu_hw_intf_timing_params *timing) >> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c >> index e8b8908d3e12..d6fe45a6da2d 100644 >> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c >> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c >> @@ -166,10 +166,21 @@ static void dpu_hw_intf_setup_timing_engine(struct dpu_hw_intf *ctx, >> * video timing. It is recommended to enable it for all cases, except >> * if compression is enabled in 1 pixel per clock mode >> */ >> + if (!p->compression_en || p->wide_bus_en) >> + intf_cfg2 |= INTF_CFG2_DATA_HCTL_EN; >> + >> if (p->wide_bus_en) >> - intf_cfg2 |= INTF_CFG2_DATABUS_WIDEN | INTF_CFG2_DATA_HCTL_EN; >> + intf_cfg2 |= INTF_CFG2_DATABUS_WIDEN; >> >> data_width = p->width; >> + if (p->wide_bus_en && !dp_intf) >> + data_width = p->width >> 1; >> + >> + if (p->compression_en) >> + intf_cfg2 |= INTF_CFG2_DCE_DATA_COMPRESS; >> + >> + if (p->compression_en && dp_intf) >> + DPU_ERROR("missing adjustments for DSC+DP\n"); >> >> hsync_data_start_x = hsync_start_x; >> hsync_data_end_x = hsync_start_x + data_width - 1; > > This should go into a separate commit with the proper justification. > All of it? setting the INTF_CFG2_DCE_DATA_COMPRESS flag at least doesn't make sense to make a separate patch. And DSI widebus is only used with DSC (and always used when available), so IMO also in the scope of this commit. >> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h >> index c539025c418b..15a5fdadd0a0 100644 >> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h >> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h >> @@ -33,6 +33,7 @@ struct dpu_hw_intf_timing_params { >> u32 hsync_skew; >> >> bool wide_bus_en; >> + bool compression_en; >> }; >> >> struct dpu_hw_intf_prog_fetch { >> -- >> 2.26.1 >> > >
On 16/11/2023 20:30, Jonathan Marek wrote: > On 11/15/23 3:53 AM, Dmitry Baryshkov wrote: >> On Wed, 15 Nov 2023 at 01:00, Jonathan Marek <jonathan@marek.ca> wrote: >>> >>> Add necessary DPU changes for DSC to work with DSI video mode. >>> >>> Note this changes the logic to enable HCTL to match downstream, it will >>> now be enabled for the no-DSC no-widebus case. >>> >>> Signed-off-by: Jonathan Marek <jonathan@marek.ca> >>> --- >>> drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 2 +- >>> drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h | 2 +- >>> .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 11 +++++++++++ >>> drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c | 13 ++++++++++++- >>> drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h | 1 + >>> 5 files changed, 26 insertions(+), 3 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c >>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c >>> index 1cf7ff6caff4..d745c8678b9d 100644 >>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c >>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c >>> @@ -2477,7 +2477,7 @@ enum dpu_intf_mode >>> dpu_encoder_get_intf_mode(struct drm_encoder *encoder) >>> return INTF_MODE_NONE; >>> } >>> >>> -unsigned int dpu_encoder_helper_get_dsc(struct dpu_encoder_phys >>> *phys_enc) >>> +unsigned int dpu_encoder_helper_get_dsc(const struct >>> dpu_encoder_phys *phys_enc) >> >> Why? >> > > drm_mode_to_intf_timing_params has "phys_enc" pointer declared as const, > so one of them needs to change to call dpu_encoder_helper_get_dsc > >>> { >>> struct drm_encoder *encoder = phys_enc->parent; >>> struct dpu_encoder_virt *dpu_enc = >>> to_dpu_encoder_virt(encoder); >>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h >>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h >>> index 6f04c3d56e77..7e27a7da0887 100644 >>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h >>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h >>> @@ -332,7 +332,7 @@ static inline enum dpu_3d_blend_mode >>> dpu_encoder_helper_get_3d_blend_mode( >>> * used for this encoder. >>> * @phys_enc: Pointer to physical encoder structure >>> */ >>> -unsigned int dpu_encoder_helper_get_dsc(struct dpu_encoder_phys >>> *phys_enc); >>> +unsigned int dpu_encoder_helper_get_dsc(const struct >>> dpu_encoder_phys *phys_enc); >>> >>> /** >>> * dpu_encoder_helper_split_config - split display configuration >>> helper function >>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c >>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c >>> index a01fda711883..df10800a9615 100644 >>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c >>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c >>> @@ -100,6 +100,8 @@ static void drm_mode_to_intf_timing_params( >>> } >>> >>> timing->wide_bus_en = >>> dpu_encoder_is_widebus_enabled(phys_enc->parent); >>> + if (dpu_encoder_helper_get_dsc(phys_enc)) >>> + timing->compression_en = true; >>> >>> /* >>> * for DP, divide the horizonal parameters by 2 when >>> @@ -112,6 +114,15 @@ static void drm_mode_to_intf_timing_params( >>> timing->h_front_porch = timing->h_front_porch >> 1; >>> timing->hsync_pulse_width = >>> timing->hsync_pulse_width >> 1; >>> } >>> + >>> + /* >>> + * for DSI, if compression is enabled, then divide the >>> horizonal active >>> + * timing parameters by compression ratio. >>> + */ >>> + if (phys_enc->hw_intf->cap->type != INTF_DP && >>> timing->compression_en) { >>> + timing->width = timing->width / 3; /* XXX: don't >>> assume 3:1 compression ratio */ >> >> Is this /3 from bpp / compressed_bpp? >> > > It is the compression ratio of DSC for 8bpc (24bpp) compressed to 8bpp. > DSI driver doesn't support any other cases so this assumption should be > OK for now (the other common ratio is 3.75 for 10bpc compressed to 8bpp > - from downstream driver it appears this would mean a division by 3.75 > here). > >>> + timing->xres = timing->width; >>> + } >>> } >>> >>> static u32 get_horizontal_total(const struct >>> dpu_hw_intf_timing_params *timing) >>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c >>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c >>> index e8b8908d3e12..d6fe45a6da2d 100644 >>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c >>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c >>> @@ -166,10 +166,21 @@ static void >>> dpu_hw_intf_setup_timing_engine(struct dpu_hw_intf *ctx, >>> * video timing. It is recommended to enable it for all >>> cases, except >>> * if compression is enabled in 1 pixel per clock mode >>> */ >>> + if (!p->compression_en || p->wide_bus_en) >>> + intf_cfg2 |= INTF_CFG2_DATA_HCTL_EN; >>> + >>> if (p->wide_bus_en) >>> - intf_cfg2 |= INTF_CFG2_DATABUS_WIDEN | >>> INTF_CFG2_DATA_HCTL_EN; >>> + intf_cfg2 |= INTF_CFG2_DATABUS_WIDEN; >>> >>> data_width = p->width; >>> + if (p->wide_bus_en && !dp_intf) >>> + data_width = p->width >> 1; >>> + >>> + if (p->compression_en) >>> + intf_cfg2 |= INTF_CFG2_DCE_DATA_COMPRESS; >>> + >>> + if (p->compression_en && dp_intf) >>> + DPU_ERROR("missing adjustments for DSC+DP\n"); >>> >>> hsync_data_start_x = hsync_start_x; >>> hsync_data_end_x = hsync_start_x + data_width - 1; >> >> This should go into a separate commit with the proper justification. >> > > All of it? setting the INTF_CFG2_DCE_DATA_COMPRESS flag at least doesn't > make sense to make a separate patch. And DSI widebus is only used with > DSC (and always used when available), so IMO also in the scope of this > commit. Excuse me for being not precise. I'm more concerned about INTF_CFG2_DATA_HCTL_EN change. They way you have added it doesn't have anything to do with the DSC support. If we ever want to revert just that clause to check anything, we wil have to revert the whole DSC-DSI-video commit, which doesn't seem correct. > >>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h >>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h >>> index c539025c418b..15a5fdadd0a0 100644 >>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h >>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h >>> @@ -33,6 +33,7 @@ struct dpu_hw_intf_timing_params { >>> u32 hsync_skew; >>> >>> bool wide_bus_en; >>> + bool compression_en; >>> }; >>> >>> struct dpu_hw_intf_prog_fetch { >>> -- >>> 2.26.1 >>> >> >>
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c index 1cf7ff6caff4..d745c8678b9d 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c @@ -2477,7 +2477,7 @@ enum dpu_intf_mode dpu_encoder_get_intf_mode(struct drm_encoder *encoder) return INTF_MODE_NONE; } -unsigned int dpu_encoder_helper_get_dsc(struct dpu_encoder_phys *phys_enc) +unsigned int dpu_encoder_helper_get_dsc(const struct dpu_encoder_phys *phys_enc) { struct drm_encoder *encoder = phys_enc->parent; struct dpu_encoder_virt *dpu_enc = to_dpu_encoder_virt(encoder); diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h index 6f04c3d56e77..7e27a7da0887 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h @@ -332,7 +332,7 @@ static inline enum dpu_3d_blend_mode dpu_encoder_helper_get_3d_blend_mode( * used for this encoder. * @phys_enc: Pointer to physical encoder structure */ -unsigned int dpu_encoder_helper_get_dsc(struct dpu_encoder_phys *phys_enc); +unsigned int dpu_encoder_helper_get_dsc(const struct dpu_encoder_phys *phys_enc); /** * dpu_encoder_helper_split_config - split display configuration helper function diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c index a01fda711883..df10800a9615 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c @@ -100,6 +100,8 @@ static void drm_mode_to_intf_timing_params( } timing->wide_bus_en = dpu_encoder_is_widebus_enabled(phys_enc->parent); + if (dpu_encoder_helper_get_dsc(phys_enc)) + timing->compression_en = true; /* * for DP, divide the horizonal parameters by 2 when @@ -112,6 +114,15 @@ static void drm_mode_to_intf_timing_params( timing->h_front_porch = timing->h_front_porch >> 1; timing->hsync_pulse_width = timing->hsync_pulse_width >> 1; } + + /* + * for DSI, if compression is enabled, then divide the horizonal active + * timing parameters by compression ratio. + */ + if (phys_enc->hw_intf->cap->type != INTF_DP && timing->compression_en) { + timing->width = timing->width / 3; /* XXX: don't assume 3:1 compression ratio */ + timing->xres = timing->width; + } } static u32 get_horizontal_total(const struct dpu_hw_intf_timing_params *timing) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c index e8b8908d3e12..d6fe45a6da2d 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c @@ -166,10 +166,21 @@ static void dpu_hw_intf_setup_timing_engine(struct dpu_hw_intf *ctx, * video timing. It is recommended to enable it for all cases, except * if compression is enabled in 1 pixel per clock mode */ + if (!p->compression_en || p->wide_bus_en) + intf_cfg2 |= INTF_CFG2_DATA_HCTL_EN; + if (p->wide_bus_en) - intf_cfg2 |= INTF_CFG2_DATABUS_WIDEN | INTF_CFG2_DATA_HCTL_EN; + intf_cfg2 |= INTF_CFG2_DATABUS_WIDEN; data_width = p->width; + if (p->wide_bus_en && !dp_intf) + data_width = p->width >> 1; + + if (p->compression_en) + intf_cfg2 |= INTF_CFG2_DCE_DATA_COMPRESS; + + if (p->compression_en && dp_intf) + DPU_ERROR("missing adjustments for DSC+DP\n"); hsync_data_start_x = hsync_start_x; hsync_data_end_x = hsync_start_x + data_width - 1; diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h index c539025c418b..15a5fdadd0a0 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h @@ -33,6 +33,7 @@ struct dpu_hw_intf_timing_params { u32 hsync_skew; bool wide_bus_en; + bool compression_en; }; struct dpu_hw_intf_prog_fetch {