From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EAB4EC2D0 for ; Thu, 30 Mar 2023 04:52:04 +0000 (UTC) Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4Pn9nH5Xj3z9sW9; Thu, 30 Mar 2023 06:44:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oltmanns.dev; s=MBO0001; t=1680151475; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+Scw9GnQ38qy4L9yW8NU1qFZ8sCslAjUOVuTv4AxjKs=; b=0cAPL4EucscPGnjt8TkvhJ236LPfnYqc+03YuCGy7AVKY/Co+HQiHxKkXiDdC9cyAeUwy3 bwxhcRl58mVQii9a4u/SsB1IdpulDrkuXjGNUjBxK8/VJSTn6yAQG/17QOdTiNHSSRgEL9 p8faqcuKdAEofHpSmqGkuIKWqXMiXHqNzx1djrYNVr/LkGhr9Pqgyg53/PIGeeR7Lton+6 aFZU5ZictHNrzEmIaA5PAsyC7Gj6d717rVZJi4Kpf888qKc7alKuaHWFXFLGXPTh3ZaTN5 0ppHQn0B4qwyam1y3dDZ9lYbvPF+CwZ2EkkqhGDFHswpJx6G7pKIEqmJ4ILKjg== References: <20230320161636.24411-1-romanberanek@icloud.com> <87wn356ni4.fsf@oltmanns.dev> <20230327202045.ceeqqwjug4ktxtsf@penduick> <87bkkc3bzc.fsf@oltmanns.dev> <20230329195639.iep4rv5rcigu3gj2@penduick> From: Frank Oltmanns To: Maxime Ripard Cc: Roman Beranek , Chen-Yu Tsai , David Airlie , Daniel Vetter , Jernej Skrabec , Samuel Holland , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/sun4i: uncouple DSI dotclock divider from TCON0_DCLK_REG Date: Thu, 30 Mar 2023 06:41:44 +0200 In-reply-to: <20230329195639.iep4rv5rcigu3gj2@penduick> Message-ID: <87bkkaonkr.fsf@oltmanns.dev> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-Rspamd-Queue-Id: 4Pn9nH5Xj3z9sW9 Hi, On 2023-03-29 at 21:56:39 +0200, Maxime Ripard wrote: > Hi, > > On Tue, Mar 28, 2023 at 09:28:19PM +0200, Frank Oltmanns wrote: >> --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c >> +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c >> @@ -819,6 +819,34 @@ static void sun6i_dsi_encoder_disable(struct drm_encoder *encoder) >> regulator_disable(dsi->regulator); >> } >> >> +static bool sun6i_dsi_encoder_mode_fixup( >> + struct drm_encoder *encoder, >> + const struct drm_display_mode *mode, >> + struct drm_display_mode *adjusted_mode) > > So, mode_fixup is kind of deprecated in favour of atomic_check I see. Thanks for pointing that out. >> +{ >> + if (encoder->encoder_type == DRM_MODE_ENCODER_DSI) { >> + /* >> + * For DSI the PLL rate has to respect the bits per pixel and >> + * number of lanes. >> + * >> + * According to the BSP code: >> + * PLL rate = DOTCLOCK * bpp / lanes >> + * >> + * Therefore, the clock has to be adjusted in order to set the >> + * correct PLL rate when actually setting the clock. >> + */ >> + struct sun6i_dsi *dsi = encoder_to_sun6i_dsi(encoder); >> + struct mipi_dsi_device *device = dsi->device; >> + u8 bpp = mipi_dsi_pixel_format_to_bpp(device->format); >> + u8 lanes = device->lanes; >> + >> + adjusted_mode->crtc_clock = mode->crtc_clock >> + * bpp / (lanes * SUN6I_DSI_TCON_DIV); > > And that's visible to the userspace, so it's not where we should store > that value. I guess the best way to do something similar would be to > store it into crtc_state, and then reuse it there. But it starts to make > a lot of rather complicated code compared to your previous patch. Ah, interesting. But I agree, let's stick to the simpler aproach. Thanks, Frank > > Maxime > > [[End of PGP Signed Part]] -- From mboxrd@z Thu Jan 1 00:00:00 1970 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DDF5FC6FD1D for ; Thu, 30 Mar 2023 04:44:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CDBC710ECD4; Thu, 30 Mar 2023 04:44:41 +0000 (UTC) Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [IPv6:2001:67c:2050:0:465::202]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9FF1610ECD4 for ; Thu, 30 Mar 2023 04:44:39 +0000 (UTC) Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4Pn9nH5Xj3z9sW9; Thu, 30 Mar 2023 06:44:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oltmanns.dev; s=MBO0001; t=1680151475; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+Scw9GnQ38qy4L9yW8NU1qFZ8sCslAjUOVuTv4AxjKs=; b=0cAPL4EucscPGnjt8TkvhJ236LPfnYqc+03YuCGy7AVKY/Co+HQiHxKkXiDdC9cyAeUwy3 bwxhcRl58mVQii9a4u/SsB1IdpulDrkuXjGNUjBxK8/VJSTn6yAQG/17QOdTiNHSSRgEL9 p8faqcuKdAEofHpSmqGkuIKWqXMiXHqNzx1djrYNVr/LkGhr9Pqgyg53/PIGeeR7Lton+6 aFZU5ZictHNrzEmIaA5PAsyC7Gj6d717rVZJi4Kpf888qKc7alKuaHWFXFLGXPTh3ZaTN5 0ppHQn0B4qwyam1y3dDZ9lYbvPF+CwZ2EkkqhGDFHswpJx6G7pKIEqmJ4ILKjg== References: <20230320161636.24411-1-romanberanek@icloud.com> <87wn356ni4.fsf@oltmanns.dev> <20230327202045.ceeqqwjug4ktxtsf@penduick> <87bkkc3bzc.fsf@oltmanns.dev> <20230329195639.iep4rv5rcigu3gj2@penduick> From: Frank Oltmanns To: Maxime Ripard Subject: Re: [PATCH] drm/sun4i: uncouple DSI dotclock divider from TCON0_DCLK_REG Date: Thu, 30 Mar 2023 06:41:44 +0200 In-reply-to: <20230329195639.iep4rv5rcigu3gj2@penduick> Message-ID: <87bkkaonkr.fsf@oltmanns.dev> MIME-Version: 1.0 Content-Type: text/plain X-Rspamd-Queue-Id: 4Pn9nH5Xj3z9sW9 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Holland , linux-kernel@vger.kernel.org, Jernej Skrabec , Roman Beranek , Chen-Yu Tsai , dri-devel@lists.freedesktop.org, linux-sunxi@lists.linux.dev, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi, On 2023-03-29 at 21:56:39 +0200, Maxime Ripard wrote: > Hi, > > On Tue, Mar 28, 2023 at 09:28:19PM +0200, Frank Oltmanns wrote: >> --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c >> +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c >> @@ -819,6 +819,34 @@ static void sun6i_dsi_encoder_disable(struct drm_encoder *encoder) >> regulator_disable(dsi->regulator); >> } >> >> +static bool sun6i_dsi_encoder_mode_fixup( >> + struct drm_encoder *encoder, >> + const struct drm_display_mode *mode, >> + struct drm_display_mode *adjusted_mode) > > So, mode_fixup is kind of deprecated in favour of atomic_check I see. Thanks for pointing that out. >> +{ >> + if (encoder->encoder_type == DRM_MODE_ENCODER_DSI) { >> + /* >> + * For DSI the PLL rate has to respect the bits per pixel and >> + * number of lanes. >> + * >> + * According to the BSP code: >> + * PLL rate = DOTCLOCK * bpp / lanes >> + * >> + * Therefore, the clock has to be adjusted in order to set the >> + * correct PLL rate when actually setting the clock. >> + */ >> + struct sun6i_dsi *dsi = encoder_to_sun6i_dsi(encoder); >> + struct mipi_dsi_device *device = dsi->device; >> + u8 bpp = mipi_dsi_pixel_format_to_bpp(device->format); >> + u8 lanes = device->lanes; >> + >> + adjusted_mode->crtc_clock = mode->crtc_clock >> + * bpp / (lanes * SUN6I_DSI_TCON_DIV); > > And that's visible to the userspace, so it's not where we should store > that value. I guess the best way to do something similar would be to > store it into crtc_state, and then reuse it there. But it starts to make > a lot of rather complicated code compared to your previous patch. Ah, interesting. But I agree, let's stick to the simpler aproach. Thanks, Frank > > Maxime > > [[End of PGP Signed Part]] -- From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DB31AC74A5B for ; Thu, 30 Mar 2023 04:45:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:In-reply-to: Date:Subject:Cc:To:From:References:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CVGenE6EYYdOyyvAV1q1Firk57wqDXETaC7X90WMAss=; b=pWrnSWXFsSU053 IOc5xBt8LHp/c/P29TSiHJLy/7A6N3WXeBn+I5rKgOTqJY7gLukW7eFBWsSwsbtcRV25gcSeC8XnN UGoVC9hNozJ+mU1XjUeusYjv1vgDoGFlRca+r3k1T6ArNscVnvvsu2YIW4WOA/0tUQrpr1HVNl08H qL4BmG7zlJGzUdvAXnfJZ32fT+5rgVtJ6BHovnj1jbsl52fuJVPVWxf12fcd95RRlqG3KjP3fm2w8 UVzUUZoGW48GQjust+FLSJn3MH6Z4pnumpP1jPY39/nrTWCPZfPHBWgrIe1MTotgQNmKBuV0axQKq qVt5QQWcG6NO/3ojYUvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1phk9X-002XkC-0Z; Thu, 30 Mar 2023 04:44:47 +0000 Received: from mout-p-202.mailbox.org ([2001:67c:2050:0:465::202]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1phk9T-002Xim-2e for linux-arm-kernel@lists.infradead.org; Thu, 30 Mar 2023 04:44:45 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4Pn9nH5Xj3z9sW9; Thu, 30 Mar 2023 06:44:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oltmanns.dev; s=MBO0001; t=1680151475; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+Scw9GnQ38qy4L9yW8NU1qFZ8sCslAjUOVuTv4AxjKs=; b=0cAPL4EucscPGnjt8TkvhJ236LPfnYqc+03YuCGy7AVKY/Co+HQiHxKkXiDdC9cyAeUwy3 bwxhcRl58mVQii9a4u/SsB1IdpulDrkuXjGNUjBxK8/VJSTn6yAQG/17QOdTiNHSSRgEL9 p8faqcuKdAEofHpSmqGkuIKWqXMiXHqNzx1djrYNVr/LkGhr9Pqgyg53/PIGeeR7Lton+6 aFZU5ZictHNrzEmIaA5PAsyC7Gj6d717rVZJi4Kpf888qKc7alKuaHWFXFLGXPTh3ZaTN5 0ppHQn0B4qwyam1y3dDZ9lYbvPF+CwZ2EkkqhGDFHswpJx6G7pKIEqmJ4ILKjg== References: <20230320161636.24411-1-romanberanek@icloud.com> <87wn356ni4.fsf@oltmanns.dev> <20230327202045.ceeqqwjug4ktxtsf@penduick> <87bkkc3bzc.fsf@oltmanns.dev> <20230329195639.iep4rv5rcigu3gj2@penduick> From: Frank Oltmanns To: Maxime Ripard Cc: Roman Beranek , Chen-Yu Tsai , David Airlie , Daniel Vetter , Jernej Skrabec , Samuel Holland , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/sun4i: uncouple DSI dotclock divider from TCON0_DCLK_REG Date: Thu, 30 Mar 2023 06:41:44 +0200 In-reply-to: <20230329195639.iep4rv5rcigu3gj2@penduick> Message-ID: <87bkkaonkr.fsf@oltmanns.dev> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4Pn9nH5Xj3z9sW9 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230329_214444_081294_952804C7 X-CRM114-Status: GOOD ( 18.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, On 2023-03-29 at 21:56:39 +0200, Maxime Ripard wrote: > Hi, > > On Tue, Mar 28, 2023 at 09:28:19PM +0200, Frank Oltmanns wrote: >> --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c >> +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c >> @@ -819,6 +819,34 @@ static void sun6i_dsi_encoder_disable(struct drm_encoder *encoder) >> regulator_disable(dsi->regulator); >> } >> >> +static bool sun6i_dsi_encoder_mode_fixup( >> + struct drm_encoder *encoder, >> + const struct drm_display_mode *mode, >> + struct drm_display_mode *adjusted_mode) > > So, mode_fixup is kind of deprecated in favour of atomic_check I see. Thanks for pointing that out. >> +{ >> + if (encoder->encoder_type == DRM_MODE_ENCODER_DSI) { >> + /* >> + * For DSI the PLL rate has to respect the bits per pixel and >> + * number of lanes. >> + * >> + * According to the BSP code: >> + * PLL rate = DOTCLOCK * bpp / lanes >> + * >> + * Therefore, the clock has to be adjusted in order to set the >> + * correct PLL rate when actually setting the clock. >> + */ >> + struct sun6i_dsi *dsi = encoder_to_sun6i_dsi(encoder); >> + struct mipi_dsi_device *device = dsi->device; >> + u8 bpp = mipi_dsi_pixel_format_to_bpp(device->format); >> + u8 lanes = device->lanes; >> + >> + adjusted_mode->crtc_clock = mode->crtc_clock >> + * bpp / (lanes * SUN6I_DSI_TCON_DIV); > > And that's visible to the userspace, so it's not where we should store > that value. I guess the best way to do something similar would be to > store it into crtc_state, and then reuse it there. But it starts to make > a lot of rather complicated code compared to your previous patch. Ah, interesting. But I agree, let's stick to the simpler aproach. Thanks, Frank > > Maxime > > [[End of PGP Signed Part]] -- _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel