From patchwork Sat Feb 18 11:17:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pin-yen Lin X-Patchwork-Id: 13145530 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 76521C61DA4 for ; Sat, 18 Feb 2023 11:17:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=tRUarQyWTXy/UaQ+aTCiS9aEshqx6SrntwaJME4vnY0=; b=o+owAsZe5cMD/55WO/F9pAgWen lyy7+33VQmSG7lIoWqlRzl02VGSkhZPOiqZ4ocvtZMja3CjWD+ONbtj4hik59GO3Heo+XlmdHeMOt oz40yMeZW9ged56rA+GY3LtYNLmOjylJnQR2DovmlHf1ARVhxCoHPytAjWWZJ3zS0C+NrF6fjrppq VWV2lFwPsxR9oPvvvSEaGxuv6sOKgYtXZfou6onTmxVqm/6qrsgQg7y+oUzaD8/s4QihJeJLcf+z6 SnLJ8nQJCNMYWwVkaoyui6hTapGL71nYgfXGwqmMvWaJ7Vy1asCGrV2LOJbH3zxwt5YNm3OhmbaoR CE7XBMXg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pTLDs-00Gqco-I7; Sat, 18 Feb 2023 11:17:44 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pTLDf-00GqVp-TM for linux-mediatek@lists.infradead.org; Sat, 18 Feb 2023 11:17:37 +0000 Received: by mail-pl1-x635.google.com with SMTP id e14so1831321plg.8 for ; Sat, 18 Feb 2023 03:17:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tRUarQyWTXy/UaQ+aTCiS9aEshqx6SrntwaJME4vnY0=; b=FhaH7iwlgirzBhkctvbPIaE33nUBelcGHAF8fq0lsjOkQ+cusRFz/4cccjVw6NEftK PpoX0TZ8w3vqQVGe5P/lYxblKHcsFlSVpBKNCV54TFjvgawSpSzJc1EE02sPm2cIp82b 392DVfxuznUnL2wiI4prL2FfCxja2ElN7chAA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding: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=tRUarQyWTXy/UaQ+aTCiS9aEshqx6SrntwaJME4vnY0=; b=3i9FYov8PeBoCXHcSrhJC+DVsHUZJgZhaJSnj7+6Kme/8WH61E3CSFYPurUDIKQqbG X0ILwnqybLdsARFjI84gJlmMDPc2/Fh6ejZ1Hb+lTlkKUxtFFg5WkKVjKSKO9xDnDvRf 55Yz+hKFFPLSLzP08dR4Pr538CljWEp3hGtJ6nlI/yUhR8R8B2rVtqpTuFFjxXwIUy0d oDUIzAfU5AwAAqRvuXzippaVxlis4cfAinQ6mX3PMhN1GYe6kOuVD1C3kZ4b/AJ052p9 20o0s7ZzuQxDROtoo7f+bZCy/SJ0MDgLSkGYZ+FMVAEsW6/nCrx7sGsoTbuCeP5fLWg0 h7HA== X-Gm-Message-State: AO0yUKVAUUxqug9m3yoEWq0QsfIKee5ovWwpBzNV8MGRPultwRgSbgkL 8n/Lpe5USZg8D9Q37OVycuV0Yg== X-Google-Smtp-Source: AK7set+FohWYixBOFWTvodfYG9ONEn4rCbUp2cY1CE91qYHZ6E0/D4C1ES2aYaY6oImj8VUL+8mG8A== X-Received: by 2002:a05:6a20:1610:b0:c7:5983:7a82 with SMTP id l16-20020a056a20161000b000c759837a82mr7002881pzj.27.1676719049830; Sat, 18 Feb 2023 03:17:29 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:88dd:be84:8f65:fec2]) by smtp.gmail.com with ESMTPSA id 23-20020aa79157000000b005a8686b72fcsm4457829pfi.75.2023.02.18.03.17.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 03:17:29 -0800 (PST) From: Pin-yen Lin To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Benson Leung Cc: Chun-Kuang Hu , devicetree@vger.kernel.org, Nicolas Boichat , chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, Guenter Roeck , Matthias Brugger , dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, Philipp Zabel , linux-arm-kernel@lists.infradead.org, Pin-yen Lin Subject: [PATCH v3 1/5] dt-bindings: display: bridge: Add ddc-i2c-bus for anx7688 Date: Sat, 18 Feb 2023 19:17:08 +0800 Message-Id: <20230218111712.2380225-2-treapking@chromium.org> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog In-Reply-To: <20230218111712.2380225-1-treapking@chromium.org> References: <20230218111712.2380225-1-treapking@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230218_031732_787062_8EC14819 X-CRM114-Status: GOOD ( 10.28 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Introduce a optional "ddc-i2c-bus" property for anx7688 bridge. This allows the bridge to register a .get_edid callback. Signed-off-by: Pin-yen Lin --- Changes in v3: - New in v3 .../bindings/display/bridge/google,cros-ec-anx7688.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/display/bridge/google,cros-ec-anx7688.yaml b/Documentation/devicetree/bindings/display/bridge/google,cros-ec-anx7688.yaml index a44d025d33bd..9d5ce8172e88 100644 --- a/Documentation/devicetree/bindings/display/bridge/google,cros-ec-anx7688.yaml +++ b/Documentation/devicetree/bindings/display/bridge/google,cros-ec-anx7688.yaml @@ -25,6 +25,10 @@ properties: maxItems: 1 description: I2C address of the device. + ddc-i2c-bus: + description: phandle link to the I2C controller used for DDC EDID probing + $ref: /schemas/types.yaml#/definitions/phandle + ports: $ref: /schemas/graph.yaml#/properties/ports @@ -59,6 +63,7 @@ examples: anx7688: anx7688@2c { compatible = "google,cros-ec-anx7688"; reg = <0x2c>; + ddc-i2c-bus = <&hdmiddc0>; ports { #address-cells = <1>; From patchwork Sat Feb 18 11:17:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pin-yen Lin X-Patchwork-Id: 13145531 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 7AC4AC61DA4 for ; Sat, 18 Feb 2023 11:18:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=s6dHGa2Xgzvsmpkv1OMI3GGLXSZg9rQflTYWwQPQ1MY=; b=mOdDXdXNaeQ4OL+gUzTdtyjhR3 jovyOvSB4Fao5SKiDUUBdJriRY6EhjC3Se0ngJ2c1pZdowYILzkqDmJsyZiae6PEZCRgkimScxsOk MWSsKt53oxKkzpfi522O7hyWdtKFt7RrO7zNFqKqF8oWfsc4IAfYgdnjqCv2gr5RAhS9vJ6dOVdbH 34ZR85V3tD0qSwlk8g6Ql/TYFgb6HrhSKVDICi5mQz50qhsgtmMA5gDy52HDi5n6HQFkOtWgO3SOr W9vkmgT3RsT6EAPQlzuHW40a9gzy7M4DZ9oYmy0HbcfIiSDbKWcXcoM5BYhe1NuLnF8hKWiNQMK3/ zEAIie+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pTLEJ-00GqqQ-JS; Sat, 18 Feb 2023 11:18:11 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pTLDj-00GqX2-Qk for linux-mediatek@lists.infradead.org; Sat, 18 Feb 2023 11:17:39 +0000 Received: by mail-pj1-x102f.google.com with SMTP id rm14-20020a17090b3ece00b00229ca6a4636so594296pjb.0 for ; Sat, 18 Feb 2023 03:17:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=s6dHGa2Xgzvsmpkv1OMI3GGLXSZg9rQflTYWwQPQ1MY=; b=JY77n9tlE/HK4ICl9GMTuT3xOecSN1t2rBwKN2r6bw9DpB3ugVZniqFJmEP/ZS6pdn FZrSdrEN79gLPWOMUK+L66wCzzs3r3Q8uln5PXzclN7b87DKiNVjqYU3DiNx/XLz0qPb Of7YZ4EvDZl+ErstHa8fMnpIbvTchMOkO2RII= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding: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=s6dHGa2Xgzvsmpkv1OMI3GGLXSZg9rQflTYWwQPQ1MY=; b=WWDmwBk0kdhxjfyieeECZQmjmRRd8fjVOmkVsTWJtlyLAStLYoMJxJDTI2x774XwLi fcB07Nq6NJjImPLQhMQFCz4wIpLTsgGi8Gzk0QCEfBYCZaFxBTyBWD0Bq45HkUlfRABe t5okuO2I4a3OGj7jAPfSRxIsx3OIkJCGCsSXXSaQTEIUJVbTSttXxDui5v8BH6Fn6xHR pSQB7s+SgUy6CCNIJ25lr4hAp7tYANsutxQJKVohtJnRiIG8uX6I6EpmBlxOrLuaXvNX VdRZ4jxkGNFEq6/F4htpFPPr3h0LmeNTfjezQ1c57Q5pU1w5uA6tidTMQWhaqCgBsRJD +1dg== X-Gm-Message-State: AO0yUKX4LvRiJ50UvsmUkSrc/J2zzLJBmxwuntHgX7SIPrB8N/OXE/FK CxsoHs9Mi+Cx+AiaBSpY2+D1wQ== X-Google-Smtp-Source: AK7set/hFbuR6/pwEBTsgMDjBxXuhNwX/DV7X+3lXNMmHiMnzFAlbjwwtNwH3GYu9AIwOZM3LSHFcw== X-Received: by 2002:a05:6a20:4e27:b0:c6:858d:81b7 with SMTP id gk39-20020a056a204e2700b000c6858d81b7mr3115816pzb.25.1676719054085; Sat, 18 Feb 2023 03:17:34 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:88dd:be84:8f65:fec2]) by smtp.gmail.com with ESMTPSA id 23-20020aa79157000000b005a8686b72fcsm4457829pfi.75.2023.02.18.03.17.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 03:17:33 -0800 (PST) From: Pin-yen Lin To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Benson Leung Cc: Chun-Kuang Hu , devicetree@vger.kernel.org, Nicolas Boichat , chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, Guenter Roeck , Matthias Brugger , dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, Philipp Zabel , linux-arm-kernel@lists.infradead.org, Pin-yen Lin Subject: [PATCH v3 2/5] drm/bridge: Add .get_edid callback for anx7688 driver Date: Sat, 18 Feb 2023 19:17:09 +0800 Message-Id: <20230218111712.2380225-3-treapking@chromium.org> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog In-Reply-To: <20230218111712.2380225-1-treapking@chromium.org> References: <20230218111712.2380225-1-treapking@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230218_031736_835976_4A556188 X-CRM114-Status: GOOD ( 13.71 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Allow the driver to read EDID when ddc-i2c-bus phandle is present in the device node. Signed-off-by: Pin-yen Lin --- Changes in v3: - New in v3 drivers/gpu/drm/bridge/cros-ec-anx7688.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/gpu/drm/bridge/cros-ec-anx7688.c b/drivers/gpu/drm/bridge/cros-ec-anx7688.c index fa91bdeddef0..a16294c87940 100644 --- a/drivers/gpu/drm/bridge/cros-ec-anx7688.c +++ b/drivers/gpu/drm/bridge/cros-ec-anx7688.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -91,14 +92,24 @@ static bool cros_ec_anx7688_bridge_mode_fixup(struct drm_bridge *bridge, return totalbw >= requiredbw; } +static struct edid *cros_ec_anx7688_get_edid(struct drm_bridge *bridge, + struct drm_connector *connector) +{ + struct cros_ec_anx7688 *anx7688 = bridge_to_cros_ec_anx7688(bridge); + + return drm_get_edid(connector, anx7688->bridge.ddc); +} + static const struct drm_bridge_funcs cros_ec_anx7688_bridge_funcs = { .mode_fixup = cros_ec_anx7688_bridge_mode_fixup, + .get_edid = cros_ec_anx7688_get_edid, }; static int cros_ec_anx7688_bridge_probe(struct i2c_client *client) { struct device *dev = &client->dev; struct cros_ec_anx7688 *anx7688; + struct device_node *phandle; u16 vendor, device, fw_version; u8 buffer[4]; int ret; @@ -153,6 +164,19 @@ static int cros_ec_anx7688_bridge_probe(struct i2c_client *client) DRM_WARN("Old ANX7688 FW version (0x%04x), not filtering\n", fw_version); + + phandle = of_parse_phandle(dev->of_node, "ddc-i2c-bus", 0); + if (phandle) { + anx7688->bridge.ddc = of_get_i2c_adapter_by_node(phandle); + of_node_put(phandle); + if (!anx7688->bridge.ddc) + return -EPROBE_DEFER; + } else { + dev_dbg(dev, "No I2C bus specified, disabling EDID readout\n"); + } + if (anx7688->bridge.ddc) + anx7688->bridge.ops |= DRM_BRIDGE_OP_EDID; + anx7688->bridge.funcs = &cros_ec_anx7688_bridge_funcs; drm_bridge_add(&anx7688->bridge); From patchwork Sat Feb 18 11:17:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pin-yen Lin X-Patchwork-Id: 13145532 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 BF44AC61DA4 for ; Sat, 18 Feb 2023 11:18:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=cUC5VpRQ+Ac+lj9Yg4rT6e7fy64d+1PZ95QiUW9T0f0=; b=mnG4UhTwzDm0V4SD6RSErQmDK8 myL2Uw16QaG+TKdk0ZtbYpMf31AUURjhSXpndhcCsG9hWcaBg0pt0uTBAIFE+X8dfKXRVRHzubwV1 5MASaIcZBlvBZUMoUc0bbEKthmf1WS9Ma6JGtsxkEp6cq1sZf1t9qOc3VnBvtvIlNBBYc4Wl9MPPE kdhhVe9nbwPvivXg74BpatVU5FcCG6JnubY5vv7DN3Yewh9JDZl12A2QQpzIRhqzuZ8iTlofafoTg lmGwlkilWHS5aJboy6ZKDyTaEMlnpfI6j8ljk1NP9D2vnmWHo9ZFSU1fZaOm43HEmM/W6yjgKLdob rT/4HsYQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pTLEa-00Gqzq-Gu; Sat, 18 Feb 2023 11:18:28 +0000 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pTLDr-00Gqaf-O7 for linux-mediatek@lists.infradead.org; Sat, 18 Feb 2023 11:17:45 +0000 Received: by mail-pf1-x42a.google.com with SMTP id dc6so269715pfb.7 for ; Sat, 18 Feb 2023 03:17:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cUC5VpRQ+Ac+lj9Yg4rT6e7fy64d+1PZ95QiUW9T0f0=; b=L6RS2NfSIeSXxStr65xeKi50qynabbVHyn1UXxRcFOQufPLZtK08i1OiLJEp9hJQ7K rUKjpKY0g3r8yXPkvsop7ktcGvX2zSGJcNmdq9qMQfKgrmyyEm3AEfdHnRXlsJ/p2H0S EVUvsiSqyjhofHzgHpHBcKINd4JPvlks4JsmU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding: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=cUC5VpRQ+Ac+lj9Yg4rT6e7fy64d+1PZ95QiUW9T0f0=; b=m0YA3p5TYDQIeewUQ1sFq4fF4+F/eGRjfbHZTMNmSGF1R3DCvWM0RZshtyFgoDv977 /MnEEE/iNjC50u/fbvvaIcRVTouQbaWnIbtyw7IH03bsbCAhDwgAzkZH0j3jjr9JqIiU 0u6Xh6+/2D//NzSdz5WqkQgZ0qmlmi7we0bll2TI/1GqKHu+1aqwkozUy9OLOdeX1V+I r1vskpkB2hYupX36E3RYvbUVa4xg/dh+kxfrXOsMY5X0JwlP2mNl03xSeIlmsIsQ+mVA DVqOTuXrioZNbwtDZutnFqAL6TmtrNSMGQzaB71o981DDAoIUeuWRFCVBlKS8IJ8OFAX ehWQ== X-Gm-Message-State: AO0yUKU0tKuRE7gZXQjZ8sCE9md9wYsX0dU4GyW8yCp3DR1DgaDqcBrT /l9o3tKdKlVcB9YJ2Qu9rN3pag== X-Google-Smtp-Source: AK7set/DVZJFasYpEc2/i7C4jXudZU0Ni1NtI2PEwLI8N4heb0cpLrlwrxj4855uNK5y7WV7aIRFHw== X-Received: by 2002:a62:5f86:0:b0:5a9:cb37:cfb7 with SMTP id t128-20020a625f86000000b005a9cb37cfb7mr5172705pfb.25.1676719060719; Sat, 18 Feb 2023 03:17:40 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:88dd:be84:8f65:fec2]) by smtp.gmail.com with ESMTPSA id 23-20020aa79157000000b005a8686b72fcsm4457829pfi.75.2023.02.18.03.17.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 03:17:40 -0800 (PST) From: Pin-yen Lin To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Benson Leung Cc: Chun-Kuang Hu , devicetree@vger.kernel.org, Nicolas Boichat , chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, Guenter Roeck , Matthias Brugger , dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, Philipp Zabel , linux-arm-kernel@lists.infradead.org, Pin-yen Lin Subject: [PATCH v3 3/5] drm/mediatek: Remove .get_edid callback Date: Sat, 18 Feb 2023 19:17:10 +0800 Message-Id: <20230218111712.2380225-4-treapking@chromium.org> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog In-Reply-To: <20230218111712.2380225-1-treapking@chromium.org> References: <20230218111712.2380225-1-treapking@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230218_031743_826892_4551B5CA X-CRM114-Status: GOOD ( 16.79 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The original implementation peaking into the remote nodes to get the ddc bus fwnode, which is not a good practice. Remove the callback from this driver and rely on drm_connector helpers to read EDID. Signed-off-by: Pin-yen Lin --- Changes in v3: - New in v3 drivers/gpu/drm/mediatek/mtk_hdmi.c | 53 +++++++---------------------- 1 file changed, 13 insertions(+), 40 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c index 0a8e0a13f516..44952e539059 100644 --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c @@ -159,7 +159,6 @@ struct mtk_hdmi { const struct mtk_hdmi_conf *conf; struct phy *phy; struct device *cec_dev; - struct i2c_adapter *ddc_adpt; struct clk *clk[MTK_HDMI_CLK_COUNT]; struct drm_display_mode mode; bool dvi_mode; @@ -1265,21 +1264,6 @@ static enum drm_connector_status mtk_hdmi_bridge_detect(struct drm_bridge *bridg return mtk_hdmi_detect(hdmi); } -static struct edid *mtk_hdmi_bridge_get_edid(struct drm_bridge *bridge, - struct drm_connector *connector) -{ - struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); - struct edid *edid; - - if (!hdmi->ddc_adpt) - return NULL; - edid = drm_get_edid(connector, hdmi->ddc_adpt); - if (!edid) - return NULL; - hdmi->dvi_mode = !drm_detect_monitor_audio(edid); - return edid; -} - static int mtk_hdmi_bridge_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { @@ -1390,10 +1374,19 @@ static void mtk_hdmi_bridge_atomic_enable(struct drm_bridge *bridge, { struct drm_atomic_state *state = old_state->base.state; struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); + struct edid *edid; /* Retrieve the connector through the atomic state. */ - hdmi->curr_conn = drm_atomic_get_new_connector_for_encoder(state, - bridge->encoder); + if (!hdmi->curr_conn) + hdmi->curr_conn = drm_atomic_get_new_connector_for_encoder( + state, bridge->encoder); + + if (hdmi->curr_conn->edid_blob_ptr) { + edid = (struct edid *)hdmi->curr_conn->edid_blob_ptr->data; + hdmi->dvi_mode = !drm_detect_monitor_audio(edid); + } else { + dev_err(hdmi->dev, "No edid in drm_connector object\n"); + } mtk_hdmi_output_set_display_mode(hdmi, &hdmi->mode); clk_prepare_enable(hdmi->clk[MTK_HDMI_CLK_HDMI_PLL]); @@ -1417,7 +1410,6 @@ static const struct drm_bridge_funcs mtk_hdmi_bridge_funcs = { .atomic_pre_enable = mtk_hdmi_bridge_atomic_pre_enable, .atomic_enable = mtk_hdmi_bridge_atomic_enable, .detect = mtk_hdmi_bridge_detect, - .get_edid = mtk_hdmi_bridge_get_edid, }; static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, @@ -1425,7 +1417,7 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, { struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; - struct device_node *cec_np, *remote, *i2c_np; + struct device_node *cec_np, *remote; struct platform_device *cec_pdev; struct regmap *regmap; struct resource *mem; @@ -1497,24 +1489,6 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, } } - i2c_np = of_parse_phandle(remote, "ddc-i2c-bus", 0); - if (!i2c_np) { - dev_err(dev, "Failed to find ddc-i2c-bus node in %pOF\n", - remote); - of_node_put(remote); - ret = -EINVAL; - goto put_device; - } - of_node_put(remote); - - hdmi->ddc_adpt = of_find_i2c_adapter_by_node(i2c_np); - of_node_put(i2c_np); - if (!hdmi->ddc_adpt) { - dev_err(dev, "Failed to get ddc i2c adapter by node\n"); - ret = -EINVAL; - goto put_device; - } - return 0; put_device: put_device(hdmi->cec_dev); @@ -1728,8 +1702,7 @@ static int mtk_drm_hdmi_probe(struct platform_device *pdev) hdmi->bridge.funcs = &mtk_hdmi_bridge_funcs; hdmi->bridge.of_node = pdev->dev.of_node; - hdmi->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID - | DRM_BRIDGE_OP_HPD; + hdmi->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_HPD; hdmi->bridge.type = DRM_MODE_CONNECTOR_HDMIA; drm_bridge_add(&hdmi->bridge); From patchwork Sat Feb 18 11:17:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pin-yen Lin X-Patchwork-Id: 13145533 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 3919DC636CC for ; Sat, 18 Feb 2023 11:18:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=MrZswIO3s0BfCLiWcvjWhA4ILZgxpyay+bftO3KZDHg=; b=fFdy34YDCK84ZklD4CMlh8stWQ CKNqzMwBgeACpS6kg/TG3CNSkZ2GECOnqUGmLAyY65hTvLeH8OBdaGmcUdfbhMYTH7MTzVintENjq wG68jZjryr9pOfzy+b9YLgY3pEHK8UT3ecDiUzflyzxFqZcbukn8qq2UnSnsF7EYLEVi10TThTuqB P3+wGHCzmtF6ANSdwiOJ9uOf6Wx2Sdk1OLIxAiOs1Alh+llyP7/miEaKNaxJ56vk4+Skw5L/AvEUr uQTdz21VQK4L3MzZOwkyEP6Sjn65W9zX/l0e1Os8miHAsmf6lieuoXPbZlYlzYCTGBx28fVka1B9/ ZcA9uuRw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pTLEb-00Gr0N-H0; Sat, 18 Feb 2023 11:18:29 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pTLDt-00GqSl-Jq for linux-mediatek@lists.infradead.org; Sat, 18 Feb 2023 11:17:47 +0000 Received: by mail-pf1-x432.google.com with SMTP id d19so242375pfo.9 for ; Sat, 18 Feb 2023 03:17:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MrZswIO3s0BfCLiWcvjWhA4ILZgxpyay+bftO3KZDHg=; b=ba9IojY/CUj+zzZ/UQHSrVd/cwQfpf6fCIPaEsCNLLepX6wnF3HgOqg3YWXfV31SSH Dgpb2oe2njMUAn8gHjEYk3ypaIoyjbybV16Brug2JRVblYSygzOi/VLJB0juzLK3bYkY 4Rbyeuq8O58WHOcm7PAIUhanqDM4bO0ozTQtM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding: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=MrZswIO3s0BfCLiWcvjWhA4ILZgxpyay+bftO3KZDHg=; b=WLpWP6UCARCsgEsTJE7F8vOpUCEEDc7zgVIOLFhqLnupvRp2iuuOB7FFN6i+7xudif mC/THnC/2rdfOThhS4/9nbMZo1GmDauaIwqEMB19qqZAaC+4sde6QxhaHWU3oqscTQxo lX33PJGMH1cDJ96Q3TRTpgApPuL/8C5J4WxWmaMsDX92/NATb2bhop8Z5yJRNODzbK3P YPNsQnPbpLU9n5dnS6CLdzQnp8wXsm8B1YQEv9UZEioyW4m06QQxEFH/Mmv3sjnlw20h tcYEk+usVZQKaH7W0nR+bBdW/DrLJUAxsn+D1OVhqvIbhwe70i9LGuldakz/L6O8oa41 uxuQ== X-Gm-Message-State: AO0yUKUMoN0HKevzD2OpGQFF1wlR5/4DMHBMKZSgmSdJKcLBR5RVMW9A lXO0pFSoSKGS2HojeHrzn8UKIw== X-Google-Smtp-Source: AK7set/2EtDLkb5CN95kCgHnoYzFvMY65qtuHhNEFZiMAKbzehZIhs0gSwBpIhugJj7RooT5OoFOTQ== X-Received: by 2002:aa7:9402:0:b0:5a8:aae8:1160 with SMTP id x2-20020aa79402000000b005a8aae81160mr3998360pfo.20.1676719065217; Sat, 18 Feb 2023 03:17:45 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:88dd:be84:8f65:fec2]) by smtp.gmail.com with ESMTPSA id 23-20020aa79157000000b005a8686b72fcsm4457829pfi.75.2023.02.18.03.17.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 03:17:44 -0800 (PST) From: Pin-yen Lin To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Benson Leung Cc: Chun-Kuang Hu , devicetree@vger.kernel.org, Nicolas Boichat , chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, Guenter Roeck , Matthias Brugger , dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, Philipp Zabel , linux-arm-kernel@lists.infradead.org, Pin-yen Lin Subject: [PATCH v3 4/5] dt-bindings: display: bridge: Add GPIO display mux binding Date: Sat, 18 Feb 2023 19:17:11 +0800 Message-Id: <20230218111712.2380225-5-treapking@chromium.org> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog In-Reply-To: <20230218111712.2380225-1-treapking@chromium.org> References: <20230218111712.2380225-1-treapking@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230218_031745_704733_4DDECAFA X-CRM114-Status: GOOD ( 15.35 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Nicolas Boichat Add bindings for Generic GPIO mux driver. Signed-off-by: Nicolas Boichat Signed-off-by: Pin-yen Lin --- Rob mentioned that this series can probably use the common MUX bindings. Those bindings are designed for MUX consumers that requests a certain MUX configuration, while this driver is reading a GPIO pin controlled by the other parts of the system (in our use case, it's the embedded controller firmware). Changes in v3: - Removed ddc-i2c-bus in the bindings Changes in v2: - Referenced existing dt-binding schemas from graph.yaml - Added ddc-i2c-bus into the bindings .../bindings/display/bridge/gpio-mux.yaml | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/bridge/gpio-mux.yaml diff --git a/Documentation/devicetree/bindings/display/bridge/gpio-mux.yaml b/Documentation/devicetree/bindings/display/bridge/gpio-mux.yaml new file mode 100644 index 000000000000..e6b82ea2f45c --- /dev/null +++ b/Documentation/devicetree/bindings/display/bridge/gpio-mux.yaml @@ -0,0 +1,90 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/bridge/gpio-mux.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Generic display mux (1 input, 2 outputs) + +maintainers: + - Nicolas Boichat + +description: | + This bindings describes a simple display (e.g. HDMI) mux, that has 1 + input, and 2 outputs. The mux status is controlled by hardware, and + its status is read back using a GPIO. + +properties: + compatible: + const: gpio-display-mux + + detect-gpios: + maxItems: 1 + description: GPIO that indicates the active output + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: | + Video port for input. + + port@1: + $ref: /schemas/graph.yaml#/properties/port + description: | + 2 video ports for output. + The reg value in the endpoints matches the GPIO status: when + GPIO is asserted, endpoint with reg value <1> is selected. + + required: + - port@0 + - port@1 + +required: + - compatible + - detect-gpios + - ports + +unevaluatedProperties: false + +examples: + - | + #include + hdmi_mux: hdmi_mux { + compatible = "gpio-display-mux"; + detect-gpios = <&pio 36 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&hdmi_mux_pins>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { /* input */ + reg = <0>; + + hdmi_mux_in: endpoint { + remote-endpoint = <&hdmi0_out>; + }; + }; + + port@1 { /* output */ + reg = <1>; + + #address-cells = <1>; + #size-cells = <0>; + + hdmi_mux_out_anx: endpoint@0 { + reg = <0>; + remote-endpoint = <&dp_bridge_in>; + }; + + hdmi_mux_out_hdmi: endpoint@1 { + reg = <1>; + remote-endpoint = <&hdmi_connector_in>; + }; + }; + }; + }; From patchwork Sat Feb 18 11:17:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pin-yen Lin X-Patchwork-Id: 13145546 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 7E8F0C636CC for ; Sat, 18 Feb 2023 11:19:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=DSUXhwP2T6y6hqUphQwZzIcqD97JaNMTBQcCPNpA7ZY=; b=NIuw7zXa1uXDdjpHYFwOEtC0PN 9eJ5Zua0SlJaSLlMzvF869SjI8COTlQOB5pBzi5LhRGWx0litgwLNxw8dFiMy2DXIFRe4Pq+K3li4 j/KFAkpVABpIvdZMz1jx81l3GQEizcHBs+RFBKOFYFJKPfcpjzyS+ejAPo/5wgrQSoqCt5pmDCQxA fZnIR/SnZ1gOTF1uqbUQvlCJsw9TFHpt72Z33NDhJvC0W49RfWb8tbkhblxZaC3muV5Rs5chqmJv1 Lh7FW4sAv/0E8yHwYwj5KdeoJ71hs0dGAns3MAx/tKv/ywIIUQkSLP/ZoGgbyYTXPR4JRw0GtnLtD OFaqykUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pTLFG-00GrPo-F2; Sat, 18 Feb 2023 11:19:10 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pTLE1-00Gqgf-6M for linux-mediatek@lists.infradead.org; Sat, 18 Feb 2023 11:17:55 +0000 Received: by mail-pf1-x42c.google.com with SMTP id j10so269614pfn.4 for ; Sat, 18 Feb 2023 03:17:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DSUXhwP2T6y6hqUphQwZzIcqD97JaNMTBQcCPNpA7ZY=; b=K1ebpzy7sQJrifSr7e6YnSVeGJ8lDRR1yYZfXCzj4juhrWWGZvln6tIvaFW84W9fZD wwL7IzYZEc5IuBLUQ/9hdp5vkMg4XPS+XJ5eNBEEUN8+491hL4ySB+6rQN2X3UgwwSYV EAat6KZ08pXwtENkeDMWN8OHzDCPuqNLH2C3E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding: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=DSUXhwP2T6y6hqUphQwZzIcqD97JaNMTBQcCPNpA7ZY=; b=iOvbrQEE3E6Q4OqAGylNrcbvXP4iTJq+hZMcGW5bt4s2orrQIGevuoZlIJpFDUbYWJ tUfMoF7ctAuqBMs0a05qpuQ/QWrVAQAaDjFMYXOgw/R6RqooRDUp5ikBPN/90CDEr9HT Pv8uoYNsmMlWc+caCtxWcDVZ6Px4/r0mzzmDQYHpWPHQQ3+EVR1TaNTANmZNIZ+4Txop QO4glmIQXe5kfmzQsV+WcHMAP2KnGAYf/SM4qsx6hijb3JfF2dmjHjR4VrFr6mJBZtWM wGFhJumDTkbMVXam4ColYGTHuk9LxR03ecM8S9VhsHjvXFCmU/BOVvfwn9Y9oja/Nw4Z A3sw== X-Gm-Message-State: AO0yUKVydQrfZC1Sd4xpBVlN2govNgWhQGEObubhs5dTadB6GbB4BLKd 8OgU5i++Mer5Yy1TuAJ9PxXWSw== X-Google-Smtp-Source: AK7set/t1QPWaM3swLlams/S2tCFO1WlAAg0l17iP2nJ78MPCrsY8PR338sdT9FfB0Tov/MzBtYzLg== X-Received: by 2002:a62:528d:0:b0:5a8:808a:d3ce with SMTP id g135-20020a62528d000000b005a8808ad3cemr4276103pfb.8.1676719070101; Sat, 18 Feb 2023 03:17:50 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:88dd:be84:8f65:fec2]) by smtp.gmail.com with ESMTPSA id 23-20020aa79157000000b005a8686b72fcsm4457829pfi.75.2023.02.18.03.17.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 03:17:49 -0800 (PST) From: Pin-yen Lin To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Benson Leung Cc: Chun-Kuang Hu , devicetree@vger.kernel.org, Nicolas Boichat , chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, Guenter Roeck , Matthias Brugger , dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, Philipp Zabel , linux-arm-kernel@lists.infradead.org, Pin-yen Lin Subject: [PATCH v3 5/5] drm: bridge: Generic GPIO mux driver Date: Sat, 18 Feb 2023 19:17:12 +0800 Message-Id: <20230218111712.2380225-6-treapking@chromium.org> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog In-Reply-To: <20230218111712.2380225-1-treapking@chromium.org> References: <20230218111712.2380225-1-treapking@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230218_031753_273028_88183ED0 X-CRM114-Status: GOOD ( 27.56 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Nicolas Boichat This driver supports single input, 2 output display mux (e.g. HDMI mux), that provide its status via a GPIO. Signed-off-by: Nicolas Boichat Signed-off-by: Pin-yen Lin --- Changes in v3: - Added .get_edid callback in generic-gpio-mux driver Changes in v2: - Dropped attach/mode_set/enable/disable callbacks - Fixed style issues - Removed the special case for the HDMI connector - Made the driver only read the GPIO status in IRQ handler - Rebased to drm-misc-next - Update the license: "GPL v2" --> "GPL" drivers/gpu/drm/bridge/Kconfig | 10 + drivers/gpu/drm/bridge/Makefile | 1 + drivers/gpu/drm/bridge/generic-gpio-mux.c | 222 ++++++++++++++++++++++ 3 files changed, 233 insertions(+) create mode 100644 drivers/gpu/drm/bridge/generic-gpio-mux.c diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig index 12e8f30c65f7..42d7c418e8ff 100644 --- a/drivers/gpu/drm/bridge/Kconfig +++ b/drivers/gpu/drm/bridge/Kconfig @@ -73,6 +73,16 @@ config DRM_FSL_LDB help Support for i.MX8MP DPI-to-LVDS on-SoC encoder. +config DRM_GENERIC_GPIO_MUX + tristate "Generic GPIO-controlled mux" + depends on OF + select DRM_KMS_HELPER + help + This bridge driver models a GPIO-controlled display mux with one + input, 2 outputs (e.g. an HDMI mux). The hardware decides which output + is active, reports it as a GPIO, and the driver redirects calls to the + appropriate downstream bridge (if any). + config DRM_ITE_IT6505 tristate "ITE IT6505 DisplayPort bridge" depends on OF diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile index 52f6e8b4a821..4d6d7f63330c 100644 --- a/drivers/gpu/drm/bridge/Makefile +++ b/drivers/gpu/drm/bridge/Makefile @@ -4,6 +4,7 @@ obj-$(CONFIG_DRM_CHRONTEL_CH7033) += chrontel-ch7033.o obj-$(CONFIG_DRM_CROS_EC_ANX7688) += cros-ec-anx7688.o obj-$(CONFIG_DRM_DISPLAY_CONNECTOR) += display-connector.o obj-$(CONFIG_DRM_FSL_LDB) += fsl-ldb.o +obj-$(CONFIG_DRM_GENERIC_GPIO_MUX) += generic-gpio-mux.o obj-$(CONFIG_DRM_ITE_IT6505) += ite-it6505.o obj-$(CONFIG_DRM_LONTIUM_LT8912B) += lontium-lt8912b.o obj-$(CONFIG_DRM_LONTIUM_LT9211) += lontium-lt9211.o diff --git a/drivers/gpu/drm/bridge/generic-gpio-mux.c b/drivers/gpu/drm/bridge/generic-gpio-mux.c new file mode 100644 index 000000000000..928edde701fa --- /dev/null +++ b/drivers/gpu/drm/bridge/generic-gpio-mux.c @@ -0,0 +1,222 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Generic gpio mux bridge driver + * + * Copyright 2016 Google LLC + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +struct gpio_display_mux { + struct device *dev; + + struct gpio_desc *gpiod_detect; + int detect_irq; + int cur_next; + + struct drm_bridge bridge; + + struct drm_bridge *next[2]; +}; + +static inline struct gpio_display_mux *bridge_to_gpio_display_mux( + struct drm_bridge *bridge) +{ + return container_of(bridge, struct gpio_display_mux, bridge); +} + +static irqreturn_t gpio_display_mux_det_threaded_handler(int unused, void *data) +{ + struct gpio_display_mux *mux = data; + int active = gpiod_get_value(mux->gpiod_detect); + + if (active < 0) { + dev_err(mux->dev, "Failed to get detect GPIO\n"); + return IRQ_HANDLED; + } + + dev_dbg(mux->dev, "Interrupt %d!\n", active); + mux->cur_next = active; + + if (mux->bridge.dev) + drm_kms_helper_hotplug_event(mux->bridge.dev); + + return IRQ_HANDLED; +} + +static bool gpio_display_mux_mode_fixup(struct drm_bridge *bridge, + const struct drm_display_mode *mode, + struct drm_display_mode *adjusted_mode) +{ + struct gpio_display_mux *mux = bridge_to_gpio_display_mux(bridge); + struct drm_bridge *next; + + next = mux->next[mux->cur_next]; + + /* Assume that we have a most one bridge in both downstreams */ + if (next && next->funcs->mode_fixup) + return next->funcs->mode_fixup(next, mode, adjusted_mode); + + return true; +} + +static struct edid *gpio_display_mux_get_edid(struct drm_bridge *bridge, + struct drm_connector *connector) +{ + struct gpio_display_mux *mux = bridge_to_gpio_display_mux(bridge); + struct drm_bridge *next; + + next = mux->next[mux->cur_next]; + + return next->funcs->get_edid(next, connector); +} + +static const struct drm_bridge_funcs gpio_display_mux_bridge_funcs = { + .mode_fixup = gpio_display_mux_mode_fixup, + .get_edid = gpio_display_mux_get_edid, +}; + +static int gpio_display_mux_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct gpio_display_mux *mux; + struct device_node *port, *ep, *remote; + int ret; + u32 reg; + + mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL); + if (!mux) + return -ENOMEM; + + platform_set_drvdata(pdev, mux); + mux->dev = &pdev->dev; + + mux->bridge.of_node = dev->of_node; + + mux->gpiod_detect = devm_gpiod_get(dev, "detect", GPIOD_IN); + if (IS_ERR(mux->gpiod_detect)) + return PTR_ERR(mux->gpiod_detect); + + mux->detect_irq = gpiod_to_irq(mux->gpiod_detect); + if (mux->detect_irq < 0) { + dev_err(dev, "Failed to get output irq %d\n", + mux->detect_irq); + return -ENODEV; + } + + port = of_graph_get_port_by_id(dev->of_node, 1); + if (!port) { + dev_err(dev, "Missing output port node\n"); + return -EINVAL; + } + + for_each_child_of_node(port, ep) { + if (!ep->name || (of_node_cmp(ep->name, "endpoint") != 0)) { + of_node_put(ep); + continue; + } + + if (of_property_read_u32(ep, "reg", ®) < 0 || + reg >= ARRAY_SIZE(mux->next)) { + dev_err(dev, + "Missing/invalid reg property for endpoint %s\n", + ep->full_name); + of_node_put(ep); + of_node_put(port); + return -EINVAL; + } + + remote = of_graph_get_remote_port_parent(ep); + if (!remote) { + dev_err(dev, + "Missing connector/bridge node for endpoint %s\n", + ep->full_name); + of_node_put(ep); + of_node_put(port); + return -EINVAL; + } + + mux->next[reg] = of_drm_find_bridge(remote); + if (!mux->next[reg]) { + dev_err(dev, "Waiting for external bridge %s\n", + remote->name); + of_node_put(ep); + of_node_put(remote); + of_node_put(port); + return -EPROBE_DEFER; + } + + of_node_put(remote); + } + of_node_put(port); + + /* + * Because the next bridges are not registered to the drm bridge chain, + * we have to set DRM_BRIDGE_OP_EDID here and trigger the .get_edid + * callbacks of the actual connectors. + */ + if (mux->next[0] && mux->next[0]->ops & DRM_BRIDGE_OP_EDID && + mux->next[1] && mux->next[1]->ops & DRM_BRIDGE_OP_EDID) + mux->bridge.ops |= DRM_BRIDGE_OP_EDID; + + mux->bridge.funcs = &gpio_display_mux_bridge_funcs; + mux->bridge.type = DRM_MODE_CONNECTOR_DisplayPort; + drm_bridge_add(&mux->bridge); + + ret = devm_request_threaded_irq(dev, mux->detect_irq, NULL, + gpio_display_mux_det_threaded_handler, + IRQF_TRIGGER_RISING | + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + "gpio-display-mux-det", mux); + if (ret) { + dev_err(dev, "Failed to request MUX_DET threaded irq\n"); + goto err_bridge_remove; + } + + return 0; + +err_bridge_remove: + drm_bridge_remove(&mux->bridge); + + return ret; +} + +static int gpio_display_mux_remove(struct platform_device *pdev) +{ + struct gpio_display_mux *mux = platform_get_drvdata(pdev); + + disable_irq(mux->detect_irq); + drm_bridge_remove(&mux->bridge); + + return 0; +} + +static const struct of_device_id gpio_display_mux_match[] = { + { .compatible = "gpio-display-mux", }, + {}, +}; + +struct platform_driver gpio_display_mux_driver = { + .probe = gpio_display_mux_probe, + .remove = gpio_display_mux_remove, + .driver = { + .name = "gpio-display-mux", + .of_match_table = gpio_display_mux_match, + }, +}; + +module_platform_driver(gpio_display_mux_driver); + +MODULE_DESCRIPTION("GPIO-controlled display mux"); +MODULE_AUTHOR("Nicolas Boichat "); +MODULE_LICENSE("GPL");