From: "CK Hu (胡俊光)" <ck.hu@mediatek.com>
To: "p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>,
"airlied@gmail.com" <airlied@gmail.com>,
Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com>,
"simona@ffwll.ch" <simona@ffwll.ch>,
"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>
Cc: "dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"kernel@collabora.com" <kernel@collabora.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v10 10/10] drm/mediatek: mtk_hdmi_v2: Add debugfs ops and implement ABIST
Date: Fri, 15 Aug 2025 09:33:22 +0000 [thread overview]
Message-ID: <6d3ba8d4286081e853ab3956234f5147189df540.camel@mediatek.com> (raw)
In-Reply-To: <20250808-mediatek-drm-hdmi-v2-v10-10-21ea82eec1f6@collabora.com>
On Fri, 2025-08-08 at 12:12 +0200, Louis-Alexis Eyraud wrote:
> External email : Please do not click links or open attachments until you have verified the sender or the content.
>
>
> From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
>
> Implement the Automated Built-In Self-Test ABIST functionality
> provided by the HDMIv2 IP and expose it through the "hdmi_abist"
> debugfs file.
>
> Write "1" to this file to activate ABIST, or "0" to deactivate.
>
> The ABIST functionality can be used to validate that the HDMI
> Transmitter itself works and that can output a valid image to
> the HDMI Display that is connected.
>
> This is especially useful when trying to rule out any possible
> issue that is related to the display pipeline, as the HDMI Tx
> is always the last component; this means that HDMI ABIST can be
> used even without prior display controller pipeline configuration.
>
> The expected output is a 100% color bar (rainbow) test pattern.
>
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com>
> ---
> drivers/gpu/drm/mediatek/mtk_hdmi_v2.c | 123 +++++++++++++++++++++++++++++++++
> 1 file changed, 123 insertions(+)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi_v2.c b/drivers/gpu/drm/mediatek/mtk_hdmi_v2.c
> index 2e8d8aed3c47417200dd951755cc2e3ef41df75d..c272e1e74b7de03a726402f77296b05c87b24e05 100644
> --- a/drivers/gpu/drm/mediatek/mtk_hdmi_v2.c
> +++ b/drivers/gpu/drm/mediatek/mtk_hdmi_v2.c
> @@ -1190,6 +1190,128 @@ static int mtk_hdmi_v2_hdmi_write_infoframe(struct drm_bridge *bridge,
> return 0;
> }
>
> +static int mtk_hdmi_v2_set_abist(struct mtk_hdmi *hdmi, bool enable)
> +{
> + struct drm_display_mode *mode = &hdmi->mode;
> + int abist_format = -EINVAL;
> + bool interlaced;
> +
> + if (!enable) {
> + regmap_clear_bits(hdmi->regs, TOP_CFG00, HDMI_ABIST_ENABLE);
> + return 0;
> + }
> +
> + if (!mode->hdisplay || !mode->vdisplay)
> + return -EINVAL;
> +
> + interlaced = mode->flags & DRM_MODE_FLAG_INTERLACE;
> +
> + switch (mode->hdisplay) {
> + case 720:
> + if (mode->vdisplay == 480)
> + abist_format = 2;
> + else if (mode->vdisplay == 576)
> + abist_format = 11;
> + break;
> + case 1280:
> + if (mode->vdisplay == 720)
> + abist_format = 3;
> + break;
> + case 1440:
> + if (mode->vdisplay == 480)
> + abist_format = interlaced ? 5 : 9;
> + else if (mode->vdisplay == 576)
> + abist_format = interlaced ? 14 : 18;
> + break;
> + case 1920:
> + if (mode->vdisplay == 1080)
> + abist_format = interlaced ? 4 : 10;
> + break;
> + case 3840:
> + if (mode->vdisplay == 2160)
> + abist_format = 25;
> + break;
> + case 4096:
> + if (mode->vdisplay == 2160)
> + abist_format = 26;
> + break;
> + default:
> + break;
> + }
> + if (abist_format < 0)
> + return abist_format;
> +
> + regmap_update_bits(hdmi->regs, TOP_CFG00, HDMI_ABIST_VIDEO_FORMAT,
> + FIELD_PREP(HDMI_ABIST_VIDEO_FORMAT, abist_format));
> + regmap_set_bits(hdmi->regs, TOP_CFG00, HDMI_ABIST_ENABLE);
> + return 0;
> +}
> +
> +static int mtk_hdmi_v2_debug_abist_show(struct seq_file *m, void *arg)
> +{
> + struct mtk_hdmi *hdmi = m->private;
> + bool en;
> + u32 val;
> + int ret;
> +
> + if (!hdmi)
> + return -EINVAL;
> +
> + ret = regmap_read(hdmi->regs, TOP_CFG00, &val);
> + if (ret)
> + return ret;
> +
> + en = FIELD_GET(HDMI_ABIST_ENABLE, val);
> +
> + seq_printf(m, "HDMI Automated Built-In Self Test: %s\n",
> + en ? "Enabled" : "Disabled");
> +
> + return 0;
> +}
> +
> +static ssize_t mtk_hdmi_v2_debug_abist_write(struct file *file,
> + const char __user *ubuf,
> + size_t len, loff_t *offp)
> +{
> + struct seq_file *m = file->private_data;
> + int ret;
> + u32 en;
> +
> + if (!m || !m->private || *offp)
> + return -EINVAL;
> +
> + ret = kstrtouint_from_user(ubuf, len, 0, &en);
> + if (ret)
> + return ret;
> +
> + if (en < 0 || en > 1)
> + return -EINVAL;
> +
> + mtk_hdmi_v2_set_abist((struct mtk_hdmi *)m->private, en);
> + return len;
> +}
> +
> +static int mtk_hdmi_v2_debug_abist_open(struct inode *inode, struct file *file)
> +{
> + return single_open(file, mtk_hdmi_v2_debug_abist_show, inode->i_private);
> +}
> +
> +static const struct file_operations mtk_hdmi_debug_abist_fops = {
> + .owner = THIS_MODULE,
> + .open = mtk_hdmi_v2_debug_abist_open,
> + .read = seq_read,
> + .write = mtk_hdmi_v2_debug_abist_write,
> + .llseek = seq_lseek,
> + .release = single_release,
> +};
> +
> +static void mtk_hdmi_v2_debugfs_init(struct drm_bridge *bridge, struct dentry *root)
> +{
> + struct mtk_hdmi *dpi = hdmi_ctx_from_bridge(bridge);
Maybe using hdmi instead of dpi is better.
I would change it when I apply this patch.
Reviewed-by: CK Hu <ck.hu@mediatek.com>
> +
> + debugfs_create_file("hdmi_abist", 0640, root, dpi, &mtk_hdmi_debug_abist_fops);
> +}
> +
> static const struct drm_bridge_funcs mtk_v2_hdmi_bridge_funcs = {
> .attach = mtk_hdmi_v2_bridge_attach,
> .detach = mtk_hdmi_v2_bridge_detach,
> @@ -1209,6 +1331,7 @@ static const struct drm_bridge_funcs mtk_v2_hdmi_bridge_funcs = {
> .hdmi_tmds_char_rate_valid = mtk_hdmi_v2_hdmi_tmds_char_rate_valid,
> .hdmi_clear_infoframe = mtk_hdmi_v2_hdmi_clear_infoframe,
> .hdmi_write_infoframe = mtk_hdmi_v2_hdmi_write_infoframe,
> + .debugfs_init = mtk_hdmi_v2_debugfs_init,
> };
>
> /*
>
> --
> 2.50.1
>
next prev parent reply other threads:[~2025-08-15 9:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-08 10:12 [PATCH v10 00/10] Add support for MT8195/88 HDMIv2 and DDCv2 Louis-Alexis Eyraud
2025-08-08 10:12 ` [PATCH v10 01/10] drm/mediatek: mtk_hdmi: Drop redundant clock retrieval in mtk_hdmi_get_cec_dev Louis-Alexis Eyraud
2025-08-15 9:22 ` CK Hu (胡俊光)
2025-08-08 10:12 ` [PATCH v10 02/10] drm/mediatek: mtk_hdmi: Improve mtk_hdmi_get_all_clk() flexibility Louis-Alexis Eyraud
2025-08-08 10:12 ` [PATCH v10 03/10] drm/mediatek: mtk_hdmi: Add HDMI IP version configuration to pdata Louis-Alexis Eyraud
2025-08-08 10:12 ` [PATCH v10 04/10] drm/mediatek: mtk_hdmi: Split driver and add common probe function Louis-Alexis Eyraud
2025-10-22 13:47 ` Chun-Kuang Hu
2025-08-08 10:12 ` [PATCH v10 05/10] drm/mediatek: mtk_hdmi_common: Make CEC support optional Louis-Alexis Eyraud
2025-08-08 10:12 ` [PATCH v10 06/10] drm/mediatek: mtk_hdmi_common: Assign DDC adapter pointer to bridge Louis-Alexis Eyraud
2025-08-08 10:12 ` [PATCH v10 07/10] drm/mediatek: mtk_hdmi_common: Add OP_HDMI if helper funcs assigned Louis-Alexis Eyraud
2025-08-08 10:12 ` [PATCH v10 08/10] drm/mediatek: mtk_hdmi_common: Add var to enable interlaced modes Louis-Alexis Eyraud
2025-08-08 10:12 ` [PATCH v10 09/10] drm/mediatek: Introduce HDMI/DDC v2 for MT8195/MT8188 Louis-Alexis Eyraud
2025-08-08 10:12 ` [PATCH v10 10/10] drm/mediatek: mtk_hdmi_v2: Add debugfs ops and implement ABIST Louis-Alexis Eyraud
2025-08-15 9:33 ` CK Hu (胡俊光) [this message]
2025-08-15 8:54 ` [PATCH v10 00/10] Add support for MT8195/88 HDMIv2 and DDCv2 CK Hu (胡俊光)
2025-09-12 9:42 ` AngeloGioacchino Del Regno
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=6d3ba8d4286081e853ab3956234f5147189df540.camel@mediatek.com \
--to=ck.hu@mediatek.com \
--cc=airlied@gmail.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chunkuang.hu@kernel.org \
--cc=dri-devel@lists.freedesktop.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=louisalexis.eyraud@collabora.com \
--cc=matthias.bgg@gmail.com \
--cc=p.zabel@pengutronix.de \
--cc=simona@ffwll.ch \
/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®