Skip to content

Commit e14cba9

Browse files
AngeloGioacchino Del RegnoChun-Kuang Hu
authored andcommitted
drm/mediatek: dsi: Use mipi_dsi_pixel_format_to_bpp() helper function
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: Alexandre Mergnat <amergnat@baylibre.com> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: CK Hu <ck.hu@mediatek.com> Link: https://patchwork.kernel.org/project/dri-devel/patch/20240215085316.56835-10-angelogioacchino.delregno@collabora.com/ Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
1 parent 2aa9514 commit e14cba9

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

drivers/gpu/drm/mediatek/mtk_dsi.c

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -598,19 +598,12 @@ static int mtk_dsi_poweron(struct mtk_dsi *dsi)
598598
if (++dsi->refcount != 1)
599599
return 0;
600600

601-
switch (dsi->format) {
602-
case MIPI_DSI_FMT_RGB565:
603-
bit_per_pixel = 16;
604-
break;
605-
case MIPI_DSI_FMT_RGB666_PACKED:
606-
bit_per_pixel = 18;
607-
break;
608-
case MIPI_DSI_FMT_RGB666:
609-
case MIPI_DSI_FMT_RGB888:
610-
default:
611-
bit_per_pixel = 24;
612-
break;
601+
ret = mipi_dsi_pixel_format_to_bpp(dsi->format);
602+
if (ret < 0) {
603+
dev_err(dev, "Unknown MIPI DSI format %d\n", dsi->format);
604+
return ret;
613605
}
606+
bit_per_pixel = ret;
614607

615608
dsi->data_rate = DIV_ROUND_UP_ULL(dsi->vm.pixelclock * bit_per_pixel,
616609
dsi->lanes);
@@ -793,12 +786,11 @@ mtk_dsi_bridge_mode_valid(struct drm_bridge *bridge,
793786
const struct drm_display_mode *mode)
794787
{
795788
struct mtk_dsi *dsi = bridge_to_dsi(bridge);
796-
u32 bpp;
789+
int bpp;
797790

798-
if (dsi->format == MIPI_DSI_FMT_RGB565)
799-
bpp = 16;
800-
else
801-
bpp = 24;
791+
bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
792+
if (bpp < 0)
793+
return MODE_ERROR;
802794

803795
if (mode->clock * bpp / dsi->lanes > 1500000)
804796
return MODE_CLOCK_HIGH;

0 commit comments

Comments
 (0)