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 */