The Adaptive Ambient Light (aal) block is one of the components of the video pipeline on some MediaTek SoCs, such as the MT8365. It adapts the picture to the ambient light through a per frame histogram and a correction curve.
U-Boot only needs the frame to go through untouched, so the driver just programs the frame size and enables the block, leaving the histogram and the correction curve at their reset values. The driver matches "mediatek,mt8183-disp-aal", the generic fallback the MT8365 aal0 node carries behind "mediatek,mt8365-disp-aal", so a single entry covers every SoC reusing that block. Signed-off-by: Julien Stephan <[email protected]> --- drivers/video/mediatek/mtk_disp_aal.c | 54 +++++++++++++++++++++++++++++++++++ drivers/video/mediatek/mtk_disp_aal.h | 31 ++++++++++++++++++++ 2 files changed, 85 insertions(+) diff --git a/drivers/video/mediatek/mtk_disp_aal.c b/drivers/video/mediatek/mtk_disp_aal.c new file mode 100644 index 00000000000..bbd8e6da6bc --- /dev/null +++ b/drivers/video/mediatek/mtk_disp_aal.c @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * MediaTek Video Adaptive Ambient Light 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_aal.h" +#include "mtk_disp_comp.h" + +#define DISP_AAL_EN 0x00 +#define AAL_EN BIT(0) + +#define DISP_AAL_SIZE 0x30 +#define DISP_AAL_SIZE_HSIZE GENMASK(28, 16) +#define DISP_AAL_SIZE_VSIZE GENMASK(12, 0) + +#define DISP_AAL_OUTPUT_SIZE 0x4d8 + +void mtk_aal_config(struct udevice *dev, const struct display_timing *timing) +{ + u32 sz; + + sz = FIELD_PREP(DISP_AAL_SIZE_HSIZE, timing->hactive.typ) | + FIELD_PREP(DISP_AAL_SIZE_VSIZE, timing->vactive.typ); + + mtk_disp_comp_write(dev, DISP_AAL_SIZE, sz); + mtk_disp_comp_write(dev, DISP_AAL_OUTPUT_SIZE, sz); +} + +void mtk_aal_start(struct udevice *dev) +{ + mtk_disp_comp_write(dev, DISP_AAL_EN, AAL_EN); +} + +static const struct udevice_id mtk_disp_aal_ids[] = { + { .compatible = "mediatek,mt8183-disp-aal" }, + { } +}; + +U_BOOT_DRIVER(mtk_disp_aal) = { + .name = "mtk_disp_aal", + .id = UCLASS_MISC, + .of_match = mtk_disp_aal_ids, + .probe = mtk_disp_comp_probe, + .priv_auto = sizeof(struct mtk_disp_comp_priv), +}; diff --git a/drivers/video/mediatek/mtk_disp_aal.h b/drivers/video/mediatek/mtk_disp_aal.h new file mode 100644 index 00000000000..d745556412e --- /dev/null +++ b/drivers/video/mediatek/mtk_disp_aal.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_AAL_H +#define _MTK_DISP_AAL_H + +struct display_timing; +struct udevice; + +/** + * mtk_aal_config() - configure the aal block + * @dev: aal device + * @timing: display timing, giving the frame size + * + * Set the input and output frame sizes of the adaptive ambient light block. + */ +void mtk_aal_config(struct udevice *dev, const struct display_timing *timing); + +/** + * mtk_aal_start() - start the aal block + * @dev: aal device + * + * Start the adaptive ambient light block. + */ +void mtk_aal_start(struct udevice *dev); + +#endif /* _MTK_DISP_AAL_H */ -- 2.55.0
