From: "CK Hu (胡俊光)" <ck.hu@mediatek.com>
To: "angelogioacchino.delregno@collabora.com"
<angelogioacchino.delregno@collabora.com>,
"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>
Cc: "linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kernel@collabora.com" <kernel@collabora.com>,
"daniel@ffwll.ch" <daniel@ffwll.ch>,
"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"amergnat@baylibre.com" <amergnat@baylibre.com>,
"airlied@gmail.com" <airlied@gmail.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"fshao@chromium.org" <fshao@chromium.org>
Subject: Re: [PATCH v6 9/9] drm/mediatek: dsi: Use mipi_dsi_pixel_format_to_bpp() helper function
Date: Thu, 15 Feb 2024 09:28:16 +0000 [thread overview]
Message-ID: <fb9a5c679cae73b0784e792729395a07be0c65cd.camel@mediatek.com> (raw)
In-Reply-To: <20240215085316.56835-10-angelogioacchino.delregno@collabora.com>
Hi, Angelo:
On Thu, 2024-02-15 at 09:53 +0100, AngeloGioacchino Del Regno wrote:
> Instead of open coding, use the mipi_dsi_pixel_format_to_bpp() helper
> function from drm_mipi_dsi.h in mtk_dsi_poweron() and for validation
> in mtk_dsi_bridge_mode_valid().
>
> Note that this function changes the behavior of this driver:
> previously,
> in case of unknown formats, it would (wrongly) assume that it should
> account for a 24-bits format - now it will return an error and refuse
> to set clocks and/or enable the DSI.
>
> This is done because setting the wrong data rate will only produce a
> garbage output that the display will misinterpret both because this
> driver doesn't actually provide any extra-spec format support and/or
> because the data rate (hence, the HS clock) will be wrong.
Reviewed-by: CK Hu <ck.hu@mediatek.com>
>
> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
> Signed-off-by: AngeloGioacchino Del Regno <
> angelogioacchino.delregno@collabora.com>
> ---
> drivers/gpu/drm/mediatek/mtk_dsi.c | 26 +++++++++-----------------
> 1 file changed, 9 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c
> b/drivers/gpu/drm/mediatek/mtk_dsi.c
> index b644505de98a..9501f4019199 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dsi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
> @@ -598,19 +598,12 @@ static int mtk_dsi_poweron(struct mtk_dsi *dsi)
> if (++dsi->refcount != 1)
> return 0;
>
> - switch (dsi->format) {
> - case MIPI_DSI_FMT_RGB565:
> - bit_per_pixel = 16;
> - break;
> - case MIPI_DSI_FMT_RGB666_PACKED:
> - bit_per_pixel = 18;
> - break;
> - case MIPI_DSI_FMT_RGB666:
> - case MIPI_DSI_FMT_RGB888:
> - default:
> - bit_per_pixel = 24;
> - break;
> + ret = mipi_dsi_pixel_format_to_bpp(dsi->format);
> + if (ret < 0) {
> + dev_err(dev, "Unknown MIPI DSI format %d\n", dsi-
> >format);
> + return ret;
> }
> + bit_per_pixel = ret;
>
> dsi->data_rate = DIV_ROUND_UP_ULL(dsi->vm.pixelclock *
> bit_per_pixel,
> dsi->lanes);
> @@ -793,12 +786,11 @@ mtk_dsi_bridge_mode_valid(struct drm_bridge
> *bridge,
> const struct drm_display_mode *mode)
> {
> struct mtk_dsi *dsi = bridge_to_dsi(bridge);
> - u32 bpp;
> + int bpp;
>
> - if (dsi->format == MIPI_DSI_FMT_RGB565)
> - bpp = 16;
> - else
> - bpp = 24;
> + bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
> + if (bpp < 0)
> + return MODE_ERROR;
>
> if (mode->clock * bpp / dsi->lanes > 1500000)
> return MODE_CLOCK_HIGH;
prev parent reply other threads:[~2024-02-15 9:28 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-15 8:53 [PATCH v6 0/9] MediaTek DRM - DSI driver cleanups AngeloGioacchino Del Regno
2024-02-15 8:53 ` [PATCH v6 1/9] drm/mediatek: dsi: Use GENMASK() for register mask definitions AngeloGioacchino Del Regno
2024-02-15 8:53 ` [PATCH v6 2/9] drm/mediatek: dsi: Fix DSI RGB666 formats and definitions AngeloGioacchino Del Regno
2024-02-15 8:53 ` [PATCH v6 3/9] drm/mediatek: dsi: Cleanup functions mtk_dsi_ps_control{_vact}() AngeloGioacchino Del Regno
2024-02-15 8:53 ` [PATCH v6 4/9] drm/mediatek: dsi: Use bitfield macros where useful AngeloGioacchino Del Regno
2024-02-15 8:53 ` [PATCH v6 5/9] drm/mediatek: dsi: Replace open-coded instance of HZ_PER_MHZ AngeloGioacchino Del Regno
2024-02-15 8:53 ` [PATCH v6 6/9] drm/mediatek: dsi: Register DSI host after acquiring clocks and PHY AngeloGioacchino Del Regno
2024-02-15 9:15 ` CK Hu (胡俊光)
2024-02-15 8:53 ` [PATCH v6 7/9] drm/mediatek: dsi: Simplify with dev_err_probe and remove gotos AngeloGioacchino Del Regno
2024-02-15 9:17 ` CK Hu (胡俊光)
2024-02-15 8:53 ` [PATCH v6 8/9] drm/mediatek: dsi: Compress of_device_id entries and add sentinel AngeloGioacchino Del Regno
2024-02-15 9:20 ` CK Hu (胡俊光)
2024-02-15 8:53 ` [PATCH v6 9/9] drm/mediatek: dsi: Use mipi_dsi_pixel_format_to_bpp() helper function AngeloGioacchino Del Regno
2024-02-15 9:28 ` CK Hu (胡俊光) [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fb9a5c679cae73b0784e792729395a07be0c65cd.camel@mediatek.com \
--to=ck.hu@mediatek.com \
--cc=airlied@gmail.com \
--cc=amergnat@baylibre.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chunkuang.hu@kernel.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=fshao@chromium.org \
--cc=kernel@collabora.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=p.zabel@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®