<html><body><p>
<pre>
On Wed, 2025-04-09 at 15:13 +0200, AngeloGioacchino Del Regno wrote:
> External email : Please do not click links or open attachments until you have verified the sender or the content.
>
>
> In preparation for adding support for additional color formats,
> add local helpers to map media bus format parameters to this
> driver's bit_num, channel_swap and color_format.
>
> This commit brings no functional changes.
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 | 46 ++++++++++++++++++++++++++----
> 1 file changed, 40 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c
> index d735398e97f8..5a66dfe3ad40 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dpi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c
> @@ -738,6 +738,43 @@ static u32 *mtk_dpi_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
> return input_fmts;
> }
>
> +static unsigned int mtk_dpi_bus_fmt_bit_num(unsigned int out_bus_format)
> +{
> + switch (out_bus_format) {
> + default:
> + case MEDIA_BUS_FMT_RGB888_1X24:
> + case MEDIA_BUS_FMT_RGB888_2X12_LE:
> + case MEDIA_BUS_FMT_RGB888_2X12_BE:
> + case MEDIA_BUS_FMT_YUYV8_1X16:
> + return MTK_DPI_OUT_BIT_NUM_8BITS;
> + }
> +}
> +
> +static unsigned int mtk_dpi_bus_fmt_channel_swap(unsigned int out_bus_format)
> +{
> + switch (out_bus_format) {
> + default:
> + case MEDIA_BUS_FMT_RGB888_1X24:
> + case MEDIA_BUS_FMT_RGB888_2X12_LE:
> + case MEDIA_BUS_FMT_RGB888_2X12_BE:
> + case MEDIA_BUS_FMT_YUYV8_1X16:
> + return MTK_DPI_OUT_CHANNEL_SWAP_RGB;
> + }
> +}
> +
> +static unsigned int mtk_dpi_bus_fmt_color_format(unsigned int out_bus_format)
> +{
> + switch (out_bus_format) {
> + default:
> + case MEDIA_BUS_FMT_RGB888_1X24:
> + case MEDIA_BUS_FMT_RGB888_2X12_LE:
> + case MEDIA_BUS_FMT_RGB888_2X12_BE:
> + return MTK_DPI_COLOR_FORMAT_RGB;
> + case MEDIA_BUS_FMT_YUYV8_1X16:
> + return MTK_DPI_COLOR_FORMAT_YCBCR_422;
> + }
> +}
> +
> static int mtk_dpi_bridge_atomic_check(struct drm_bridge *bridge,
> struct drm_bridge_state *bridge_state,
> struct drm_crtc_state *crtc_state,
> @@ -757,13 +794,10 @@ static int mtk_dpi_bridge_atomic_check(struct drm_bridge *bridge,
> bridge_state->output_bus_cfg.format);
>
> dpi->output_fmt = out_bus_format;
> - dpi->bit_num = MTK_DPI_OUT_BIT_NUM_8BITS;
> - dpi->channel_swap = MTK_DPI_OUT_CHANNEL_SWAP_RGB;
> + dpi->bit_num = mtk_dpi_bus_fmt_bit_num(out_bus_format);
> + dpi->channel_swap = mtk_dpi_bus_fmt_channel_swap(out_bus_format);
> dpi->yc_map = MTK_DPI_OUT_YC_MAP_RGB;
> - if (out_bus_format == MEDIA_BUS_FMT_YUYV8_1X16)
> - dpi->color_format = MTK_DPI_COLOR_FORMAT_YCBCR_422;
> - else
> - dpi->color_format = MTK_DPI_COLOR_FORMAT_RGB;
> + dpi->color_format = mtk_dpi_bus_fmt_color_format(out_bus_format);
>
> return 0;
> }
> --
> 2.49.0
>
</pre>
</p></body></html><!--type:text--><!--{--><pre>************* MEDIATEK Confidentiality Notice
********************
The information contained in this e-mail message (including any
attachments) may be confidential, proprietary, privileged, or otherwise
exempt from disclosure under applicable laws. It is intended to be
conveyed only to the designated recipient(s). Any use, dissemination,
distribution, printing, retaining or copying of this e-mail (including its
attachments) by unintended recipient(s) is strictly prohibited and may
be unlawful. If you are not an intended recipient of this e-mail, or believe
that you have received this e-mail in error, please notify the sender
immediately (by replying to this e-mail), delete any and all copies of
this e-mail (including any attachments) from your system, and do not
disclose the content of this e-mail to any other person. Thank you!
</pre><!--}-->