From patchwork Mon Jan 23 12:23:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 2646 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id C34253F039 for ; Mon, 23 Jan 2023 13:24:58 +0100 (CET) Received: by mail-pj1-f72.google.com with SMTP id h6-20020a17090aa88600b00223fccff2efsf9339962pjq.6 for ; Mon, 23 Jan 2023 04:24:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674476697; cv=pass; d=google.com; s=arc-20160816; b=jMK2VUXqYBlFEjUCpcZBsvyl9pAr1+xGwZdXSMsmYi97ppgcB9K3haAVdlOgjiuv7w GhPHzLwaS8A4zhysmMxrs0dPFEiipvQAFTfbwdzDQgf6xgsfkd72z2q07vvmk2gTlxDj aDajAnemIhfwMxMkxDSbk0YBn6XftpI00dVnIOsEfg6it3Mq7xuJSjYfIIqpgm67K7HY 3MSdNLc5zfqx2oSwnHvoplDe6ojyOTwiFqUfnGDJcAlxmKN1tj81eo9Nj7LwZ4JajQCZ RVL0MFUgDlgQHd7nkgvGboP1O0ULataxfCLoplAuRJmnSMEHnChOxK5WyfePpiI9/Js9 a9CQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=9KULKvxG5QfbZfARng7acmuae2mw/zm7CjEtASY3JtQ=; b=YxVy3Hgb+6xlmcG3oV4Y3ACvKbo6knX4J2RRzU0QQneIOzsiLafdXt9behBXm52n5l LHzWJoiaDBeSnEJFFxoANr76LTppZ/yXcsozRJ5kaaQFTNbd7qaXDJKg2cDd2AjqLAvZ Wd6wfAEf2Jl/pZXfbSuabIi6tTVh2W1dpyz3Pds6MVflENusSytLMAYQVgU9Aaf2SfHy YDYtB9VJ7tAzSSt9LXt1ryHx5vdit//jQ9pbVutr9ndTEWv4I8FK1g71ZC1qO5YxvKcZ OApXeRWqlNygXmOFZFW59kDJ7VQzNxjeqbmFL0cRQPPCxNC2MpOObXjHimBciVO7G1vS 51Bw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=nojSeomH; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=9KULKvxG5QfbZfARng7acmuae2mw/zm7CjEtASY3JtQ=; b=VXxwEfZlcYjJx3edBsLjqfA/sBopMBQp6hNPsczFoe7nJ7zrkWaajILOOeqfqDR5FI /3RkMpCd70oVKqeWoj2/za01uZcLvpOA0n26igJRxpavSPm23OV5GxPaDELqyXHmYaxu Qk+6VryqSl5XnnClV9rkSj5kwOegJArNWdxBM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9KULKvxG5QfbZfARng7acmuae2mw/zm7CjEtASY3JtQ=; b=pF8JArb7FqYCc5cbI6nPkUUAGge9vvfFl/rCgUmFKnokoyR88TLNkUPNkvwcsQCQjU F3/ybcvlEGVUIHu7lO1P3ReA5WkQDnX25TDmYIMetkYe8XI+0uIjTWwcHrqQn5fCV2GW JY7WiNDgNZ5LBcCMBghNBLRat4Xc407wjyTIPWKY+6oA6rPh5JnXMOq6EB2EK8fIwCDw g9q3HER6/c9+gMxY63qqP27gU/iWe+xugZAKE0P7TEykqWoDF45Y3/A1TFqUcBFghSdV dSEVQG4n3UN/tKsXnwSPu91GU0kPhIJAmLxTQLtCkdGabfFRMHNpNisuAwrsynicAW1p wLoQ== X-Gm-Message-State: AFqh2kqDdZkHI55tN0Gn3ewZ9NGIO41HkulcbmrrBZmfwfsaHJ2KRVpY 6A3LEE327z5QCunt2TrHvgvk2ZGz X-Google-Smtp-Source: AMrXdXvo8O0jYwE1JvA7yTDORyfezCMQUZvgF1K8d7+xhe0O64OVVPh6BlBV4jZt79gifmXhFfwfMA== X-Received: by 2002:a65:5548:0:b0:4cd:830b:240c with SMTP id t8-20020a655548000000b004cd830b240cmr1079839pgr.135.1674476697556; Mon, 23 Jan 2023 04:24:57 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:ab8c:b0:191:1e85:3329 with SMTP id f12-20020a170902ab8c00b001911e853329ls12746664plr.3.-pod-prod-gmail; Mon, 23 Jan 2023 04:24:57 -0800 (PST) X-Received: by 2002:a17:902:9688:b0:192:55ab:88fe with SMTP id n8-20020a170902968800b0019255ab88femr23854209plp.56.1674476696652; Mon, 23 Jan 2023 04:24:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674476696; cv=none; d=google.com; s=arc-20160816; b=wZzf/HXAwTi8vQCs9fjuv7PjVg+PMU35jO1b6sTV++J7Pn8fqNY3JLP1qh2n/fRaRg tvHHCCoNVCGyYGgCkL25kiCOoPCtJl5RCW7lge++UJo00O0UDW788BqssALPUF7uugtx pWyyEehA7r3Hoc4XPuBReXPHrGur1EyQGVk0pBKhLPgkj9g2H4mq+xQK+YTz+5qXBG3G HBIm/vKCBZjI0hAt7c4cpNjb62adl6R+lvejqpjk+K4jVwt8OdYWpnZlIQwHxfiIp4Wx jySRVdNClJyUdWDXdvij/2j4u6WkCzGNaOEM4B+btkPA/hswt0XY1AbEQa9xyqx2VYY2 YNLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Do3dhCYjC50CYA+L4s1clteIXcoOQ2GW8nVaTGD414U=; b=zDkbsG36ITrIXwS8Ijp+7gC8ddGRwwUkSzlzMEBbOY6KPA1bRTQ+E+ZsQBqmXOkqUp 2FiI7zt+VPx+e4NXF9VGbJuy6cOZbVjsYPHJkmVOA4BJNryPn/NxDDGU0wW7qGjL5wlM MtWu5T+ib/KJUyPyhuuDPswHp2ZyptKZZAslBKGqnJDzvHIevL7w3hFH1z9szroAaL6D 0glhBq5h/ANWu1F0OgAxfC8CoGc5vxSkE5/4ns4vgdJ/NoQYRHSiWNFufFSjwFOjRhwB 9bsPtKrc/lBnbXp1DazVMyYoXg4oT4cGTJfl2rf3LipNQkXvRZa+rItW+dAhqrnjSPLU yd0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=nojSeomH; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id d9-20020a170902854900b00189b41c1b5fsor1171342plo.138.2023.01.23.04.24.56 for (Google Transport Security); Mon, 23 Jan 2023 04:24:56 -0800 (PST) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:902:f54c:b0:192:fc9c:a238 with SMTP id h12-20020a170902f54c00b00192fc9ca238mr30487972plf.66.1674476696345; Mon, 23 Jan 2023 04:24:56 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a15f:2279:f361:f93b:7971]) by smtp.gmail.com with ESMTPSA id w10-20020a170902e88a00b001960806728asm1291811plg.88.2023.01.23.04.24.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 04:24:55 -0800 (PST) From: Jagan Teki To: Andrzej Hajda , Inki Dae , Marek Szyprowski , Joonyoung Shim , Seung-Woo Kim , Kyungmin Park , Frieder Schrempf , Fancy Fang , Tim Harvey , Michael Nazzareno Trimarchi , Adam Ford , Neil Armstrong , Robert Foss , Laurent Pinchart , Tommaso Merciai , Marek Vasut Cc: Matteo Lisi , dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, NXP Linux Team , linux-amarula , Jagan Teki Subject: [PATCH v11 11/18] drm: exynos: dsi: Add atomic_get_input_bus_fmts Date: Mon, 23 Jan 2023 17:53:12 +0530 Message-Id: <20230123122319.261341-12-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230123122319.261341-1-jagan@amarulasolutions.com> References: <20230123122319.261341-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=nojSeomH; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Finding the right input bus format throughout the pipeline is hard so add atomic_get_input_bus_fmts callback and initialize with the proper input format from list of supported output formats. This format can be used in pipeline for negotiating bus format between the DSI-end of this bridge and the other component closer to pipeline components. List of Pixel formats are taken from, AN13573 i.MX 8/RT MIPI DSI/CSI-2, Rev. 0, 21 March 2022 3.7.4 Pixel formats Table 14. DSI pixel packing formats Reviewed-by: Frieder Schrempf Tested-by: Marek Szyprowski Signed-off-by: Jagan Teki --- Changes for v11: - collect RB from Frieder - drop extra line Changes for v10: - none Changes for v9: - added MEDIA_BUS_FMT_FIXED - return MEDIA_BUS_FMT_RGB888_1X24 output_fmt if supported output_fmt list is unsupported. - added MEDIA_BUS_FMT_YUYV10_1X20, MEDIA_BUS_FMT_YUYV12_1X24 Changes for v8: - added pixel formats supported by NXP AN13573 i.MX 8/RT MIPI DSI/CSI-2 Changes for v7 - v4: - none Changes for v3: - include media-bus-format.h Changes for v2: - none Changes for v1: - new patch drivers/gpu/drm/exynos/exynos_drm_dsi.c | 68 +++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 5518d92c8455..7afbbe30d1d3 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -1466,6 +1467,72 @@ static void exynos_dsi_atomic_post_disable(struct drm_bridge *bridge, pm_runtime_put_sync(dsi->dev); } +/* + * This pixel output formats list referenced from, + * AN13573 i.MX 8/RT MIPI DSI/CSI-2, Rev. 0, 21 March 2022 + * 3.7.4 Pixel formats + * Table 14. DSI pixel packing formats + */ +static const u32 exynos_dsi_pixel_output_fmts[] = { + MEDIA_BUS_FMT_YUYV10_1X20, + MEDIA_BUS_FMT_YUYV12_1X24, + MEDIA_BUS_FMT_UYVY8_1X16, + MEDIA_BUS_FMT_RGB101010_1X30, + MEDIA_BUS_FMT_RGB121212_1X36, + MEDIA_BUS_FMT_RGB565_1X16, + MEDIA_BUS_FMT_RGB666_1X18, + MEDIA_BUS_FMT_RGB888_1X24, + MEDIA_BUS_FMT_FIXED, +}; + +static bool exynos_dsi_pixel_output_fmt_supported(u32 fmt) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(exynos_dsi_pixel_output_fmts); i++) { + if (exynos_dsi_pixel_output_fmts[i] == fmt) + return true; + } + + return false; +} + +static u32 * +exynos_dsi_atomic_get_input_bus_fmts(struct drm_bridge *bridge, + struct drm_bridge_state *bridge_state, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state, + u32 output_fmt, + unsigned int *num_input_fmts) +{ + u32 *input_fmts; + + if (!exynos_dsi_pixel_output_fmt_supported(output_fmt)) + /* + * Some bridge/display drivers are still not able to pass the + * correct format, so handle those pipelines by falling back + * to the default format till the supported formats finalized. + */ + output_fmt = MEDIA_BUS_FMT_RGB888_1X24; + + input_fmts = kmalloc(sizeof(*input_fmts), GFP_KERNEL); + if (!input_fmts) + return NULL; + + switch (output_fmt) { + case MEDIA_BUS_FMT_FIXED: + input_fmts[0] = MEDIA_BUS_FMT_RGB888_1X24; + break; + default: + input_fmts[0] = output_fmt; + break; + } + + *num_input_fmts = 1; + + return input_fmts; +} + static int exynos_dsi_atomic_check(struct drm_bridge *bridge, struct drm_bridge_state *bridge_state, struct drm_crtc_state *crtc_state, @@ -1514,6 +1581,7 @@ static const struct drm_bridge_funcs exynos_dsi_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, + .atomic_get_input_bus_fmts = exynos_dsi_atomic_get_input_bus_fmts, .atomic_check = exynos_dsi_atomic_check, .atomic_pre_enable = exynos_dsi_atomic_pre_enable, .atomic_enable = exynos_dsi_atomic_enable,