From patchwork Wed Jan 19 12:36:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 12717510 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 08085C433FE for ; Wed, 19 Jan 2022 12:37:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E453110F1AD; Wed, 19 Jan 2022 12:37:03 +0000 (UTC) Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by gabe.freedesktop.org (Postfix) with ESMTPS id DB22710F1B8 for ; Wed, 19 Jan 2022 12:37:01 +0000 (UTC) Received: by mail-wm1-x32f.google.com with SMTP id 25-20020a05600c231900b003497473a9c4so14262766wmo.5 for ; Wed, 19 Jan 2022 04:37:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qCSzim4chD2YZ1nYmMNUQu/jVANvmFwzUsxwlSkjcNs=; b=wZ+86cHu8by60Agnp1LSNhYjMgIjqTdNmvTULzONiNWLDnC/Pu6/zOmu/j4lE9pLJh oQC4FdupKTx5Fv8aq/4GC95rl+LCb1zLVz4RacPi2lbEtI8vGckDJLYCA9QQWFZCzhVs jRnZnAWkiE4yIK2+mCMbBiyMstokGQGvyEErREzQKhIzpxHeEL+5r1Ukpv+CAQjAuqd4 QV1/iOyV+3NShPPDnszcc4FX0J1c/I2yjDC6ga7Z+d2AzpG6EQGhOJPmexLh+WOxJgl5 Ay/w5+oLRIg5iuIm0ocOT2++SwIiB7xjpUAzaLsexUQbVCikOYzzqja42SDz4KOjIWvN 6C/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qCSzim4chD2YZ1nYmMNUQu/jVANvmFwzUsxwlSkjcNs=; b=duk0aDAk2neSetP5VJOCRAk4HCyjjbxJpysWQ0TcnqqEU3nxyRQIIK/T87GAGlZiK1 Yz5QrfLGwNeGu7nd53PO9o3IAbFXT2SlkcnskJjEoAHscdgmpCzocD9o5TbxTTS6QJA9 BK7iLkheduQkoP55E8qFPiZPHDXDaYPzaDcehqqTkyErI6oYiD2i7fOuPOVxi6WKzVup /0SgK88i4BwlPFWfsZNDSbCKfVQTUhZ1h1b0IjV3uiXVM6yMTD4epP70p0+/KLrXom0Y 4xXjLVDYxZYucgs1xYtCsAaDqSGJ+dz79jw6UDuYv/euIR1C6iHPOooCuIBkoZhjudNu CHcg== X-Gm-Message-State: AOAM533ZBCNRqWB+GVVrxL1EMN6QeLBlWsZTHBhSV0CCwCPt1uK6/Q+w XdY4XR+0dr1Ok3aW/8P8h/k5Kg== X-Google-Smtp-Source: ABdhPJw5a6DqhO5V4G/twLsma+1rrkJjiYS0Dq+Tec+BjOq4x+FA3gSO/pnEybBYhPBtNQSJ0iIj9g== X-Received: by 2002:a5d:428f:: with SMTP id k15mr6580508wrq.347.1642595820339; Wed, 19 Jan 2022 04:37:00 -0800 (PST) Received: from localhost.localdomain ([2001:861:44c0:66c0:d394:97d0:bc02:3846]) by smtp.gmail.com with ESMTPSA id bh13sm2610327wmb.33.2022.01.19.04.36.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jan 2022 04:36:59 -0800 (PST) From: Neil Armstrong To: robert.foss@linaro.org Subject: [PATCH 1/2] drm/bridge: dw-hdmi: filter safe formats when first in bridge chain Date: Wed, 19 Jan 2022 13:36:55 +0100 Message-Id: <20220119123656.1456355-1-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jernej.skrabec@gmail.com, Neil Armstrong , jonas@kwiboo.se, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Laurent.pinchart@ideasonboard.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" If the dw-bridge is in the first position in the bridge chain, this means there is no way to set the encoder output bus format. In this case, this makes sure we only return the default format as return of the get_input_bus_fmts() callback, limiting possible output formats of dw-hdmi to what the dw-hdmi can convert from the default RGB24 input format. Fixes: 6c3c719936da ("drm/bridge: synopsys: dw-hdmi: add bus format negociation") Signed-off-by: Neil Armstrong --- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index 97cdc61b57f6..56021f20d396 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -2674,6 +2674,25 @@ static u32 *dw_hdmi_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge, if (!input_fmts) return NULL; + /* If dw-hdmi is the first bridge make sure it only takes RGB24 as input */ + if (list_is_first(&bridge->chain_node, &bridge->encoder->bridge_chain)) { + switch (output_fmt) { + case MEDIA_BUS_FMT_FIXED: + case MEDIA_BUS_FMT_RGB888_1X24: + case MEDIA_BUS_FMT_YUV8_1X24: + case MEDIA_BUS_FMT_UYVY8_1X16: + input_fmts[i++] = MEDIA_BUS_FMT_RGB888_1X24; + break; + default: + kfree(input_fmts); + input_fmts = NULL; + } + + *num_input_fmts = i; + + return input_fmts; + } + switch (output_fmt) { /* If MEDIA_BUS_FMT_FIXED is tested, return default bus format */ case MEDIA_BUS_FMT_FIXED: From patchwork Wed Jan 19 12:36:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 12717511 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 01DB9C433EF for ; Wed, 19 Jan 2022 12:37:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2DA4110F1B4; Wed, 19 Jan 2022 12:37:04 +0000 (UTC) Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by gabe.freedesktop.org (Postfix) with ESMTPS id CFC0610F1AD for ; Wed, 19 Jan 2022 12:37:02 +0000 (UTC) Received: by mail-wm1-x329.google.com with SMTP id l35-20020a05600c1d2300b0034d477271c1so5676432wms.3 for ; Wed, 19 Jan 2022 04:37:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FtbatZGWzmTr6DnUVWu1NqWNgW9rriYHmmB6wzthA20=; b=JWxcBFQmrMmIDILvkvK/SS+Im4XPo9L8Pl9DcWHi+Ri46hejUeOEpiLOVw05+gb7qk dHg2xvMjH0rRfpwkkEegTwwO6uZfcwrnLaM4ZAe/YoI77sWKGk6KrWehxJVSj66e37V9 WCjrol0IzevLXB/WO3ynOjoIc5dynwkqs9Vu0k+5SyLJMMznOGJY5VHcqGR036cMGgSr Sm8mLoB00qBO6YXXawH7vCdi5AEYtTrIEE3Y9m3+FMSSvcIgeh/lA27bFy8M07LcBeyN sLvnHrTNXpf7mcWFczWIou7JbnHEKJyYlfp2Bc21zNoieIcHpKqu+bBE1592XrxWLerz 8fxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FtbatZGWzmTr6DnUVWu1NqWNgW9rriYHmmB6wzthA20=; b=ThnpqLX2IwmbgUURD2DyasfsemvMSJPUaDKB2D33mSZxVLbjDNxrpYYT0C7phRsOZp JrlUjmXFETTDbPd2IISqXgzwXz+y/x3Q/6MBpT1avoPFfoHtRDsJb6pas7iB28PKHnQq JBhv9Ouey/6cSTqp2w9jFVk3+h3bQPuvukh9FMwd/wj9m8n8UVfnbpNNXCSeky3c+Rwa rAyIEixFOVX8fcCWCsSUokAd12Eslv+/u5957HpJhOUCEhzKCc2BMnm3MFzu1nytBdqN noyfLVBOUQQkSz2gfvNRAWtxo9qyG5GpaiqMY9wIhGFaZNU/3Ivps+1MMrcfwfSTNCO9 w3cA== X-Gm-Message-State: AOAM531Tm5ETTOgtjGEk08+sznSZ0jHnm+9ML4eLp5jQpkRcxJU1xE/F P+DTAogrTJENaTdWlIlpBik2oQ== X-Google-Smtp-Source: ABdhPJxGHOe4mirdaI0EnQU54OW7tOqwZqmf5efIF3TQMf5fjYwGXAICSWDLcUt1DvJKIdU68iVj5g== X-Received: by 2002:a05:6000:10c1:: with SMTP id b1mr28467840wrx.226.1642595821323; Wed, 19 Jan 2022 04:37:01 -0800 (PST) Received: from localhost.localdomain ([2001:861:44c0:66c0:d394:97d0:bc02:3846]) by smtp.gmail.com with ESMTPSA id bh13sm2610327wmb.33.2022.01.19.04.37.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jan 2022 04:37:00 -0800 (PST) From: Neil Armstrong To: robert.foss@linaro.org Subject: [PATCH 2/2] drm/bridge: dw-hdmi: filter out YUV output formats when DVI Date: Wed, 19 Jan 2022 13:36:56 +0100 Message-Id: <20220119123656.1456355-2-narmstrong@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220119123656.1456355-1-narmstrong@baylibre.com> References: <20220119123656.1456355-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jernej.skrabec@gmail.com, Neil Armstrong , jonas@kwiboo.se, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Laurent.pinchart@ideasonboard.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" When the display is not an HDMI sink, only the RGB output format is valid. Thus stop returning YUV output formats when sink is not HDMI. Fixes: 6c3c719936da ("drm/bridge: synopsys: dw-hdmi: add bus format negociation") Signed-off-by: Neil Armstrong --- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index 56021f20d396..03057d335158 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -2538,6 +2538,7 @@ static u32 *dw_hdmi_bridge_atomic_get_output_bus_fmts(struct drm_bridge *bridge, struct drm_connector *conn = conn_state->connector; struct drm_display_info *info = &conn->display_info; struct drm_display_mode *mode = &crtc_state->mode; + struct dw_hdmi *hdmi = bridge->driver_private; u8 max_bpc = conn_state->max_requested_bpc; bool is_hdmi2_sink = info->hdmi.scdc.supported || (info->color_formats & DRM_COLOR_FORMAT_YCRCB420); @@ -2564,7 +2565,7 @@ static u32 *dw_hdmi_bridge_atomic_get_output_bus_fmts(struct drm_bridge *bridge, * If the current mode enforces 4:2:0, force the output but format * to 4:2:0 and do not add the YUV422/444/RGB formats */ - if (conn->ycbcr_420_allowed && + if (hdmi->sink_is_hdmi && conn->ycbcr_420_allowed && (drm_mode_is_420_only(info, mode) || (is_hdmi2_sink && drm_mode_is_420_also(info, mode)))) { @@ -2595,36 +2596,36 @@ static u32 *dw_hdmi_bridge_atomic_get_output_bus_fmts(struct drm_bridge *bridge, */ if (max_bpc >= 16 && info->bpc == 16) { - if (info->color_formats & DRM_COLOR_FORMAT_YCRCB444) + if (hdmi->sink_is_hdmi && info->color_formats & DRM_COLOR_FORMAT_YCRCB444) output_fmts[i++] = MEDIA_BUS_FMT_YUV16_1X48; output_fmts[i++] = MEDIA_BUS_FMT_RGB161616_1X48; } if (max_bpc >= 12 && info->bpc >= 12) { - if (info->color_formats & DRM_COLOR_FORMAT_YCRCB422) + if (hdmi->sink_is_hdmi && info->color_formats & DRM_COLOR_FORMAT_YCRCB422) output_fmts[i++] = MEDIA_BUS_FMT_UYVY12_1X24; - if (info->color_formats & DRM_COLOR_FORMAT_YCRCB444) + if (hdmi->sink_is_hdmi && info->color_formats & DRM_COLOR_FORMAT_YCRCB444) output_fmts[i++] = MEDIA_BUS_FMT_YUV12_1X36; output_fmts[i++] = MEDIA_BUS_FMT_RGB121212_1X36; } if (max_bpc >= 10 && info->bpc >= 10) { - if (info->color_formats & DRM_COLOR_FORMAT_YCRCB422) + if (hdmi->sink_is_hdmi && info->color_formats & DRM_COLOR_FORMAT_YCRCB422) output_fmts[i++] = MEDIA_BUS_FMT_UYVY10_1X20; - if (info->color_formats & DRM_COLOR_FORMAT_YCRCB444) + if (hdmi->sink_is_hdmi && info->color_formats & DRM_COLOR_FORMAT_YCRCB444) output_fmts[i++] = MEDIA_BUS_FMT_YUV10_1X30; output_fmts[i++] = MEDIA_BUS_FMT_RGB101010_1X30; } - if (info->color_formats & DRM_COLOR_FORMAT_YCRCB422) + if (hdmi->sink_is_hdmi && info->color_formats & DRM_COLOR_FORMAT_YCRCB422) output_fmts[i++] = MEDIA_BUS_FMT_UYVY8_1X16; - if (info->color_formats & DRM_COLOR_FORMAT_YCRCB444) + if (hdmi->sink_is_hdmi && info->color_formats & DRM_COLOR_FORMAT_YCRCB444) output_fmts[i++] = MEDIA_BUS_FMT_YUV8_1X24; /* Default 8bit RGB fallback */