From patchwork Fri Nov 24 15:14:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alvin_=C5=A0ipraga?= X-Patchwork-Id: 169467 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp1293269vqx; Fri, 24 Nov 2023 07:24:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IFLlzOFtSfptFzun3MZRDm1HJQuYM8F8/NfhMWH9CS+zpV76yhlNHvTNjJVZLm6acDpV71R X-Received: by 2002:a05:6a20:160b:b0:18c:3ec:5ad5 with SMTP id l11-20020a056a20160b00b0018c03ec5ad5mr2015301pzj.57.1700839497429; Fri, 24 Nov 2023 07:24:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700839497; cv=none; d=google.com; s=arc-20160816; b=USI+R5lyc7a3mSngXbec7lFqrPVva57XfXniVgOHVzYLOHhQ2eN5bddUvP9kSiQO27 NkKS7wwyGsIGRNRNRCeOMFzH0jY9xn1n6TP383oDMrDPtOp+02wk6p0f1qPy+64AInyE VwKbbGwFPjJY7+RYcC9gD6ItH3Eqlp58mMJcQk30j/UMtrGcZLBYH7/XeTiSTi4qbCeU s9GJskaH/y2GCPVuR7ro1gR6fNcKT7a00CcuLfAEQkbiNckPXU4usgEN5nP5om+doBlW FFHzXZ/4O147duH3lvgPMeYjhHEDBiwVWBd1iRcd4UHdwew+lT8N6qhOA7RXLwko75Wa lHQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=jIEnx9CoIn2hRvEpRDmHvZNWG76Z/UfEmMl3bO7DffQ=; fh=ydulqYqzRgtodS6f6e63tjxzqAXo+nDD8TuQAI7qv6o=; b=Aoe22+sXi0M4qx5R6NpKrTlTGKhC/z13NHBxaRgdKTDP5RDE7k6zBQ9IJ00pnENNa8 dHw2ZIKVPq79Pii5USX6rlswcXcZbfKNgz9g/YgBz7OERTirLBiL8jPY7ivu+eLJnDXo xUQZmDOj7DVHjX4brbPwylBxTqdkYC/u6P9B3sceZyktuFxgJRFhYkPuHW0BSg4EYdsV CkhOoEhZO1fNT/+7vJPy3Yh6ZtJCyqFl6zX8GM1IQcye6NRX4A81vMfgw3fb8EdiVBZE YB10TW9HRHP/nVShwstcEvgGOVwHETK20cKBqMJuYTQy5XL4GOc5LgnXYtJLvE2Iw8R6 c4Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pqrs.dk header.s=key1 header.b=ns4rkLOP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id l27-20020a63ba5b000000b005c219456791si3875622pgu.322.2023.11.24.07.24.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 07:24:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@pqrs.dk header.s=key1 header.b=ns4rkLOP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 54B448376BFA; Fri, 24 Nov 2023 07:24:54 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345839AbjKXPYg (ORCPT + 99 others); Fri, 24 Nov 2023 10:24:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345832AbjKXPY1 (ORCPT ); Fri, 24 Nov 2023 10:24:27 -0500 Received: from out-179.mta1.migadu.com (out-179.mta1.migadu.com [IPv6:2001:41d0:203:375::b3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E48D919AF for ; Fri, 24 Nov 2023 07:24:32 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pqrs.dk; s=key1; t=1700838870; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jIEnx9CoIn2hRvEpRDmHvZNWG76Z/UfEmMl3bO7DffQ=; b=ns4rkLOPocy4Mn0v+u8Rcp2xu2ZFBxhXfYtK1b7SRNd23n9CoTcwPAuNHPZiMezFimpvB4 t4uX+3azkRlUJXTZvB5tHGrmmO+XnvxMerTvxzHeby3mLIKgotqYjjtiDdFgCyNiDz7cu5 CP5QQ7jkYzwfhLXZ2MJf6NeVXt7C+HG5bE/lpCKV/SNg6bzBwINZDT/rm8imsGA4ev+7bb gHvlWwyZxDgke7PYsX3nUcLxEpCgoa3zXs5w/ANydLm60Na9iO+gsRg0hLXnDKluxWoCDl wtfVDvDHzCMxdv0JiTO60URFNkbMZwvcUG1aIe4jWgrc66u+OuufZMoeMh2zjQ== From: =?utf-8?q?Alvin_=C5=A0ipraga?= Date: Fri, 24 Nov 2023 16:14:21 +0100 Subject: [PATCH v2 1/2] drm/bridge: adv7511: rearrange hotplug work code MIME-Version: 1.0 Message-Id: <20231124-adv7511-cec-edid-v2-1-f0e5eeafdfc2@bang-olufsen.dk> References: <20231124-adv7511-cec-edid-v2-0-f0e5eeafdfc2@bang-olufsen.dk> In-Reply-To: <20231124-adv7511-cec-edid-v2-0-f0e5eeafdfc2@bang-olufsen.dk> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Hans Verkuil Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, =?utf-8?q?Alvin_=C5=A0ipraga?= X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 24 Nov 2023 07:24:54 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783459476971860990 X-GMAIL-MSGID: 1783459476971860990 From: Alvin Šipraga In preparation for calling EDID helpers from the hotplug work, move the hotplug work below the EDID helper section. No functional change. Signed-off-by: Alvin Šipraga --- drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 120 ++++++++++++++------------- 1 file changed, 62 insertions(+), 58 deletions(-) diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c index 8be235144f6d..5ffc5904bd59 100644 --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c @@ -406,64 +406,6 @@ static void adv7511_power_off(struct adv7511 *adv7511) * Interrupt and hotplug detection */ -static bool adv7511_hpd(struct adv7511 *adv7511) -{ - unsigned int irq0; - int ret; - - ret = regmap_read(adv7511->regmap, ADV7511_REG_INT(0), &irq0); - if (ret < 0) - return false; - - if (irq0 & ADV7511_INT0_HPD) { - regmap_write(adv7511->regmap, ADV7511_REG_INT(0), - ADV7511_INT0_HPD); - return true; - } - - return false; -} - -static void adv7511_hpd_work(struct work_struct *work) -{ - struct adv7511 *adv7511 = container_of(work, struct adv7511, hpd_work); - enum drm_connector_status status; - unsigned int val; - int ret; - - ret = regmap_read(adv7511->regmap, ADV7511_REG_STATUS, &val); - if (ret < 0) - status = connector_status_disconnected; - else if (val & ADV7511_STATUS_HPD) - status = connector_status_connected; - else - status = connector_status_disconnected; - - /* - * The bridge resets its registers on unplug. So when we get a plug - * event and we're already supposed to be powered, cycle the bridge to - * restore its state. - */ - if (status == connector_status_connected && - adv7511->connector.status == connector_status_disconnected && - adv7511->powered) { - regcache_mark_dirty(adv7511->regmap); - adv7511_power_on(adv7511); - } - - if (adv7511->connector.status != status) { - adv7511->connector.status = status; - - if (adv7511->connector.dev) { - if (status == connector_status_disconnected) - cec_phys_addr_invalidate(adv7511->cec_adap); - drm_kms_helper_hotplug_event(adv7511->connector.dev); - } else { - drm_bridge_hpd_notify(&adv7511->bridge, status); - } - } -} - static int adv7511_irq_process(struct adv7511 *adv7511, bool process_hpd) { unsigned int irq0, irq1; @@ -600,6 +542,68 @@ static int adv7511_get_edid_block(void *data, u8 *buf, unsigned int block, return 0; } +/* ----------------------------------------------------------------------------- + * Hotplug handling + */ + +static bool adv7511_hpd(struct adv7511 *adv7511) +{ + unsigned int irq0; + int ret; + + ret = regmap_read(adv7511->regmap, ADV7511_REG_INT(0), &irq0); + if (ret < 0) + return false; + + if (irq0 & ADV7511_INT0_HPD) { + regmap_write(adv7511->regmap, ADV7511_REG_INT(0), + ADV7511_INT0_HPD); + return true; + } + + return false; +} + +static void adv7511_hpd_work(struct work_struct *work) +{ + struct adv7511 *adv7511 = container_of(work, struct adv7511, hpd_work); + enum drm_connector_status status; + unsigned int val; + int ret; + + ret = regmap_read(adv7511->regmap, ADV7511_REG_STATUS, &val); + if (ret < 0) + status = connector_status_disconnected; + else if (val & ADV7511_STATUS_HPD) + status = connector_status_connected; + else + status = connector_status_disconnected; + + /* + * The bridge resets its registers on unplug. So when we get a plug + * event and we're already supposed to be powered, cycle the bridge to + * restore its state. + */ + if (status == connector_status_connected && + adv7511->connector.status == connector_status_disconnected && + adv7511->powered) { + regcache_mark_dirty(adv7511->regmap); + adv7511_power_on(adv7511); + } + + if (adv7511->connector.status != status) { + adv7511->connector.status = status; + + if (adv7511->connector.dev) { + if (status == connector_status_disconnected) + cec_phys_addr_invalidate(adv7511->cec_adap); + drm_kms_helper_hotplug_event(adv7511->connector.dev); + } else { + drm_bridge_hpd_notify(&adv7511->bridge, status); + } + } +} + /* ----------------------------------------------------------------------------- * ADV75xx helpers */ From patchwork Fri Nov 24 15:14:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alvin_=C5=A0ipraga?= X-Patchwork-Id: 169466 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp1293118vqx; Fri, 24 Nov 2023 07:24:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IE2RocGMe+yD4/ZMNkmQn7uqNwTirdBqMI65iTRWYbOnPC6wdUB/W00IGIeilxY/upZypKb X-Received: by 2002:a05:6a20:548b:b0:18b:cea3:c34d with SMTP id i11-20020a056a20548b00b0018bcea3c34dmr3211604pzk.32.1700839486853; Fri, 24 Nov 2023 07:24:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700839486; cv=none; d=google.com; s=arc-20160816; b=HVRRDG6APCAgrTEzK1QtZFbn36nUqLmLrdJBnSK6rRvLIkuIy06h1A2Zbsqk9uORj8 fT4iKth+3v3kFfPOWQ+o8nCoK7MzUkT0mwmChhC7jcjPe3UgYZilJBG15ksAdKikgGG4 CLsR+++3fsWb5ot+5RRxYv/up4g4NUkbNQ08IvPqoNehenTCBOKSTfbnUeDt+PG1mcos w0wy6nQA4AoaCisglzFaa8U217+CyNOnRzfxTE27M8oGvhe0IE3T/ipgqmaqxqDoHoB6 /V7aZ6/NcTWXqKyAjmwIqub32P4sFFlQxoYMBzkbNfz4eBiSxX1Tt3K/zldQ6dTP14mj Rf/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=Mc7Wf0hW6FowFM4Mm7qR65l0E98I4NpTxHZ7srPzTOc=; fh=ydulqYqzRgtodS6f6e63tjxzqAXo+nDD8TuQAI7qv6o=; b=oMOenkPxyPJi2fXS2OAL2DrnpI7Fb1uORCcL0THz58+01y0DOT8F27Ltkrvc5wKsCv +9qF7Gqf6ELZEL1AkkeoNAkFavrrS+TJGO67Ikms7waxP5Kim2GudxGSO8u0l0z5Iwud FThWz/2PNMk8DNyisVTVN1UHI0ri+ykJX73jsqa/AUBeMmLu1xkZr8urcA83CJJQm/RE +KnMfZVb7Krj2Cpkph/D6ud+PPYaCzT+5z40gEZ0IVbpP8t7VfeRHk01lMrZYe5yd0aR 1LzK7DruKMDm9cZUh5DY6FoqMRQibKe04lkg9BCjZO0oe/rSlpVew4PQfgU+QKSkAs3U OFdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pqrs.dk header.s=key1 header.b=wkVvMqHU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id d4-20020a056a0010c400b0069026254582si3750694pfu.98.2023.11.24.07.24.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 07:24:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@pqrs.dk header.s=key1 header.b=wkVvMqHU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7552681D770D; Fri, 24 Nov 2023 07:24:45 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345823AbjKXPYd (ORCPT + 99 others); Fri, 24 Nov 2023 10:24:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345799AbjKXPY1 (ORCPT ); Fri, 24 Nov 2023 10:24:27 -0500 Received: from out-180.mta1.migadu.com (out-180.mta1.migadu.com [IPv6:2001:41d0:203:375::b4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E464419AD for ; Fri, 24 Nov 2023 07:24:32 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pqrs.dk; s=key1; t=1700838871; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mc7Wf0hW6FowFM4Mm7qR65l0E98I4NpTxHZ7srPzTOc=; b=wkVvMqHUqI8TxuJSHJUgA8mxyczMeeUC99Yz/tNb1r7Myj4sN7l2EK/Q0rfSuOFEf4t5sF vKjL5Rd/Hyds14IHXsQOjg2rNPtIjIUyZPhBJ9JwaDL255ckALplmxOGruk5AlgpkE7Sk1 UfDI3+bJ3d6UyWkGeP1v/MBptd2Y97+UhXIFLeQJ9FPbD37RvZ2e8YCC1pmhtvbvLpFhPj C3vdz1MF3pD9KCx+b+HoUNBtIyPuZNIoaH441+D55iMUYY+85ztWHwgsryXIaij6x0qW32 4CYpSy9dQQLXSQLFjML3kZqphN/AdJjOPToem+Vr38z5+GXi9cKAcWRizHTmDA== From: =?utf-8?q?Alvin_=C5=A0ipraga?= Date: Fri, 24 Nov 2023 16:14:22 +0100 Subject: [PATCH v2 2/2] drm/bridge: adv7511: get edid in hpd_work to update CEC phys address MIME-Version: 1.0 Message-Id: <20231124-adv7511-cec-edid-v2-2-f0e5eeafdfc2@bang-olufsen.dk> References: <20231124-adv7511-cec-edid-v2-0-f0e5eeafdfc2@bang-olufsen.dk> In-Reply-To: <20231124-adv7511-cec-edid-v2-0-f0e5eeafdfc2@bang-olufsen.dk> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Hans Verkuil Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, =?utf-8?q?Alvin_=C5=A0ipraga?= X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 24 Nov 2023 07:24:45 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783459465720702929 X-GMAIL-MSGID: 1783459465720702929 From: Alvin Šipraga The adv7511 driver is solely responsible for setting the physical address of its CEC adapter. To do this, it must read the EDID. However, EDID is only read when either the drm_bridge_funcs :: get_edid or drm_connector_helper_funcs :: get_modes ops are called. Without loss of generality, it cannot be assumed that these ops are called when a sink gets attached. Therefore there exist scenarios in which the CEC physical address will be invalid (f.f.f.f), rendering the CEC adapter inoperable. Address this problem by always fetching the EDID in the HPD work when we detect a connection. The CEC physical address is set in the process. This is done by moving the EDID DRM helper into an internal helper function so that it can be cleanly called from an earlier section of the code. The EDID getter has not changed in practice. Signed-off-by: Alvin Šipraga Reviewed-by: Robert Foss --- drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 74 ++++++++++++++++++---------- 1 file changed, 48 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c index 5ffc5904bd59..1f1d3a440895 100644 --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c @@ -542,6 +542,36 @@ static int adv7511_get_edid_block(void *data, u8 *buf, unsigned int block, return 0; } +static struct edid *__adv7511_get_edid(struct adv7511 *adv7511, + struct drm_connector *connector) +{ + struct edid *edid; + + /* Reading the EDID only works if the device is powered */ + if (!adv7511->powered) { + unsigned int edid_i2c_addr = + (adv7511->i2c_edid->addr << 1); + + __adv7511_power_on(adv7511); + + /* Reset the EDID_I2C_ADDR register as it might be cleared */ + regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR, + edid_i2c_addr); + } + + edid = drm_do_get_edid(connector, adv7511_get_edid_block, adv7511); + + if (!adv7511->powered) + __adv7511_power_off(adv7511); + + adv7511_set_config_csc(adv7511, connector, adv7511->rgb, + drm_detect_hdmi_monitor(edid)); + + cec_s_phys_addr_from_edid(adv7511->cec_adap, edid); + + return edid; +} + /* ----------------------------------------------------------------------------- * Hotplug handling */ @@ -595,8 +625,24 @@ static void adv7511_hpd_work(struct work_struct *work) adv7511->connector.status = status; if (adv7511->connector.dev) { - if (status == connector_status_disconnected) + if (status == connector_status_disconnected) { cec_phys_addr_invalidate(adv7511->cec_adap); + } else { + struct edid *edid; + + /* + * Get the updated EDID so that the CEC + * subsystem gets informed of any change in CEC + * address. The helper returns a newly allocated + * edid structure, so free it to prevent + * leakage. + */ + edid = __adv7511_get_edid(adv7511, + &adv7511->connector); + if (edid) + kfree(edid); + } + drm_kms_helper_hotplug_event(adv7511->connector.dev); } else { drm_bridge_hpd_notify(&adv7511->bridge, status); @@ -611,31 +657,7 @@ static void adv7511_hpd_work(struct work_struct *work) static struct edid *adv7511_get_edid(struct adv7511 *adv7511, struct drm_connector *connector) { - struct edid *edid; - - /* Reading the EDID only works if the device is powered */ - if (!adv7511->powered) { - unsigned int edid_i2c_addr = - (adv7511->i2c_edid->addr << 1); - - __adv7511_power_on(adv7511); - - /* Reset the EDID_I2C_ADDR register as it might be cleared */ - regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR, - edid_i2c_addr); - } - - edid = drm_do_get_edid(connector, adv7511_get_edid_block, adv7511); - - if (!adv7511->powered) - __adv7511_power_off(adv7511); - - adv7511_set_config_csc(adv7511, connector, adv7511->rgb, - drm_detect_hdmi_monitor(edid)); - - cec_s_phys_addr_from_edid(adv7511->cec_adap, edid); - - return edid; + return __adv7511_get_edid(adv7511, connector); } static int adv7511_get_modes(struct adv7511 *adv7511,