From patchwork Wed Mar 8 16:39:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 2789 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 18A4B414B5 for ; Wed, 8 Mar 2023 17:41:12 +0100 (CET) Received: by mail-pf1-f200.google.com with SMTP id z19-20020a056a001d9300b005d8fe305d8bsf9262193pfw.22 for ; Wed, 08 Mar 2023 08:41:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1678293671; cv=pass; d=google.com; s=arc-20160816; b=M52B4M5YG3Bo4blhngyYs4cU2LdlRDNkouh0V9TOMye1XRzY4nWYWvx8OcDQd7e0kr 8pBcNxRKhWwEvcOnXI2MHRZ2LGzwpSN/pAIkHuw+9YKfM5AfU3aMOm6S5Lzc9TiwDqPQ 8+FSwqUZejSqshFbHGoR69asjJpx1ofotQHmVHtAhtPA1UW/XR+TbwOYMPiDZcqTHR5m fwOtaONjD3dswimUz2/p3mW6CoKdBIOC6dlgTrko0h00m2164PJEz1qjkljSlMsJDLet xXStqEKU/yZHT2sN4YpTRFMghVFERJ0A5YBd99xpXKtVLvt/uDpUsvtGNT1TMVX59fWE AcRQ== 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=Ay2sxI29qtApbMwJYujpUDEekfQsGMlwwWNW1QdlgR0=; b=sqtN6PcKV63dpSYUiqvy6LQ14HeuRUeszTYydbO1UXuJ5BkoQU+UGC0XrrhblzAUzV XYZkARtBT1LQCgRmNit0BtCdgr4cdYP22AnfDLSlcqEWVygaTVrIpU9smahzXzoB2Si0 Q+SRNftvZU65tn2/E/e7Lnp9EBgxJoYbnWInnEyf+xOPO4ih3VsrQLsh+s15+7vrY/KN tGcOIud4cHiQfWt+FOL5nAFQUpwELILXoLX+EPdrjQ+BhskzkmnMRb9MZ9ozu3bhJo5X ca5nyE9pE8olyLvBvQWcZYmJcGMl0nUH1Cecf6rTOm7PnJJU85PTargd+mC8QUOgiqFV OsHQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=EKUzQ+uf; 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; t=1678293671; 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=Ay2sxI29qtApbMwJYujpUDEekfQsGMlwwWNW1QdlgR0=; b=MSxhXFEXRmUp3rEEulE1n6qziCwTwVMP9o/20jkBV50QGwbAZL+bp6DBJjKpft/apq Kfja4o5YC3TR04dyYElQ2NRpO9sE8Kez7nxXUTGqw0RP9dW5rFwSSbkwaz9OlcUW250G aiLM2riGzYSimfLWoBmO5qrwkwLhqHLe4YJew= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678293671; 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=Ay2sxI29qtApbMwJYujpUDEekfQsGMlwwWNW1QdlgR0=; b=15G76axBGnzTJ6vMkMIEtuu+Pru5BW1w4Inh21I0AmtLPvW8+pkcyD8LHfY+feBDlK R/Nxo9uQTbddAPTCb7nkOX/FW29JVoJk6Suld1mXfx8e4dU/H5jXhVg5j/m/U4iSZMrr lkgcfllTqbRWengzGIapWdGUhM99QxkF3VbtTfzCxF98U0Tvsk4HcHb6Y1ItV8htBarB vg3XNiaETfhc/Ynel+/LmgvD8Bxv+eHZ4R2RqKxyszIYQxjdlqK69IDXuYMScmeJ/G3S kHoblrzQCvhL9ky0UmlyRvy/QY/HhZ8k7WErSgBL1Mhiw+mPkzYZ88E6ylQ4OHVY8tuu GjEw== X-Gm-Message-State: AO0yUKU5YabGsEauEXO+JHj/jXn2Mwx/NguPAD0SX3gmNhSqp1AlvWFF hgEYdq0y5eIDd6g8MFsL1NUhBCQI X-Google-Smtp-Source: AK7set89JjSIeE6UYQ8bgUJMMH6Q2KDA9AB8an+i2QR+OGLwfjxwHF8DjSYvg7C9okpPgzmn22stkQ== X-Received: by 2002:a17:902:efcf:b0:19b:373:94ad with SMTP id ja15-20020a170902efcf00b0019b037394admr7065705plb.3.1678293670908; Wed, 08 Mar 2023 08:41:10 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:7043:b0:199:182b:34bf with SMTP id h3-20020a170902704300b00199182b34bfls16381093plt.3.-pod-prod-gmail; Wed, 08 Mar 2023 08:41:10 -0800 (PST) X-Received: by 2002:a17:902:aa4a:b0:19e:3922:b7d8 with SMTP id c10-20020a170902aa4a00b0019e3922b7d8mr15388466plr.12.1678293669926; Wed, 08 Mar 2023 08:41:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678293669; cv=none; d=google.com; s=arc-20160816; b=Ubu+8eBu08uOrZvCh6FZeR9KKxZoQx2FdEYTCSe752EyI4gApnaW6ieSo5HpXLeHdY Nor8BLy7pz7VTlB/n8MUaQn8qa/DOf8z+XVKdS2vx1FaGIOthwIxG/EO10bSUPiD4QXy Vhcfa3yYvT/wpM+hCYKUFVjwWMatDEJcCzC6ZUIWiOPT0PO5OObirTWWT+4aKhhVLXSk 7pbX2rxOsv96n0QlCdV+TjHxGElI105O16oH3Ogat+V9+YctRavUolrQmQl9gz0eFzPy PkY1SFfxRjn8WaMI/9xqocpKzBuJ8zIhC8deP6xlEWEMHBFYsOaxCgYaQETpFBnvEVDf 9qFw== 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=UsgY6N6catKRCRfBq6xxwmLwSB7PaDK4tqNXn1E6zOw=; b=i4xIplGo4cLUg7cXTx54nOgkdPSo560cVbPH0U+HhWzgndO102uvy+7/BrcFFKPhBb pKLG/vzWao5fDKV+dDACmhO8g0E50YqmoarLvqRhSsiHeytr8E3tjJi9GLKYghW3Uyt/ W20PN11GH1dEDin3bEPsW8d30yEuqkZyaXQWGW0QJqJ7GDGpfrpTzgdEiJJbZFmBVprS fZSa0ICplj25ScdEtiSVGVhmZdM/rRahMidwlHtuNXsoZQ3w5DqymgnZCxwd86aeLMNe K4WldQokpNhff5iT4eepw3rw5dUboHAo7ZR0VHkD1QXSdMGmJbx1912KQaFXeqo1ZKPu iDVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=EKUzQ+uf; 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 jk4-20020a170903330400b0019c94cf7697sor6170442plb.133.2023.03.08.08.41.09 for (Google Transport Security); Wed, 08 Mar 2023 08:41:09 -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:903:244b:b0:19c:c9da:a62e with SMTP id l11-20020a170903244b00b0019cc9daa62emr22126627pls.54.1678293669560; Wed, 08 Mar 2023 08:41:09 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a8a1:b545:91cc:80b2:f9fe]) by smtp.gmail.com with ESMTPSA id kq3-20020a170903284300b0019b9a075f1fsm10046540plb.80.2023.03.08.08.41.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Mar 2023 08:41:09 -0800 (PST) From: Jagan Teki To: Andrzej Hajda , Inki Dae , Marek Szyprowski , Neil Armstrong , Marek Vasut , Maxime Ripard Cc: Seung-Woo Kim , Kyungmin Park , Frieder Schrempf , Tim Harvey , Adam Ford , Matteo Lisi , dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org, linux-amarula , Jagan Teki Subject: [PATCH v16 09/16] drm: exynos: dsi: Add atomic_get_input_bus_fmts Date: Wed, 8 Mar 2023 22:09:46 +0530 Message-Id: <20230308163953.28506-10-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230308163953.28506-1-jagan@amarulasolutions.com> References: <20230308163953.28506-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=EKUzQ+uf; 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: Marek Vasut Reviewed-by: Frieder Schrempf Tested-by: Marek Szyprowski Signed-off-by: Jagan Teki --- Changes for v16: - none Changes for v15: - collect RB from Marek Changes for v12: - update the logic suggested by Marek 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 | 62 +++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 0c480be5f070..bd3bb8622ca3 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,66 @@ 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, +}; + +static bool exynos_dsi_pixel_output_fmt_supported(u32 fmt) +{ + int i; + + if (fmt == MEDIA_BUS_FMT_FIXED) + return false; + + 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; + + input_fmts = kmalloc(sizeof(*input_fmts), GFP_KERNEL); + if (!input_fmts) + return NULL; + + 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[0] = output_fmt; + *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 +1575,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,