Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6826862rwn; Tue, 13 Sep 2022 09:29:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR6bNmPTEhieaHcD/cDF73ubkPkuv/oVzE7LUOxNwU9PAHztkYtq8N7u9LKtCfWf24ixA7eE X-Received: by 2002:a05:6a00:2181:b0:51b:560b:dd30 with SMTP id h1-20020a056a00218100b0051b560bdd30mr33913830pfi.44.1663086576381; Tue, 13 Sep 2022 09:29:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663086576; cv=none; d=google.com; s=arc-20160816; b=C8KCPapSXEw8iT4TrzsgLjAoy20PHNjGTB1QCmXqq5jeuL0Hr4rAfzxGksnylHFNMC 8DheNLZGaKYO3dGkJkid1mFr1VpuJFHi2qYRr5reGsIGxCnDldK9uYPZUrEb5l/JURlv fJo+kpTIumt/vEe0JBC2UxcE0zs0hlrh4iJGgJ7qA82HxXOYDx2EZ7wGrMJZaZ8peLU4 gRB+3cVYdeHJTle49mHbT2Jf7MRUx4MSaVw+zveFLGXZLvMU4o4hZi5XGQSBQTvXdHPI NNUPJDebmtbxYjmIG2C40qzFoJcRdUiz9Fm4LBRu78CtgDwUbm/nyL04ZINoNNaommPA 2VYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yxrifJXorOxED3qE8h6mtLrwARAJyEIsH0tLyQZ+nLs=; b=TE+evJbe9IhO6N/vyq18XsBXHnBq8dAbPvhSqAtJKuhS3tkb+7AFSkWUABZgSrR0nI 3NIu/OQ3FNDzmPwxPgxz4rI9RKS59oKUYckVrakU3SY214cKDtanzHj8i2UfNhuY/rpq xas9cSw8ULf6527/84zVQKT3sYpwFu+hKVM0OcfXULsMvFeJ+wWgokOkqVmCd66iN7Dk xArxMw+UsQDoe6SzYC/LXnhDvv7Lj1l218WhGwfq8tJKIVXH0NqcPuPyIzFISnorv+8l re351kbB+9ImocUA4oRAJ2JqMd37wOVfhbeCUVowtRXzVOqm6ctfvDDTZgV/kpzzFEOf MTdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TqUrKfwY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e25-20020a62aa19000000b0052f44beb0d1si10920577pff.291.2022.09.13.09.29.23; Tue, 13 Sep 2022 09:29:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TqUrKfwY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230139AbiIMOrP (ORCPT + 99 others); Tue, 13 Sep 2022 10:47:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234587AbiIMOoC (ORCPT ); Tue, 13 Sep 2022 10:44:02 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FA7661116; Tue, 13 Sep 2022 07:23:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BA87DB80F63; Tue, 13 Sep 2022 14:21:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23ED3C433D6; Tue, 13 Sep 2022 14:21:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663078883; bh=yFnDgQPHh04lImNs9zxwG2wlMAoD+s2Zxc3+wS2Q0ZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TqUrKfwYxW1RUDFEo/bf7ogC/Akxb7gt1JXEwJXtre0+GfUh8IlEBg6UUU4+rOnfD fXoUESyJX8Se0bnBgwN3N/S0RYgYCLKZD+fk3WDzPgI9qTGYU8P/eceNBUJdi4ylTX Znx/Vb/6pl01B/cp1EDzPA3LUn3BlqTgl417QBFQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Neil Armstrong , Sam Ravnborg , Stefan Agner Subject: [PATCH 5.15 119/121] drm/bridge: display-connector: implement bus fmts callbacks Date: Tue, 13 Sep 2022 16:05:10 +0200 Message-Id: <20220913140402.477899469@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140357.323297659@linuxfoundation.org> References: <20220913140357.323297659@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Neil Armstrong commit 7cd70656d1285b79c001f041a017fcfee4292ff9 upstream. Since this bridge is tied to the connector, it acts like a passthrough, so concerning the output & input bus formats, either pass the bus formats from the previous bridge or return fallback data like done in the bridge function: drm_atomic_bridge_chain_select_bus_fmts() & select_bus_fmt_recursive. This permits avoiding skipping the negociation if the remaining bridge chain has all the bits in place. Without this bus fmt negociation breaks on drm/meson HDMI pipeline when attaching dw-hdmi with DRM_BRIDGE_ATTACH_NO_CONNECTOR, because the last bridge of the display-connector doesn't implement buf fmt callbacks and MEDIA_BUS_FMT_FIXED is used leading to select an unsupported default bus format from dw-hdmi. Signed-off-by: Neil Armstrong Reviewed-by: Sam Ravnborg Link: https://patchwork.freedesktop.org/patch/msgid/20211020123947.2585572-2-narmstrong@baylibre.com Cc: Stefan Agner Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/bridge/display-connector.c | 86 +++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) --- a/drivers/gpu/drm/bridge/display-connector.c +++ b/drivers/gpu/drm/bridge/display-connector.c @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -87,10 +88,95 @@ static struct edid *display_connector_ge return drm_get_edid(connector, conn->bridge.ddc); } +/* + * Since this bridge is tied to the connector, it acts like a passthrough, + * so concerning the output bus formats, either pass the bus formats from the + * previous bridge or return fallback data like done in the bridge function: + * drm_atomic_bridge_chain_select_bus_fmts(). + * This supports negotiation if the bridge chain has all bits in place. + */ +static u32 *display_connector_get_output_bus_fmts(struct drm_bridge *bridge, + struct drm_bridge_state *bridge_state, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state, + unsigned int *num_output_fmts) +{ + struct drm_bridge *prev_bridge = drm_bridge_get_prev_bridge(bridge); + struct drm_bridge_state *prev_bridge_state; + + if (!prev_bridge || !prev_bridge->funcs->atomic_get_output_bus_fmts) { + struct drm_connector *conn = conn_state->connector; + u32 *out_bus_fmts; + + *num_output_fmts = 1; + out_bus_fmts = kmalloc(sizeof(*out_bus_fmts), GFP_KERNEL); + if (!out_bus_fmts) + return NULL; + + if (conn->display_info.num_bus_formats && + conn->display_info.bus_formats) + out_bus_fmts[0] = conn->display_info.bus_formats[0]; + else + out_bus_fmts[0] = MEDIA_BUS_FMT_FIXED; + + return out_bus_fmts; + } + + prev_bridge_state = drm_atomic_get_new_bridge_state(crtc_state->state, + prev_bridge); + + return prev_bridge->funcs->atomic_get_output_bus_fmts(prev_bridge, prev_bridge_state, + crtc_state, conn_state, + num_output_fmts); +} + +/* + * Since this bridge is tied to the connector, it acts like a passthrough, + * so concerning the input bus formats, either pass the bus formats from the + * previous bridge or MEDIA_BUS_FMT_FIXED (like select_bus_fmt_recursive()) + * when atomic_get_input_bus_fmts is not supported. + * This supports negotiation if the bridge chain has all bits in place. + */ +static u32 *display_connector_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) +{ + struct drm_bridge *prev_bridge = drm_bridge_get_prev_bridge(bridge); + struct drm_bridge_state *prev_bridge_state; + + if (!prev_bridge || !prev_bridge->funcs->atomic_get_input_bus_fmts) { + u32 *in_bus_fmts; + + *num_input_fmts = 1; + in_bus_fmts = kmalloc(sizeof(*in_bus_fmts), GFP_KERNEL); + if (!in_bus_fmts) + return NULL; + + in_bus_fmts[0] = MEDIA_BUS_FMT_FIXED; + + return in_bus_fmts; + } + + prev_bridge_state = drm_atomic_get_new_bridge_state(crtc_state->state, + prev_bridge); + + return prev_bridge->funcs->atomic_get_input_bus_fmts(prev_bridge, prev_bridge_state, + crtc_state, conn_state, output_fmt, + num_input_fmts); +} + static const struct drm_bridge_funcs display_connector_bridge_funcs = { .attach = display_connector_attach, .detect = display_connector_detect, .get_edid = display_connector_get_edid, + .atomic_get_output_bus_fmts = display_connector_get_output_bus_fmts, + .atomic_get_input_bus_fmts = display_connector_get_input_bus_fmts, + .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, }; static irqreturn_t display_connector_hpd_irq(int irq, void *arg)