[PATCH v2 28/46] drm/mediatek: Add support for MediaTek Digital Video Output (DVO)
AngeloGioacchino Del Regno
angelogioacchino.delregno at collabora.com
Mon Nov 23 02:03:53 PST 2026
On 11/20/26 08:42, CK Hu (胡俊光) wrote:
> On Tue, 2026-07-14 at 13:43 +0200, AngeloGioacchino Del Regno wrote:
>> Add a new driver for the Digital Video Output (DVO) hardware found
>> in the MT8189, MT8196 Kompanio SoCs and their Dimensity and Genio
>> variants.
>>
>> This version currently supports output to Embedded DisplayPort on
>> MT8189 and MT8196, and to DisplayPort on MT8189.
>>
>> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno at collabora.com>
>> ---
>
> [snip]
>
>> static inline struct mtk_dpi *bridge_to_dpi(struct drm_bridge *b)
>> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
>> index f7cbf9b47672..f96f887809c0 100644
>> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
>> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
>> @@ -621,8 +621,12 @@ static const struct of_device_id mtk_ddp_comp_dt_ids[] = {
>> .data = (void *)MTK_DISP_DSI },
>> { .compatible = "mediatek,mt8188-dsi",
>> .data = (void *)MTK_DISP_DSI },
>> - { .compatible = "mediatek,mt8196-dsi",
>
> Why do you remove "mediatek,mt8196-dsi"? This is not related to this patch.
That was not supposed to be here and it's a (huge) mistake.
Thanks for pointing that out.
>
>> - .data = (void *)MTK_DISP_DSI },
>> + { .compatible = "mediatek,mt8189-dp-dvo",
>> + .data = (void *)MTK_DISP_DVO },
>> + { .compatible = "mediatek,mt8189-edp-dvo",
>> + .data = (void *)MTK_DISP_DVO },
>> + { .compatible = "mediatek,mt8196-edp-dvo",
>> + .data = (void *)MTK_DISP_DVO },
>> { }
>> };
>>
>
> [snip]
>
>> +static void mtk_dvo_config_color_format(struct mtk_dpi *dvo,
>> + enum mtk_dpi_out_color_format format)
>> +{
>> + mtk_dvo_config_channel_swap(dvo, dvo->channel_swap);
>> +
>> + dev_err(dvo->dev, "[DPTX] format:%d", format);
>
> I think you should use debug, not err.
>
Yes.
>> +
>> + switch (format) {
>> + case MTK_DPI_COLOR_FORMAT_YCBCR_444:
>> + mtk_dvo_config_yuv422_enable(dvo, false);
>> + mtk_dvo_config_csc_enable(dvo, true);
>> + break;
>> + case MTK_DPI_COLOR_FORMAT_YCBCR_422:
>> + mtk_dvo_config_yuv422_enable(dvo, true);
>> + mtk_dvo_config_csc_enable(dvo, true);
>> + break;
>> + case MTK_DPI_COLOR_FORMAT_RGB:
>> + default:
>> + mtk_dvo_config_yuv422_enable(dvo, false);
>> + mtk_dvo_config_csc_enable(dvo, false);
>> + break;
>> + }
>> +}
>> +
>
> [snip]
>
>> +static void mtk_dvo_config_hw(struct mtk_dpi *dvo,
>> + struct videomode *vm, struct mtk_dpi_sync *sync,
>> + struct mtk_dpi_polarities *dpi_pol,
>> + struct mtk_dpi_yc_limit *limit)
>> +{
>> + struct drm_display_mode *mode = &dvo->mode;
>> + u32 vactive = vm->vactive;
>> +
>> + mtk_dvo_sw_reset(dvo, true);
>> +
>> + mtk_dvo_irq_enable(dvo);
>> +
>> + mtk_dpi_config_pol(dvo, dpi_pol);
>> +
>> + mtk_dvo_config_hsync(dvo, &sync->hsync);
>> + mtk_dvo_config_vsync(dvo, &sync->vsync_l_odd, DVO_TGEN_V0, DVO_TGEN_V1);
>> + mtk_dvo_config_vsync(dvo, &sync->vsync_l_even, DVO_TGEN_V_EVEN0, DVO_TGEN_V_EVEN1);
>> +
>> + mtk_dvo_config_interface(dvo, !!(vm->flags & DISPLAY_FLAGS_INTERLACED));
>> +
>> + if (vm->flags & DISPLAY_FLAGS_INTERLACED)
>> + vactive >>= 1;
>> +
>> + mtk_dvo_config_fb_size(dvo, vm->hactive, vactive);
>> +
>> + mtk_dvo_config_channel_limit(dvo, limit);
>> + mtk_dvo_config_channel_swap(dvo, dvo->channel_swap);
>> + mtk_dvo_config_color_format(dvo, dvo->color_format);
>> +
>> + mtk_dvo_info_queue_start(dvo);
>> + mtk_dpi_buffer_ctrl(dvo);
>> +
>> + mtk_dvo_trailing_blank_setting(dvo);
>> + mtk_dvo_get_gs_level(dvo);
>> + mtk_dvo_golden_setting(dvo);
>
> The two register set by mtk_dvo_golden_setting() would immediately set by mtk_dvo_sodi_setting(),
> so mtk_dvo_golden_setting() is redundant function. Drop it.
>
That's right. I'll recheck that part.
>> + mtk_dvo_sodi_setting(dvo, mode);
>> +
>> + mtk_dvo_set_output_pixiter(dvo);
>> +
>> + mtk_dvo_sw_reset(dvo, false);
>> +}
>> +
>
> [snip]
>
>> +
>> +static enum drm_mode_status
>> +mtk_dvo_bridge_mode_valid(struct drm_bridge *bridge,
>> + const struct drm_display_info *info,
>> + const struct drm_display_mode *mode)
>> +{
>
> In dpi driver, it check mode->clock max_clock_khz, so I think here should also check this.
>
Yeah, thing is - this was a bit more complicated than just checking max_clock_hz to
actually be correct, and I was planning to improve that later - but I guess that a
basic check for max_clock_hz is better than unconditionally and stupidly accepting
any mode.
I'll add a decent check here, thanks for pointing that out.
>> + return MODE_OK;
>> +}
>> +
>
> [snip]
>
>> --- /dev/null
>> +++ b/drivers/gpu/drm/mediatek/mtk_dvo_regs.h
>> @@ -0,0 +1,192 @@
>> +/* SPDX-License-Identifier: GPL-2.0-only */
>> +/*
>> + * Copyright (c) 2014 MediaTek Inc.
>> + * Author: Jie Qiu <jie.qiu at mediatek.com>
>> + */
>> +#ifndef __MTK_DPI_REGS_H
>
> __MTK_DVO_REGS_H
>
>> +#define __MTK_DPI_REGS_H
>> +
>
> [snip]
>
>> +#define DVO_TGEN_INFOQ_LATENCY 0x80
>> +#define INFOQ_START_LATENCY 0
>> +#define INFOQ_START_LATENCY_MASK (0xffff << 0)
>> +#define INFOQ_END_LATENCY 16
>> +#define INFOQ_END_LATENCY_MASK (0xffff << 16)
>> +
>> +#define DVO_BUF_CON0 0x220
>
> It's better to place register definition in address number order.
>
I completely agree. That was my intention, but with all this stuff that I've done
some things started slipping out of my sight ;-)
>> +#define DISP_BUF_EN BIT(0)
>> +#define FIFO_UNDERFLOW_DONE_BLOCK BIT(4)
>> +
>
> [snip]
>
>> +#define DVO_PATTERN_COLOR 0x104
>> +#define PAT_R (0x3ff << 0)
>> +#define PAT_G (0x3ff << 10)
>> +#define PAT_B (0x3ff << 20)
>> +
>> +#define DVO_Y_LIMIT 0x130
>> +#define Y_LMT_BOT GENMASK(9, 0)
>> +#define Y_LMT_TOP GENMASK(21, 12)
>> +
>> +#define DVO_C_LIMIT 0x134
>> +#define C_LMT_BOT GENMASK(9, 0)
>> +#define C_LMT_TOP GENMASK(21, 12)
>> +
>> +#define DVO_SHADOW_CTRL 0x190
>> +#define FORCE_COMMIT BIT(0)
>> +#define BYPASS_SHADOW BIT(1)
>> +#define READ_WRK_REG BIT(2)
>> +
>> +#define DVO_SIZE 0x18
>
> Ditto.
>
>> +#define DVO_TGEN_VWIDTH 0x28
>> +#define DVO_TGEN_VPORCH 0x2c
>> +#define DVO_TGEN_HPORCH 0x24
>> +#define DVO_TGEN_HWIDTH 0x20
>> +
>> +#define DVO_BUF_SODI_HIGHT 0x230
>> +#define DVO_BUF_SODI_LOW 0x234
>> +#define DVO_BUF_DVFS_HIGHT 0x238
>> +#define DVO_BUF_DVFS_LOW 0x23c
>> +#define DVO_BUF_PREULTRA_HIGHT 0x240
>> +#define DVO_BUF_PREULTRA_LOW 0x244
>> +#define DVO_BUF_ULTRA_HIGHT 0x248
>> +#define DVO_BUF_ULTRA_LOW 0x24c
>> +#define DVO_BUF_URGENT_HIGHT 0x250
>> +#define DVO_BUF_URGENT_LOW 0x254
>> +#define DVO_DISP_BUF_MASK GENMASK(31 ,0)
>
> GENMASK(31, 0)
Thanks, will cleanup
Cheers,
Angelo
>
> Regards,
> CK
>
>> +
>> +#define DVO_MATRIX_SET 0x140
>> +#define DVO_CSC_EN BIT(0)
>> +#define DVO_INT_MTX_SEL_MASK GENMASK(8, 4)
>> +
>> +#define DVO_YUV422_SET 0x170
>> +#define DVO_YUV422_EN BIT(0)
>> +#define DVO_CRYCB_MAP BIT(8)
>> +
>
More information about the linux-arm-kernel
mailing list