Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4037586rwd; Mon, 29 May 2023 22:40:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4gMwfC0Ao8+B4BPDhDi+XjzaUg14v4foEye4ZczaNmYupFGQLNaAv9cvWS3+bSKiPZHaI8 X-Received: by 2002:a17:90b:4c4d:b0:256:95d3:7d3e with SMTP id np13-20020a17090b4c4d00b0025695d37d3emr1169303pjb.49.1685425223008; Mon, 29 May 2023 22:40:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685425222; cv=none; d=google.com; s=arc-20160816; b=laR+glh7kPhb+kHXTwnk/VXQQfyHgmjxitz+tJvl/me+TC6G0TPrli/yGlrhliai6J tTWFlLmF18bp4rCrm1H2wv5ro7R7vNVmW96XAsYYpak2F7gVpJdXmMccfvMqVjmpUbfr IZnP5+xyS3zn0CEFuHaGCcyUk2Io5PJbbcmNni2/fxZ6a4uv4cxeWYTnmfx8D7GVBxVi Z7oWmYHSMaVtHDnM7kYgan3HtD2Iq3w8b/rRjnU2xTj1l2RkCmY0bYxrrDWjkSxYMuzL J4F/2Xg4bagAJ17Rk1CGM8fwPOKK2gtbiMV3kZhmcq8/JqLg6rx9uOstAqnyqJCZzTe5 TIQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=GPrZJ1FuK/lyhedvMoDkzqpf5lW1XKFTD6vF/dQBu7U=; b=LfdN7Zf7eOIGyCWWs+MH5F13PS9AMDC/5xIbD2FhMGImzb+yeFkZWyL3OiTgNsihMp jUla8ZcoCR/7+wNIaEF+sHqo2x9YDrDcNrP4H/Ji5Y659qdZnMJQ7jRpI0jCVMPm9tX4 Bv4q09Q6OEWa7mlfteTNmnbIblejGZNlyJMXNzjBEAYYUSRRAzcUtNHCKIA0hPKCGS4j s7/yhB9HJ5OcHSgQyKqb3qcw0FTOckurHEmmiZpLnTCdqo5r0lUnTFWBLAqu9uX0RUjM xgwxhXL4S/XewTtq7iU+2R+0pN4RP17VemkmY1p9o6Ld3oniHo+89gf33M6fklkFOB1k 2drA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="RHduFg/S"; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e1-20020a17090a818100b0024753ec4dccsi9824705pjn.124.2023.05.29.22.40.10; Mon, 29 May 2023 22:40:22 -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=@chromium.org header.s=google header.b="RHduFg/S"; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229461AbjE3FPv (ORCPT + 99 others); Tue, 30 May 2023 01:15:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229775AbjE3FPr (ORCPT ); Tue, 30 May 2023 01:15:47 -0400 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA372EA for ; Mon, 29 May 2023 22:15:44 -0700 (PDT) Received: by mail-il1-x130.google.com with SMTP id e9e14a558f8ab-33b4e351c2aso13897325ab.0 for ; Mon, 29 May 2023 22:15:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685423744; x=1688015744; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=GPrZJ1FuK/lyhedvMoDkzqpf5lW1XKFTD6vF/dQBu7U=; b=RHduFg/SkfnNpEeH/Z8vVcemveNn2K0KJ8KJJxlqhyUzci5D1F0GWnxfQFmx4zY6bU 7W72z1XSBRExMGDxJsL04fAQnnEQQ7FfGeDoRceqiRj4BGZqzz5JHQxR1a7MCOXSHrs6 Rq+ivMx9W4zKYugEaw891iW/g7lyS3P3/dkVg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685423744; x=1688015744; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GPrZJ1FuK/lyhedvMoDkzqpf5lW1XKFTD6vF/dQBu7U=; b=RtJXeXre9PuL36iworwVOEFCcagNHSCwAXMmMtgFtAL5tpesH+HfJi1A2ORqbe6KUd m+QpJTCwdKwMcu7KlMsu8989XRxlxYNIFJjftoe01X0J8yoLhMQbt+HI/ICkSM0H+NDi RXAD3/+Zpt8wUyyBEHrJxhL5ziITO5ZHgEHaMVuyELIUsCFmYmLi7s6F4oZiN1HFC/R3 H3LK/KOwIoDOcrs37pqFUsjPbvWadgVGveBtUh9EJdY9YPqvVcUcn47G1BXrCygtSuhW Y9A5/FS5hP9MJoRh0vWMtZFf9/eSPIhvCSz9HtTPC5i8TP3br4i0xSxIC/SUzmCtt+kM ropQ== X-Gm-Message-State: AC+VfDy8Vb3oyYcPxxbvljCUw9BB3I5tNbp2wcqB+D8MR79AHpaxmANT GB2MBaKzBUcaGv+6KMT7zeOSmtQPCbhP8JY5IeraIQ== X-Received: by 2002:a92:cd49:0:b0:339:f011:77f8 with SMTP id v9-20020a92cd49000000b00339f01177f8mr1029659ilq.16.1685423744156; Mon, 29 May 2023 22:15:44 -0700 (PDT) MIME-Version: 1.0 References: <20230331091145.737305-1-treapking@chromium.org> <20230331091145.737305-5-treapking@chromium.org> In-Reply-To: From: Pin-yen Lin Date: Tue, 30 May 2023 13:15:33 +0800 Message-ID: Subject: Re: [PATCH v15 04/10] dt-bindings: display: bridge: anx7625: Add mode-switch support To: Stephen Boyd Cc: Andrzej Hajda , Andy Shevchenko , Benson Leung , Daniel Scally , Daniel Vetter , David Airlie , Greg Kroah-Hartman , Guenter Roeck , Heikki Krogerus , Jernej Skrabec , Jonas Karlman , Krzysztof Kozlowski , Laurent Pinchart , Neil Armstrong , Prashant Malani , "Rafael J . Wysocki" , Rob Herring , Robert Foss , Sakari Ailus , Xin Ji , Marek Vasut , Hsin-Yi Wang , Thomas Zimmermann , AngeloGioacchino Del Regno , Lyude Paul , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-acpi@vger.kernel.org, chrome-platform@lists.linux.dev, =?UTF-8?B?TsOtY29sYXMgRiAuIFIgLiBBIC4gUHJhZG8=?= , Javier Martinez Canillas , linux-kernel@vger.kernel.org, Krzysztof Kozlowski , Chen-Yu Tsai , jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On Fri, May 12, 2023 at 1:30=E2=80=AFAM Stephen Boyd = wrote: > > Quoting Pin-yen Lin (2023-05-09 20:41:54) > > On Sat, Apr 29, 2023 at 12:47=E2=80=AFPM Stephen Boyd wrote: > > > > > > Good point. I'm suggesting to make the drm bridge chain into a tree. = We > > > need to teach drm_bridge core about a mux, and have some logic to > > > navigate atomically switching from one output to another. I was talki= ng > > > with dianders@ and he was suggesting to use bridge attach/detach for > > > this. I'm not sure that will work though because that hook is only > > > called when the encoder is attached to the bridge. > > > > > > It may also turn out that this helps with DP multi-stream transport > > > (MST). As far as I can recall DP MST doesn't mesh well with drm_bridg= e > > > designs because it wants to operate on a drm_connector and > > > drm_bridge_connector_init() wants to make only one drm_connector for = a > > > chain of bridges. If you squint, the anx7625 could be an MST "branch" > > > that only supports one drm_connector being enabled at a time. Maybe t= hat > > > is what we should do here, make drm_bridge support creating more than > > > one drm_connector and when there is a mux in the tree it walks both > > > sides and runs a callback similar to struct > > > drm_dp_mst_topology_cbs::add_connector() to tell the encoder that > > > there's another possible drm_connector here. > > > > I have been surveying the approaches to change the bridge chain in > > runtime, and I found this thread[1]. Quoting from Daniel: > > I find the lore links easier to read. > > > "... exchanging the bridge chain isn't supported, there's no locking > > for that since it's assumed to be invariant over the lifetime of the > > drm_device instance. The simplest way to make that happen right now is = to > > have 2 drm_encoder instances, one with the lvds bridge chain, the other > > with the hdmi bridge chain, and select the right encoder/bridge chain > > depending upon which output userspace picks. > > ... > > I wouldn't try to make bridge chains exchangeable instead, that's > > headaches - e.g. with dp mst we've also opted for a bunch of fake > > drm_encoders to model that kind of switching." > > > > I'm not sure how we register two encoders properly, though. Do we make > > the encoder driver check all the downstream bridges and register two > > drm_encoder when a bridge is acting as a mux? > > I honestly don't know because I'm not a DRM expert. Maybe Jagan or DRM > bridge maintainers can add to the thread here. > > I kept reading the thread[2] and I think they settled on 2 drm_encoders > because they're different display formats (LVDS vs. HDMI) and 2 > drm_connector structures. But then I watched the youtube video from this > thread[3] and it seems like 1 drm_encoder is actually what should be > done because there is really only DSI at the root. There's at least > three people working on this topic of muxing displays though. Good news? > > The analogy between their gpio controlled mux and this anx part with a > crosspoint switch is that the gpio is like the crosspoint switch, but > the gpio is like a virtual mux? If the gpio is asserted for them, one > display bridge is enabled (HDMI) and the other one is not (LVDS). > > In this case, the type-c cables may be connected to both > usb-c-connectors and HPD may be asserted on both, but only one > drm_connector will be able to attach to the 1 drm_encoder at a time. If > we had 2 drm_encoders it would be possible to attach both encoders to > both drm_connectors at the same time, which is impossible because it's a > mux. Indicating that each connector is connected is OK when HPD is high > on both usb-c-connectors. Userspace will have to attach an encoder to > the drm_connector it wants to use, and the drm_connector will indicate > which drm_encoders are possible for it, so all the information will be > provided to userspace in this design. > > I think it really comes down to implementing the tree walking logic in > the drm bridge APIs. The problem is things like > drm_bridge_get_next_bridge(), drm_bridge_get_prev_bridge(), and > drm_for_each_bridge_in_chain() which will have to operate on a tree > instead of a list. There's also drm_bridge_chain_get_first_bridge() and > drm_bridge_attach(). The good news is most of these APIs are used > sparingly. > > Maybe the simplest way to handle this is to maintain a tree of bridges > and generate bridge chains when an encoder is attached to a connector in > the tree. Presumably there is only one connector possible for a leaf of > the bridge tree, and one encoder at the root of the bridge chain. From > the drm_bridge structure, you'll only be able to iterate over the bridge > chain that is currently configured. Same for the encoder, you'll only be > able to walk the currently configured bridge chain from struct > drm_encoder::bridge_chain. If I understand correctly, encoders are attached to connectors when the driver initializes itself. Do you mean that the chain should be generated when a connector is connected? If so, "attach" becomes adding a bridge to the bridge "tree", and the chain is only determined after a connector is plugged. When HPD fires, we can use the .detect callback to find the right connector and form the bridge chain. The following changes would need to be made to the existing APIs: (1) Some of the chain-traversing helpers (e.g., drm_for_each_bridge_in_chain()) need to be changed to traversing the bridge tree. (2) Drivers that hold a pointer to the connector need to either hold a list of possible connectors or use a helper to get the active connector at runtime. I don't really know if this would work out. e.g., Do we really not need the chain when the connector is disconnected? I will appreciate any suggestions on this. Regards, Pin-yen > This hinges on the idea that the bridge_chain is a list, not a tree, and > that it only needs to exist when an encoder is attached to a connector. > When an encoder isn't attached to a connector the bridges will be in the > tree, and probably that tree structure will be maintained in the bridge > driver itself knowing that there is one input side bridge and two output > side bridges. When the input bridge is attached, it should be able to > query the output side bridges for the connector that the encoder is > attaching to and configure the mux and hook the input bridge to the > correct output bridge. > > [2] https://lore.kernel.org/all/CAPj87rO7a=3DNbarOyZp1pE=3D19Lf2aGjWu7sru= -eHwGjX0fpN+-A@mail.gmail.com/ > [3] https://lore.kernel.org/all/CAMty3ZAQyADGLVcB13qJdEy_BiZEKpyDfCr9QrM-= ucFLFPZLcw@mail.gmail.com/