From patchwork Wed Dec 14 12:59:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 2562 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id C3ACA3F0FB for ; Wed, 14 Dec 2022 14:00:54 +0100 (CET) Received: by mail-pg1-f197.google.com with SMTP id g32-20020a635660000000b00478c21b8095sf1801058pgm.10 for ; Wed, 14 Dec 2022 05:00:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671022853; cv=pass; d=google.com; s=arc-20160816; b=fnIZ6Dp/7sLr9HkqwYG/RP18g1GiaGizXH4MDqMlKEoOmaIQnrywTSmyROLU9Aw+CF QPddfX5QZcQ6WITgvum8+kUoEYxXbGJBpGmyZhjgBEbpf3WkH7rcFotbGg5e3gOPmehl wMlIAOivGus/EkTgRJ6wK+DnCjjkrqXZix1U6uavoh3AKC2pz40DB/FAlc2AYhHkEf0P 3PaYVULy1zbekHom6ayF7RR/PhfVmW3JNuOUSfSSlgfBBwuHso2pBbOq8+ItFmM3cdp0 OrKThlnCqnrAECnXxjvUoGVy84ZquU4KIAtK0a6AJIjAx88QEGvYUn5YHi1ChQgCrKCB m8yw== 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=IpCUchmGErxoQZD8nJzrRDRuRK89qMPOIj+CmBqXsSE=; b=sGiXoezUFLRKiFKsSQ2wDWGwAjwGA2XfG6tSFqs7v4DzHKYncvl4aD+MxQmDnUkLMu uMIJ5oHj/eqkEP+0ysTCBMg3oR9Q1NWipC5t/tug/rCt3GVOk9eYqg7ojU7ug2UpFQxr eafR8N0guPQWSfuzQTAnx+mVlKbL216M0eFTeOTAz9e0P08qUTdHypBEG6DbHGDR3e3E ZJkGMxTKIFQoK8Te0VCFKJ36ZI9TQwoTiXdVLoWPp/87I/wesqDnxwPyx8wnQDPoxzCB HccjIxeJMO+UTEO1zEy58DG9Y27Ev+sOMAeHTtVD3gEOsg40Dk2OyWHyHtELyoYkc6h+ s1Cg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=kIDUfCKr; 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=IpCUchmGErxoQZD8nJzrRDRuRK89qMPOIj+CmBqXsSE=; b=pDYy6yK0whDJ1cpBcMrz5Vvv1yA/JHPYIl8TyIVZzoc5HbudfGs2iKDs04IWtMJnbM qI7AgR7uQT4N9zUrtdu8M0EcJlW9iA87IG4/AGEVVU6y2FtXXwYcreqSBpO2woQqfIEH P1vcktdpoj++KmykWKMK0XMMnOQyLTZqG/7gA= 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=IpCUchmGErxoQZD8nJzrRDRuRK89qMPOIj+CmBqXsSE=; b=EpbICaWDIneebjRs99p0YXsTJyQRSdigEGtwy0Hcl7ktbMLthDSCwnjc3s78mosFfk Wf74c/l0YVeh7TT3iTBMocfCGOUxNQp8FSrKV3UoQ23AjKSwQpxen85KdpKnRLHOx27H Fm/9BhB3YTrP8XnsmHxtivcFoRJYr9KVKewZFdyRgF2exm12e1ZorD2wtDd1npSXW+zM 1ymcSB+Km8ypCExHaieYthpqDNbSmML+uVk0vBWqonS0joPtqLdImxPDnDjhDJuO4Qfx wo8C0fqXZUSWXBsGZVPTcdGyQpOgIkchpG1QHa8hD61SNeh3FBARdF0gXAqYhsj8ZKIT cYnQ== X-Gm-Message-State: ANoB5pmTsoo3eNs26MXDIJNYRDjZfKpgUo1veaLnStEltru8kKu7zliS +BN5QXBiC9/vkL1sPhxUmiByMAW6 X-Google-Smtp-Source: AA0mqf5FRNYh9OdKY64aumUaRFIoVnYDojwdqvJOEt9oOGnkmhzG/ZbIMGH6xGNKH3xY8MYChcKwIA== X-Received: by 2002:a63:f003:0:b0:45f:bf86:c917 with SMTP id k3-20020a63f003000000b0045fbf86c917mr87808105pgh.201.1671022853402; Wed, 14 Dec 2022 05:00:53 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:90a:a898:b0:210:6f33:e22d with SMTP id h24-20020a17090aa89800b002106f33e22dls24227156pjq.2.-pod-control-gmail; Wed, 14 Dec 2022 05:00:52 -0800 (PST) X-Received: by 2002:a17:902:d509:b0:189:b0fe:d70f with SMTP id b9-20020a170902d50900b00189b0fed70fmr31898028plg.60.1671022852233; Wed, 14 Dec 2022 05:00:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671022852; cv=none; d=google.com; s=arc-20160816; b=GXmPb3vfKGUJRPTdjFgBBqGXPZtq7PpGMExtpGa7r4r4oWOkLot5DPOfxEUtFuRyqb UkXzEttQMZmtiZvi76Ps4aWzT1o4xxYc2vLv71KfGIXCiziRqhS6+gZhj/pXdPO7TgRD 0R/6ycjHrGzbzbvD+H3mTz5JMiAMXYAvb49IDWViq5n1hCO5n+E3jy3rN7whiq6eI115 OLmtwJ/K43L0LM9fQFCvn+x0PWsDrtuA9rzdjqdecW58wDsg2pOYefri21FMP+90Dmh1 0YJGeP9xvN7F+IEb7uij1EuvGErucPsIDXXOLPxaNsyf9FNKtzFNM9S8jILggmP/nx2/ wWbw== 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=GVhftXkOyDrHisXtuBAfFezrQnFr2dvDm7Sl7pD6BIE=; b=GxIagf7VnjMyGzcwz5Xxw6CXIA/mEgGt4EUg3VPxutmljq362BkuGm35sunBAL3BPS /7++nvphk+qGTohrCQPIZ0NSNaK0q38KEK8N1ppkbS53SGJGi1l80Gcz036fAiuCpJvW kgzIdvHEwor0nsb/s09/oEd/7wfWfMlVak3cx1UO+x+l9S1pZTmMwmyA2X/W1jQTbeQ6 FMyuKEXw2a87s+jLDFEMQgZaEefIhSeLR8Iqos5kPUKtD7ut5M+Ei+cvkZmmiaQVEyAQ F9jx8ilowz3cbVlC7TFHua31mfvJV5mLcQs3IV6T4WUYtvNu9D4h1bEEhqRgqBS+hxpe ScWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=kIDUfCKr; 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 v23-20020a1709028d9700b00190e233cd36sor1311766plo.4.2022.12.14.05.00.52 for (Google Transport Security); Wed, 14 Dec 2022 05:00:52 -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:788e:b0:189:efe7:df8d with SMTP id q14-20020a170902788e00b00189efe7df8dmr24006481pll.43.1671022851498; Wed, 14 Dec 2022 05:00:51 -0800 (PST) Received: from localhost.localdomain ([2405:201:c00a:a809:5e03:faf:846e:352d]) by smtp.gmail.com with ESMTPSA id ix17-20020a170902f81100b001895f7c8a71sm1838651plb.97.2022.12.14.05.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Dec 2022 05:00:51 -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 v10 11/18] drm: exynos: dsi: Add atomic_get_input_bus_fmts Date: Wed, 14 Dec 2022 18:29:00 +0530 Message-Id: <20221214125907.376148-12-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221214125907.376148-1-jagan@amarulasolutions.com> References: <20221214125907.376148-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=kIDUfCKr; 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 Tested-by: Marek Szyprowski Signed-off-by: Jagan Teki Reviewed-by: Frieder Schrempf --- 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 | 69 +++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 36820a7b5884..bb3d6a7fa84e 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 @@ -1467,6 +1468,73 @@ 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, @@ -1515,6 +1583,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,