The color correction (CCORR) block is one of the components of the video pipeline on some MediaTek SoCs, such as the MT8365. It applies a 3x3 color transform matrix to the pixel stream.
U-Boot has no color management, so the driver only programs the frame size and enables the engine, which then applies the matrix left in the coefficient registers at reset. The driver matches "mediatek,mt8183-disp-ccorr", the generic fallback the MT8365 ccorr0 node carries behind "mediatek,mt8365-disp-ccorr", so a single entry covers every SoC reusing that block. Signed-off-by: Julien Stephan <[email protected]> --- drivers/video/mediatek/mtk_disp_ccorr.c | 55 +++++++++++++++++++++++++++++++++ drivers/video/mediatek/mtk_disp_ccorr.h | 31 +++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/drivers/video/mediatek/mtk_disp_ccorr.c b/drivers/video/mediatek/mtk_disp_ccorr.c new file mode 100644 index 00000000000..b54cc7dbe82 --- /dev/null +++ b/drivers/video/mediatek/mtk_disp_ccorr.c @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * MediaTek Video Color Correction Engine support + * + * Copyright (c) 2026 BayLibre, SAS. + * Author: Julien Masson <[email protected]> + * Julien Stephan <[email protected]> + */ + +#include <dm/device.h> +#include <fdtdec.h> +#include <linux/bitfield.h> +#include <linux/bitops.h> + +#include "mtk_disp_ccorr.h" +#include "mtk_disp_comp.h" + +#define DISP_CCORR_EN 0x00 +#define CCORR_EN BIT(0) + +#define DISP_CCORR_CFG 0x20 +#define CCORR_ENGINE_EN BIT(1) + +#define DISP_CCORR_SIZE 0x30 +#define DISP_CCORR_SIZE_HSIZE GENMASK(28, 16) +#define DISP_CCORR_SIZE_VSIZE GENMASK(12, 0) + +void mtk_ccorr_config(struct udevice *dev, const struct display_timing *timing) +{ + u32 sz; + + sz = FIELD_PREP(DISP_CCORR_SIZE_HSIZE, timing->hactive.typ) | + FIELD_PREP(DISP_CCORR_SIZE_VSIZE, timing->vactive.typ); + + mtk_disp_comp_write(dev, DISP_CCORR_SIZE, sz); + mtk_disp_comp_write(dev, DISP_CCORR_CFG, CCORR_ENGINE_EN); +} + +void mtk_ccorr_start(struct udevice *dev) +{ + mtk_disp_comp_write(dev, DISP_CCORR_EN, CCORR_EN); +} + +static const struct udevice_id mtk_disp_ccorr_ids[] = { + { .compatible = "mediatek,mt8183-disp-ccorr" }, + { } +}; + +U_BOOT_DRIVER(mtk_disp_ccorr) = { + .name = "mtk_disp_ccorr", + .id = UCLASS_MISC, + .of_match = mtk_disp_ccorr_ids, + .probe = mtk_disp_comp_probe, + .priv_auto = sizeof(struct mtk_disp_comp_priv), +}; diff --git a/drivers/video/mediatek/mtk_disp_ccorr.h b/drivers/video/mediatek/mtk_disp_ccorr.h new file mode 100644 index 00000000000..2d5bd3aa060 --- /dev/null +++ b/drivers/video/mediatek/mtk_disp_ccorr.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2026 BayLibre, SAS. + * Author: Julien Masson <[email protected]> + * Julien Stephan <[email protected]> + */ + +#ifndef _MTK_DISP_CCORR_H +#define _MTK_DISP_CCORR_H + +struct display_timing; +struct udevice; + +/** + * mtk_ccorr_config() - configure the ccorr block + * @dev: ccorr device + * @timing: display timing, giving the frame size + * + * Set the frame size of the color correction block. + */ +void mtk_ccorr_config(struct udevice *dev, const struct display_timing *timing); + +/** + * mtk_ccorr_start() - start the ccorr block + * @dev: ccorr device + * + * Start the color correction block. + */ +void mtk_ccorr_start(struct udevice *dev); + +#endif /* _MTK_DISP_CCORR_H */ -- 2.55.0
