From patchwork Mon Feb 27 11:39:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 2751 Return-Path: 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 962E13F9C2 for ; Mon, 27 Feb 2023 12:40:55 +0100 (CET) Received: by mail-pf1-f199.google.com with SMTP id z19-20020a056a001d9300b005d8fe305d8bsf3304771pfw.22 for ; Mon, 27 Feb 2023 03:40:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1677498054; cv=pass; d=google.com; s=arc-20160816; b=tRWKesZ6BVU3kjfzF3k9EGxXo4ubTMcrbr0lbXYxj3MFL48e/BU/0nXu6/xS2/aZRc Z4+9PsORYJUtnb0CtoGd2MWoKVT75v+LIQ3+Jy4BPZ8B5QhXe7fhA9MxGBW8q4jYuOqQ 981u5qiDo40KuYBvOSMUQEKMRBcNqYQ8NOXKkkMmzOZ5KDMvrrLG4hDFPg/r2l8IY+Zl Tdk7knoPbRGqmbHeYz065ctmzNYFM9RVrRpNNCDWZp1arSA+bN96wyNyt79ir6xGPtWj 5T1Uv46BenF+ePzfpCQjYDQrM9n0+LDFe5EJppRpGAptGQLSpVXr1aUxz1ERVIOqW8qN PTew== 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=7MNVVmbFthAezpN2pHOcY1MnPgFCW9tk7Pxt1Car0bc=; b=q4sBQxXamux+kEmZFWHiky57kkY4Rw1AACedzCX07irkPgk4OjfYLgxbU+EWQqT3iy MiCb8u5w1Hiv2X+FIl7t9sc0eBb/p0+Nw8Y4dtmBHWmg6H0VoUxE8D4QkgHbzsJtm/a6 rxOw3A31LeYsWOGY8+5XqyddUApxP1Uwl9hVkg2rUFPPRstVpizNEQEM1Xj1pwPQFHaF gX6tHRmAQAP6xFKFL+g/0+HFf0zWdpHgk2vb+95410p/YlzBTCh+H9N8F67Kb/xebKj7 GrCuxYCERwmwb4Z6wsHO13zl/pT2sq6vJnqF+6ws/6a0DGUnxO2UD1ApR9J19zL8dOMI UhtA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="Fg/gj+++"; 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=7MNVVmbFthAezpN2pHOcY1MnPgFCW9tk7Pxt1Car0bc=; b=Q9gVJLRMr3M9QJh3QsLM2fAWdYCEmWs9MOj9JZtJdO6zUacGQ5zQLfCY2J4AFPn/l9 i5rPkvT9Ci9W0fGvWrebbrDYBClWexj54GTkigrgISRaQpvda9yFYjLEpdRsjlX9i0YE wxPstG/hrA4S4/IZqyfE8JW/NAus0TO5hBXl4= 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=7MNVVmbFthAezpN2pHOcY1MnPgFCW9tk7Pxt1Car0bc=; b=sc0s9U8acCmnhjMaPsy4euE/CqmMHA91YAkqMYqWbIVeIaA9X6gwptkpg3gyGbbCiX 0rYRkX5xA/3f34sWQ+fwbM5m3bTVUkWbo7DVDtoMxaVdwsG82OW8cVn8vkspozXMJQU9 XYJdAEiL5/FW3rx3YeK+z9oFy6tVcAekCTUg+GSvuvgXC6z/2wAPRw35gIqnKwITIdzi USzliyBC24NrmLQBBd0ahyW/z2f1Q83Kn8ccSGbZQob5R4vXDyKU0iXb4vTJzgr39ncl Lw+dbj76Vy+GR7WSEWGuuqJ42edtrqoXnWbaEakBWBvyB0qFg7sR2sLTqnVx6oFawu/M vEkQ== X-Gm-Message-State: AO0yUKV3A1XPd1Sz/pykdW56reF3y3pp1LfgZYryD+/4llZa7RqZln1Q irx30znC9UnnFlBXj4fKwLG4Xctt X-Google-Smtp-Source: AK7set/WaTqdkOMDXbocgdj5wCPKIuwJMdV0srHrYvakwvYZkgCJdyAOnVfLDCbaJVBdFwZ4A3XO3w== X-Received: by 2002:a63:7b56:0:b0:4fb:933a:919 with SMTP id k22-20020a637b56000000b004fb933a0919mr5497229pgn.3.1677498054399; Mon, 27 Feb 2023 03:40:54 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:903:451:b0:19c:b3c9:49d5 with SMTP id iw17-20020a170903045100b0019cb3c949d5ls10500979plb.6.-pod-prod-gmail; Mon, 27 Feb 2023 03:40:53 -0800 (PST) X-Received: by 2002:a17:903:120c:b0:19c:bd10:3d40 with SMTP id l12-20020a170903120c00b0019cbd103d40mr17590783plh.40.1677498053393; Mon, 27 Feb 2023 03:40:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677498053; cv=none; d=google.com; s=arc-20160816; b=TcyAiPSpH283VEly2qiWVAIK0xFIX1LYBjQ8o+CIhJsM50HCuQoUmEf0voxlhEA4jW G6j55drUCW4gSAFQQzySesoMIJ7fFDhFD+SIgcXfVCNyCAidhfJ0KQBe+VuqBGAiAzzW iMPRxHN7xfwbSzIvlf77b//QLYIFAbVkfuglSP79nj/mJpPH+IloqS9ietoz2RxHPEf2 DMtUHv4wmzXs6cR/7uLA6u8wm6cx1gWrjB0eN0tMiE77MOpjxuVfGg6webnTqEgssl6M 8TGrv7DjY/VSkwU4TRHcxuFxQZijbe1GPSLNdq7xpcvc5RX+m2WOP+Wsqe2+XqP95/eR nG6w== 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=Yy00kSfB9ubDpN+1KzITSR+hdj0rooRsqbMSOz16J0s=; b=UCSmgadewglEQAhsa786Lfxtx77ErFZTuNZrekFwJUxvThYZ1DJndd51EcA4TnEsS7 TXQaYO/eCmawnvsMeTKtLByuS04wZg247yyRr+GRgEdkYlBX1PMLwxQ1SHFpWNuxqYMo aJhzI7zIBPaEEgL/uIH85pGYtV5Sqyrav1SNVDQrlOPMj0K3Cy6X9BEmtwGyE+OV1LUZ ZItIrZ5BO94h8nIzWsYDFkWrBiFxvrUC2mI0G04T6kmNdYeSTAKgkbzPJAmHRUF3SPyC EMeINqa0Hx1Yx/95K9wJYumCd9XPIAssV88Df8fCNSHy3RQtUVzMskrlXrl8MV+wki5M LEDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="Fg/gj+++"; 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 g12-20020a1709026b4c00b0019c86b0dd45sor2134271plt.96.2023.02.27.03.40.53 for (Google Transport Security); Mon, 27 Feb 2023 03:40:53 -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:cf4e:b0:19d:b20:4d1a with SMTP id e14-20020a170902cf4e00b0019d0b204d1amr3321667plg.60.1677498053066; Mon, 27 Feb 2023 03:40:53 -0800 (PST) Received: from localhost.localdomain ([94.140.8.120]) by smtp.gmail.com with ESMTPSA id k10-20020a170902ba8a00b0019c919bccf8sm4395277pls.86.2023.02.27.03.40.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 03:40:52 -0800 (PST) From: Jagan Teki To: Andrzej Hajda , Inki Dae , Marek Szyprowski , Seung-Woo Kim , Kyungmin Park , Frieder Schrempf , Tim Harvey , Adam Ford , Laurent Pinchart , 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 v13 11/18] drm: exynos: dsi: Add atomic_get_input_bus_fmts Date: Mon, 27 Feb 2023 17:09:18 +0530 Message-Id: <20230227113925.875425-12-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230227113925.875425-1-jagan@amarulasolutions.com> References: <20230227113925.875425-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="Fg/gj+++"; 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 Reviewed-by: Marek Vasut --- Changes for v13: - none 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 7f0703582506..aea56b6fbf17 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,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, @@ -1515,6 +1576,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,