Message ID | 20240215085316.56835-10-angelogioacchino.delregno@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-66453-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp259791dyb; Thu, 15 Feb 2024 00:58:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX/TRUZdxf5M7Q3EifCIpbcKkhKNL5Tb75DoTLU749bBLM6r5aQTGg4skFngzi50bLw2U7h5gCI3aLM+Nu6+TWh+ldexA== X-Google-Smtp-Source: AGHT+IGzUcsjGuvYHZeBn+v8kpMFmIg7jYh3kUkl+aFQStyzZutcBoCyb2Lnjw3f0zCT2j2zTHNP X-Received: by 2002:a05:6a20:6f88:b0:1a0:64bc:743 with SMTP id gv8-20020a056a206f8800b001a064bc0743mr1377094pzb.7.1707987490486; Thu, 15 Feb 2024 00:58:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707987490; cv=pass; d=google.com; s=arc-20160816; b=cbVqclf0Ai7Ck1LaBrCcUSZz9pSgNBK8tw9HUiyZ1nkm3hln46G7e22em3/HAnowsy L/sjs7yrmJjgF+7H3Gg0W1mpTR/dQQvt9hT++aQQEBkvb4FZt82xUKiiJiTM1Pr+3IBf 0TgorLQl9IfGRLEgLrt7d2vq40+GtnfamzPnHxOGEAQUJUygwL5iDK5uyRCVzBq9eI41 j/+ZRQiiFXa6L6f8xICarqhCta7sZTEFuGVBn+wUQyJ4bIFtR1gd072A9gN/vps7fAHc LwOLSClzXKvKvgWGsr05nNkzXUCtvVqt1ywMkWX4/5e6goOPgDOdEL9dEaqoDGlhg9BQ 6OkQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=b4dA93jvf0KlgcvF+UQHWZ0AHav2xg8zQh8AZYfaEm4=; fh=DymtPskoT54dQuQTH3+j1GsMJSYUhAPWziBriE7pXA4=; b=JXKKbip7DP2yX/fP/jNXimnG790N80b5PwMyTHclArl71Sr0m3lOqehOBHrAajQtXn UoOXg88Ygtg2IG4ZW9MzUIYi6dcYBWXGd+K+FMf5Y63Tw0ShdTZGT7i+NnTvJhakawjt QpOxe2qdcUDwvJnOdiGNtQvd4MakzcWIj6R+sKitNq0CE4Dh4yY/AWMvdmczU809chNT 7F/yei7m8aNbXJMMC3Mymce532LfvcT7cYiC06Ib8rF1/TZ3ACk+re6PMSj9Z+BFJ0z9 oSpexDrc15UoMMU0mVV5XcbzvlYPOBJ/URJ7QqRTZ/7kSRJ7m4iCXzAkixcTKdrK15EB Y76Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=3XjlyJNq; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-66453-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66453-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id bz3-20020a056a02060300b005dc4d8c8fb3si800533pgb.364.2024.02.15.00.58.10 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 00:58:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66453-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=3XjlyJNq; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-66453-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66453-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DB10A28D3A3 for <ouuuleilei@gmail.com>; Thu, 15 Feb 2024 08:55:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 666B81C68A; Thu, 15 Feb 2024 08:53:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="3XjlyJNq" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (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 44E5F1BC43 for <linux-kernel@vger.kernel.org>; Thu, 15 Feb 2024 08:53:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707987213; cv=none; b=W59Ijj3gIKwaXJ+CP34fmbR6AL2DTDYeF/tfd1Zop2hOnAJQfswnpvzPFk7N2RTZvhBpjHd9pW4PzptYLETZOzGzWZ9NaClRgUfA4OVlhLvC+2CIdvw9PZEKqvE1Fd+b8LtHJNgPaioOqNKEVTESFtAA48ZTup8HnhdBcHXXCtY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707987213; c=relaxed/simple; bh=t314JYLEkG/5o9HpK7I9qR3Mx0x17vEhEBxIxc/bWK0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G7RWePK++5ETYumQCuy6mi68CbDn+Rfpu46Fc68eaxQbWiV7vrxPTK7OVkKNvrGdpGEfLLn3gzJjGk76NJHV4nyrz/tdEcGE1pn9iOPPhzHqUXtHzmEqiKYkn7TMrCAcOOm96uyAz9IviZdvv6/6VHxE/JuQdrusqexqyQwkJo8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=3XjlyJNq; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1707987210; bh=t314JYLEkG/5o9HpK7I9qR3Mx0x17vEhEBxIxc/bWK0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=3XjlyJNqqrkhFH0s5u8O4UvGyNRs0YdhfTHjRJpQUdbyWX5pwegaSJ453ttZbh81+ TRoVlGcTFK4juZxrtVsZc/5sTvpkaJNyLyAsDFt3VN7IrUJ1rUbptgKmmPi/mnNyRI YXQ4nP/8pWmGnA7tt+oearOXWiCUR3zb8c21xnJBgHeEKPxclr9zDrPiw/ugF2mVOX 6xOKsO3lzH44FyDULJ7X2LP5PATGjd2/27lXcIi/RpkUZBAhf+KNjwnnLlOV3zFlru 68Hf2EPnZSPjb/3ZewUgB7SvqBN/A2SHIPzfFX2QEYieFEoMET+1wNI19Mi2Anplmz OwB+qC747Xp6w== Received: from IcarusMOD.eternityproject.eu (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madrid.collaboradmins.com (Postfix) with ESMTPSA id E77B137820AD; Thu, 15 Feb 2024 08:53:29 +0000 (UTC) From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> To: chunkuang.hu@kernel.org Cc: fshao@chromium.org, p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, Alexandre Mergnat <amergnat@baylibre.com> Subject: [PATCH v6 9/9] drm/mediatek: dsi: Use mipi_dsi_pixel_format_to_bpp() helper function Date: Thu, 15 Feb 2024 09:53:16 +0100 Message-ID: <20240215085316.56835-10-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215085316.56835-1-angelogioacchino.delregno@collabora.com> References: <20240215085316.56835-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790954690824107600 X-GMAIL-MSGID: 1790954690824107600 |
Series |
MediaTek DRM - DSI driver cleanups
|
|
Commit Message
AngeloGioacchino Del Regno
Feb. 15, 2024, 8:53 a.m. UTC
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> --- drivers/gpu/drm/mediatek/mtk_dsi.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-)
Comments
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;
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;