From: "CK Hu (胡俊光)" <ck.hu@mediatek.com>
To: AngeloGioacchino Del Regno
<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>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"simona@ffwll.ch" <simona@ffwll.ch>,
"tzimmermann@suse.de" <tzimmermann@suse.de>,
"mripard@kernel.org" <mripard@kernel.org>,
"Jitao Shi (石记涛)" <jitao.shi@mediatek.com>,
"kernel@collabora.com" <kernel@collabora.com>,
"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
"maarten.lankhorst@linux.intel.com"
<maarten.lankhorst@linux.intel.com>,
"conor+dt@kernel.org" <conor+dt@kernel.org>,
"robh@kernel.org" <robh@kernel.org>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"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>,
"krzk+dt@kernel.org" <krzk+dt@kernel.org>
Subject: Re: [PATCH v1 2/6] drm/mediatek: mtk_dpi: Add support for Pattern Generator in debugfs
Date: Fri, 22 Nov 2024 02:02:42 +0000 [thread overview]
Message-ID: <a19bb68fc2c7492cd39ba9939abe678273ce6a81.camel@mediatek.com> (raw)
In-Reply-To: <20241120124420.133914-3-angelogioacchino.delregno@collabora.com>
Hi, Angelo:
On Wed, 2024-11-20 at 13:44 +0100, AngeloGioacchino Del Regno wrote:
> External email : Please do not click links or open attachments until you have verified the sender or the content.
>
>
> This IP includes a Pattern Generator which is useful for debugging
> and testing purposes: add the relevant register and bits to the
> mtk_dpi_regs.h header, and implement support for it in mtk_dpi.
>
> Adding this required to introduce a .debugfs_init() callback for
> the DPI bridge, which creates a "dpi_test_pattern" file in the
> directory of the appropriate connector.
>
> The pattern generator can generate various internal patterns and
> this submission includes support for:
> - 256 or 1024 shades of gray in a Vertical or Horizontal Pattern
> - Vertical Color Bars
> - Frame border
> - Dot Moire
>
> This generator also supports filling the entire screen with one
> custom color, but support for that is not included in this commit.
>
> Enabling and disabling this generator can be done by sending a
> string to the dpi_test_pattern debugfs file; the pattern is
> expected to be formatted as follows:
>
> <enable (1) or disable (0)> <pattern number>
>
> where the pattern number can be a number from 0 to 7, excluding 5.
>
> Of course 5 is excluded because that activates custom color fill
> which, again, is not supported in this commit.
Reviewed-by: CK Hu <ck.hu@mediatek.com>
>
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> ---
> drivers/gpu/drm/mediatek/mtk_dpi.c | 107 ++++++++++++++++++++++++
> drivers/gpu/drm/mediatek/mtk_dpi_regs.h | 4 +
> 2 files changed, 111 insertions(+)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c
> index 20a9d589fd75..c7143184e5de 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dpi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c
> @@ -6,6 +6,7 @@
>
> #include <linux/clk.h>
> #include <linux/component.h>
> +#include <linux/debugfs.h>
> #include <linux/interrupt.h>
> #include <linux/kernel.h>
> #include <linux/media-bus-format.h>
> @@ -166,6 +167,18 @@ static void mtk_dpi_mask(struct mtk_dpi *dpi, u32 offset, u32 val, u32 mask)
> writel(tmp, dpi->regs + offset);
> }
>
> +static void mtk_dpi_test_pattern_en(struct mtk_dpi *dpi, u8 type, bool enable)
> +{
> + u32 val;
> +
> + if (enable)
> + val = FIELD_PREP(DPI_PAT_SEL, type) | DPI_PAT_EN;
> + else
> + val = 0;
> +
> + mtk_dpi_mask(dpi, DPI_PATTERN0, val, DPI_PAT_SEL | DPI_PAT_EN);
> +}
> +
> static void mtk_dpi_sw_reset(struct mtk_dpi *dpi, bool reset)
> {
> mtk_dpi_mask(dpi, DPI_RET, reset ? RST : 0, RST);
> @@ -767,6 +780,99 @@ mtk_dpi_bridge_mode_valid(struct drm_bridge *bridge,
> return MODE_OK;
> }
>
> +static int mtk_dpi_debug_tp_show(struct seq_file *m, void *arg)
> +{
> + struct mtk_dpi *dpi = m->private;
> + bool en;
> + u32 val;
> +
> + if (!dpi)
> + return -EINVAL;
> +
> + val = readl(dpi->regs + DPI_PATTERN0);
> + en = val & DPI_PAT_EN;
> + val = FIELD_GET(DPI_PAT_SEL, val);
> +
> + seq_printf(m, "DPI Test Pattern: %s\n", en ? "Enabled" : "Disabled");
> +
> + if (en) {
> + seq_printf(m, "Internal pattern %d: ", val);
> + switch (val) {
> + case 0:
> + seq_puts(m, "256 Vertical Gray\n");
> + break;
> + case 1:
> + seq_puts(m, "1024 Vertical Gray\n");
> + break;
> + case 2:
> + seq_puts(m, "256 Horizontal Gray\n");
> + break;
> + case 3:
> + seq_puts(m, "1024 Horizontal Gray\n");
> + break;
> + case 4:
> + seq_puts(m, "Vertical Color bars\n");
> + break;
> + case 6:
> + seq_puts(m, "Frame border\n");
> + break;
> + case 7:
> + seq_puts(m, "Dot moire\n");
> + break;
> + default:
> + seq_puts(m, "Invalid selection\n");
> + break;
> + }
> + }
> +
> + return 0;
> +}
> +
> +static ssize_t mtk_dpi_debug_tp_write(struct file *file, const char __user *ubuf,
> + size_t len, loff_t *offp)
> +{
> + struct seq_file *m = file->private_data;
> + u32 en, type;
> + char buf[6];
> +
> + if (!m || !m->private || *offp || len > sizeof(buf) - 1)
> + return -EINVAL;
> +
> + memset(buf, 0, sizeof(buf));
> + if (copy_from_user(buf, ubuf, len))
> + return -EFAULT;
> +
> + if (sscanf(buf, "%u %u", &en, &type) != 2)
> + return -EINVAL;
> +
> + if (en < 0 || en > 1 || type < 0 || type > 7)
> + return -EINVAL;
> +
> + mtk_dpi_test_pattern_en((struct mtk_dpi *)m->private, type, en);
> + return len;
> +}
> +
> +static int mtk_dpi_debug_tp_open(struct inode *inode, struct file *file)
> +{
> + return single_open(file, mtk_dpi_debug_tp_show, inode->i_private);
> +}
> +
> +static const struct file_operations mtk_dpi_debug_tp_fops = {
> + .owner = THIS_MODULE,
> + .open = mtk_dpi_debug_tp_open,
> + .read = seq_read,
> + .write = mtk_dpi_debug_tp_write,
> + .llseek = seq_lseek,
> + .release = single_release,
> +};
> +
> +static void mtk_dpi_debugfs_init(struct drm_bridge *bridge, struct dentry *root)
> +{
> + struct mtk_dpi *dpi = bridge_to_dpi(bridge);
> +
> + debugfs_create_file("dpi_test_pattern", 0640, root, dpi, &mtk_dpi_debug_tp_fops);
> +}
> +
> static const struct drm_bridge_funcs mtk_dpi_bridge_funcs = {
> .attach = mtk_dpi_bridge_attach,
> .mode_set = mtk_dpi_bridge_mode_set,
> @@ -779,6 +885,7 @@ static const struct drm_bridge_funcs mtk_dpi_bridge_funcs = {
> .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
> .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
> .atomic_reset = drm_atomic_helper_bridge_reset,
> + .debugfs_init = mtk_dpi_debugfs_init,
> };
>
> void mtk_dpi_start(struct device *dev)
> diff --git a/drivers/gpu/drm/mediatek/mtk_dpi_regs.h b/drivers/gpu/drm/mediatek/mtk_dpi_regs.h
> index 62bd4931b344..a0b1d18bbbf7 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dpi_regs.h
> +++ b/drivers/gpu/drm/mediatek/mtk_dpi_regs.h
> @@ -235,4 +235,8 @@
> #define MATRIX_SEL_RGB_TO_JPEG 0
> #define MATRIX_SEL_RGB_TO_BT601 2
>
> +#define DPI_PATTERN0 0xf00
> +#define DPI_PAT_EN BIT(0)
> +#define DPI_PAT_SEL GENMASK(6, 4)
> +
> #endif /* __MTK_DPI_REGS_H */
> --
> 2.47.0
>
next prev parent reply other threads:[~2024-11-22 2:02 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-20 12:44 [PATCH v1 0/6] drm/mediatek: dpi: Add support for MT8195/8188 and Pattern Generator AngeloGioacchino Del Regno
2024-11-20 12:44 ` [PATCH v1 1/6] dt-bindings: display: mediatek: dpi: Add MT8195 and MT8188 compat AngeloGioacchino Del Regno
2024-11-21 8:39 ` Krzysztof Kozlowski
2024-11-22 2:00 ` CK Hu (胡俊光)
2024-11-20 12:44 ` [PATCH v1 2/6] drm/mediatek: mtk_dpi: Add support for Pattern Generator in debugfs AngeloGioacchino Del Regno
2024-11-22 2:02 ` CK Hu (胡俊光) [this message]
2024-11-20 12:44 ` [PATCH v1 3/6] drm/mediatek: mtk_dpi: Use an array for pixclk factor calculation AngeloGioacchino Del Regno
2024-11-22 3:54 ` CK Hu (胡俊光)
2024-11-22 6:23 ` CK Hu (胡俊光)
2024-11-25 16:55 ` AngeloGioacchino Del Regno
2024-11-20 12:44 ` [PATCH v1 4/6] drm/mediatek: mtk_dpi: Move pixel clock setting flow to function AngeloGioacchino Del Regno
2024-11-20 12:44 ` [PATCH v1 5/6] drm/mediatek: mtk_dpi: Add checks for reg_h_fre_con existence AngeloGioacchino Del Regno
2024-11-26 5:45 ` CK Hu (胡俊光)
2024-11-20 12:44 ` [PATCH v1 6/6] drm/mediatek: Add support for MT8195 Digital Parallel Interface AngeloGioacchino Del Regno
2024-11-22 7:23 ` CK Hu (胡俊光)
2024-11-25 16:55 ` AngeloGioacchino Del Regno
2024-11-26 3:07 ` CK Hu (胡俊光)
2024-11-26 9:25 ` AngeloGioacchino Del Regno
2024-11-27 7:02 ` CK Hu (胡俊光)
2024-11-27 8:41 ` AngeloGioacchino Del Regno
2024-11-27 9:04 ` CK Hu (胡俊光)
2024-11-27 12:44 ` AngeloGioacchino Del Regno
2024-11-28 3:08 ` CK Hu (胡俊光)
2024-11-28 10:34 ` 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=a19bb68fc2c7492cd39ba9939abe678273ce6a81.camel@mediatek.com \
--to=ck.hu@mediatek.com \
--cc=airlied@gmail.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chunkuang.hu@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jitao.shi@mediatek.com \
--cc=kernel@collabora.com \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthias.bgg@gmail.com \
--cc=mripard@kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=robh@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.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®