| Message ID | 20230123151212.269082-12-jagan@amarulasolutions.com |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-amarula+bncBD7MFH7A7EEBBLWIXKPAMGQEKIMHTZY@amarulasolutions.com> X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id B266A3F039 for <linux-amarula@patchwork.amarulasolutions.com>; Mon, 23 Jan 2023 16:13:51 +0100 (CET) Received: by mail-pf1-f199.google.com with SMTP id a18-20020a62bd12000000b0056e7b61ec78sf5423321pff.17 for <linux-amarula@patchwork.amarulasolutions.com>; Mon, 23 Jan 2023 07:13:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674486830; cv=pass; d=google.com; s=arc-20160816; b=UaeltjOfTtF65a9ds7IczYtpaEZK9jpt9WHij5NokZ37l3MjDasAnIEgcxRza7tCdA YMMhjjujNeMSwk3+1f34C79vDOPS3ov8BSSaV0bDqz1D87gVVFYtTtmXeDFj/WZZW4dv 9nyxtkHzJxvT9Mz3Ud8OBNVuTxolbU03/PVhb2fzxQPqXqklYfVScf///LhoZ0Py89/c VnMN1QqxnCVXjzsA+bFEuIsQuH4Vrr0MpQ4558ybd8CqByLThsf3WzkgNXtBrQD0SCiD Sj7d9c5D1VENeCpXu77IQWh3ABJKnnCsKmDGmS1g8thRY0e9F7izE5FaSgmHk3xY59wu QJOA== 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=ZslMR/B4YLTeXVWiVIOz3ZE44z4XacN0uxX/OoAXPN1OKBnf7wtWPvlMr+4L3tyFry /+nwDRzJnnRGFeBCkqhosMu738K5fOJBPM6i0ExUapkQ9Dt7kjf1p7yQpO6xskStG6g2 BGK2OnF7cDFzP/WhV/42Wt7VGasMogz5HgJ+D3ySFRwU7wpPTQQUyFzIaz30EfWSzj8j HlJ8assJUtDRU7VHcWQxQHRVDlZ9U4iYByuOpZBB1lpqGR9hAECn+BMFtfy5Q8quzhH4 GWY4FliS5qU5cJSzeSjdF3JLp3Fw19BA5ODqy2NRX7wNQPgJOhHwhliHq6IMiiRvHvgU iRJw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=hQUCk+G8; 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=rda4U77D4MSr/zk301uuBw4LAcDAxUBPgfkfycoQWnjiVNvHVd2PNY0UuN5L2qRpLX F1Rr6OjVvECmJrWXkxpaMi5nprhXzQslJBNfeGA6wPyf4iPhJS4I9lMmm/sa57D6WdUE D7bYAArm++wjuKKtOrHqfv7Z1DKKvaKgciUpQ= 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=5NBnkBKSbCWLtLADbBk6VcRqjIvfNoC/5x+a1atHGMNsPuK3BwKaasfMvuvdDQ/PYy OS2TZsRn69NxVRRH3cr9JNwQrbCFJyeZgqjuaqnn1naMmZ2vcxeDhqA6EP/nWfr4K0Ne kTALftHO6U8emESNEUXiBq5vPC/EQQkXp460whU88cE8Q5LiKUWw11WprlWebQveW654 jF0pQk3Wmqt9ng8wDfbFBeOQhIrvW4tl4yuvJ6OrD3TBy3B4hWvglUjoDVzPWn0FW420 ndcbFTtJSbNI2p61GKvGRC50HgxnPFAyQAnc+xIjdWONQo5GmriWVWQgMuRUmWwh57yV z1Wg== X-Gm-Message-State: AFqh2krre/WI9WzAYgIQcf1cT6Dx8QUOPteRxua08r/YfIgisAglesgY 216XBZtmwgc0pMN06GDAO8PFaOL5 X-Google-Smtp-Source: AMrXdXuZ0beSa9GGaxFyoTRellh7OiFkeca+euL7fwgNOVKBQV8z/GbMUUbA/cqMYUnBsV2JZDS3Fg== X-Received: by 2002:a17:90a:74c2:b0:228:fcdb:43a1 with SMTP id p2-20020a17090a74c200b00228fcdb43a1mr2768186pjl.143.1674486830318; Mon, 23 Jan 2023 07:13:50 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:6b44:b0:194:6afa:c3 with SMTP id g4-20020a1709026b4400b001946afa00c3ls13127281plt.4.-pod-prod-gmail; Mon, 23 Jan 2023 07:13:49 -0800 (PST) X-Received: by 2002:a17:902:9b8b:b0:189:d8fb:152d with SMTP id y11-20020a1709029b8b00b00189d8fb152dmr25206740plp.25.1674486829436; Mon, 23 Jan 2023 07:13:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674486829; cv=none; d=google.com; s=arc-20160816; b=HNObAk0426yTLiw6OjlMJhTflwGnhiaNr96PRk9q0TkLijru2OJujsTLo7ZAFrm2Yf WhoWrMGqyqKG50Vi0EZGUWqGDj+InHvxVEG1kLD6O1UwOGVPJwBYRrjAwa0RBwOuC8WX Fjy7X3QsYidZvNFdbbnYtHlJDFteiCBuy3/j9z1P9RnVnY/VX/BTXAhFwlBIqF4N1m9S qsl9rVqyGCzVm/dFfmO4XU+97nqee3fRVfBK21xelbGQfdtbWBriPbtQyQb41psi3ujU tOS9pzV5VPFBVybVX3loXVNACa6XSBKNPCPNPKMv37s50SnWtJ/SzUgfpukCTpevpcbb +syQ== 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=USd+9SNVJvy+0gMAJb8rX6ltrhsZu1RnL7cCcpXRVL57lQECodA25XR/qcRD5An3Yl 1n1J1wBBMQxtsN408FmxDjW3RerH2quxy5AIx8HpD4y5mNgruN+WKxBCvKSCKesHh0kN jgBvWdhlvJ5JDHNADuVIa2h16Cqpp0YRZi9Kxn/8LuVk2l9uK2dalWmKS1paZIoDY+na 1ozrvQyg4PZZckB/ryCMsQLf9/6SXh/m9IuVGUFnfCrjOI03L5UX6ZaJK5Wmh7kOOtcK 7WsJkH/KbELBtwbMyllOixATF94ajaqXm8AzkKVjZUL0UOpjm5VVr4+tujylpjvmOq/0 wn0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=hQUCk+G8; 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 p1-20020a170902a40100b00192fd37a18dsor1398006plq.164.2023.01.23.07.13.49 for <linux-amarula@amarulasolutions.com> (Google Transport Security); Mon, 23 Jan 2023 07:13:49 -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:eaca:b0:189:cbf6:9534 with SMTP id p10-20020a170902eaca00b00189cbf69534mr24224608pld.0.1674486829087; Mon, 23 Jan 2023 07:13:49 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a15f:2279:f361:f93b:7971]) by smtp.gmail.com with ESMTPSA id d5-20020a170903230500b001754fa42065sm19207111plh.143.2023.01.23.07.13.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 07:13:48 -0800 (PST) From: Jagan Teki <jagan@amarulasolutions.com> To: Andrzej Hajda <andrzej.hajda@intel.com>, Inki Dae <inki.dae@samsung.com>, Marek Szyprowski <m.szyprowski@samsung.com>, Joonyoung Shim <jy0922.shim@samsung.com>, Seung-Woo Kim <sw0312.kim@samsung.com>, Kyungmin Park <kyungmin.park@samsung.com>, Frieder Schrempf <frieder.schrempf@kontron.de>, Fancy Fang <chen.fang@nxp.com>, Tim Harvey <tharvey@gateworks.com>, Michael Nazzareno Trimarchi <michael@amarulasolutions.com>, Adam Ford <aford173@gmail.com>, Neil Armstrong <narmstrong@linaro.org>, Robert Foss <robert.foss@linaro.org>, Laurent Pinchart <Laurent.pinchart@ideasonboard.com>, Tommaso Merciai <tommaso.merciai@amarulasolutions.com>, Marek Vasut <marex@denx.de> Cc: Matteo Lisi <matteo.lisi@engicam.com>, dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, NXP Linux Team <linux-imx@nxp.com>, linux-amarula <linux-amarula@amarulasolutions.com>, Jagan Teki <jagan@amarulasolutions.com> Subject: [RESEND PATCH v11 11/18] drm: exynos: dsi: Add atomic_get_input_bus_fmts Date: Mon, 23 Jan 2023 20:42:05 +0530 Message-Id: <20230123151212.269082-12-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230123151212.269082-1-jagan@amarulasolutions.com> References: <20230123151212.269082-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=hQUCk+G8; 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: <linux-amarula.amarulasolutions.com> X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/post>, <mailto:linux-amarula@amarulasolutions.com> List-Help: <https://support.google.com/a/amarulasolutions.com/bin/topic.py?topic=25838>, <mailto:linux-amarula+help@amarulasolutions.com> List-Archive: <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/> List-Unsubscribe: <mailto:googlegroups-manage+476853432473+unsubscribe@googlegroups.com>, <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/subscribe> |
| Series |
drm: Add Samsung MIPI DSIM bridge
|
|
Commit Message
Jagan Teki
Jan. 23, 2023, 3:12 p.m. UTC
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 <frieder.schrempf@kontron.de> Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> --- 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(+)
Comments
On 1/23/23 16:12, Jagan Teki wrote: [...] > +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; > + > + 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; You can move this ^ past the kmalloc() call, so in unlikely case the kmalloc() fails, it would fail first. > + input_fmts = kmalloc(sizeof(*input_fmts), GFP_KERNEL); > + if (!input_fmts) > + return NULL; Delete from here ... > + switch (output_fmt) { > + case MEDIA_BUS_FMT_FIXED: > + input_fmts[0] = MEDIA_BUS_FMT_RGB888_1X24; > + break; > + default: > + input_fmts[0] = output_fmt; > + break; > + } ... until here, and do simple: input_fmts[0] = output_fmt; The effect should be the same, the code should be simpler and faster. > + *num_input_fmts = 1; [...]
On Wed, Jan 25, 2023 at 2:15 AM Marek Vasut <marex@denx.de> wrote: > > On 1/23/23 16:12, Jagan Teki wrote: > > [...] > > > +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; > > + > > + 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; > > You can move this ^ past the kmalloc() call, so in unlikely case the > kmalloc() fails, it would fail first. I didn't get this point, what do we need to do if exynos_dsi_pixel_output_fmt_supported returns false? Jagan.
On 1/24/23 22:16, Jagan Teki wrote: > On Wed, Jan 25, 2023 at 2:15 AM Marek Vasut <marex@denx.de> wrote: >> >> On 1/23/23 16:12, Jagan Teki wrote: >> >> [...] >> >>> +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; >>> + >>> + 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; >> >> You can move this ^ past the kmalloc() call, so in unlikely case the >> kmalloc() fails, it would fail first. > > I didn't get this point, what do we need to do if > exynos_dsi_pixel_output_fmt_supported returns false? { 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)) /* ... the comment ... */ output_fmt = MEDIA_BUS_FMT_RGB888_1X24; input_fmts[0] = output_fmt; *num_input_fmts = 1; return input_fmts; }
On Wed, Jan 25, 2023 at 2:49 AM Marek Vasut <marex@denx.de> wrote: > > On 1/24/23 22:16, Jagan Teki wrote: > > On Wed, Jan 25, 2023 at 2:15 AM Marek Vasut <marex@denx.de> wrote: > >> > >> On 1/23/23 16:12, Jagan Teki wrote: > >> > >> [...] > >> > >>> +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; > >>> + > >>> + 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; > >> > >> You can move this ^ past the kmalloc() call, so in unlikely case the > >> kmalloc() fails, it would fail first. > > > > I didn't get this point, what do we need to do if > > exynos_dsi_pixel_output_fmt_supported returns false? > > { > 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)) > /* ... the comment ... */ > output_fmt = MEDIA_BUS_FMT_RGB888_1X24; > > input_fmts[0] = output_fmt; > *num_input_fmts = 1; > > return input_fmts; > } Got it, thanks!
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 <linux/component.h> #include <linux/gpio/consumer.h> #include <linux/irq.h> +#include <linux/media-bus-format.h> #include <linux/of_device.h> #include <linux/of_graph.h> #include <linux/phy/phy.h> @@ -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,