Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1350052rdb; Mon, 19 Feb 2024 12:20:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWq2AHzvmbWCpSWled8x0StN2blRj/8eH9pKSvFJYXpCv1Kkn28tfU26WThIHqRzV6YzWB9vg+xkE1/anfWLgvWyFfB7RTnzMBHBk5bTg== X-Google-Smtp-Source: AGHT+IET+Ll3uJbKseDeKcvWkMHzmw4o5qI6jaxJEitSgo+6NJqvpO7nfgaAvE/Ya+r8dB/8mPHT X-Received: by 2002:a17:902:9006:b0:1d7:524:a4f8 with SMTP id a6-20020a170902900600b001d70524a4f8mr13328421plp.41.1708374045939; Mon, 19 Feb 2024 12:20:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708374045; cv=pass; d=google.com; s=arc-20160816; b=yWmhSuHU/x6V1bt2ZHt/BwtKoCn/SUaXAaxyum6tLIM2WyYCsnV0vl0YN6m0LZJ8dM /VIe778l3pa/tCejdfnd7Te16zMWzY8lcf8QxAEj33fRBTh8AnG/Af4tcs8cialTpn5P j2UKu5j4wC1NZhnGuCKJi4QyTk8mFfjntQwCtY+Nj6GMu9DYP2dzdw/Ob0CjDiXzB/P1 EUosjCHAlziBwig+nBwcWCtdTn+B0sPGNbp83aMBmWKxKuJRBzgbOeBCtPo9kLlvfv+J 4BF3S0brEUcH/AZGmEUjYh/wjaZzqSLHiGIFezQzGkckU2gpjmFqZiquZ69JLli8XCyz P8cw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=Gr6bVcKnfspMMRxxIcvGJZKYsuRR76HeAUpuoZm3aKc=; fh=ydulqYqzRgtodS6f6e63tjxzqAXo+nDD8TuQAI7qv6o=; b=oE3T6C5AsH9Ej2V2/al4gj7ip4EaruVKZ/SjpIkOyk2rKJ4KSHGVTEqAOsxmwAJtVd cFNMgFghqSVLvTgOev8mr/FaIdoLmqUYgijdDnL+uEmXcS8k3f2HgCKBJOy1lNP3bB5u TWQACON1G9pMEVs434TAa/uV/kC9caf1Tj7GU8KgYBs64/uoNEagQiGPh9BrX78ezmJT FN4ILi6VJvweYLShtrwKXFf15XMdfZwZkrIku2bp3AcuQBcWjEltDZWWFEyRx2dYvFAm GMtqzo9Jo02BoQoEVSgxMdynS3l2rNkfxwlH+Nh8NeXnfZkJOQTXZh8HlrEZsDZv4ABZ z9xQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@pqrs.dk header.s=key1 header.b=xoz8tY5e; arc=pass (i=1 spf=pass spfdomain=pqrs.dk dkim=pass dkdomain=pqrs.dk); spf=pass (google.com: domain of linux-kernel+bounces-71944-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71944-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id n12-20020a170902d2cc00b001d94c1d01besi5066658plc.276.2024.02.19.12.20.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 12:20:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71944-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@pqrs.dk header.s=key1 header.b=xoz8tY5e; arc=pass (i=1 spf=pass spfdomain=pqrs.dk dkim=pass dkdomain=pqrs.dk); spf=pass (google.com: domain of linux-kernel+bounces-71944-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71944-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2B48F288184 for ; Mon, 19 Feb 2024 20:13:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2DBA8535CE; Mon, 19 Feb 2024 20:13:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pqrs.dk header.i=@pqrs.dk header.b="xoz8tY5e" Received: from out-187.mta0.migadu.com (out-187.mta0.migadu.com [91.218.175.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC646481A3 for ; Mon, 19 Feb 2024 20:13:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708373594; cv=none; b=Mz3UdHnVi3ZfGb3zV4Q/AJpyE3Bnde1UHjTE5quJJ761v4lPtztOfw8I+TLV5jwMWjY3q8oxv3J+NQUvwEoMZr4oTqgllqW3SoNg/AlyI2AH0/e9INR0gmf1y3u3NeyPZjt9X5RAnkUfzlgtgMS4blxsrgzlTWnRDTzp7RqzaNE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708373594; c=relaxed/simple; bh=G2kwsajV3/BBtY00VbesBoBB8bLmiTJnlVx2H/N2aLg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Za1cLZL2SGtFjUWjdorL5YYUuFfXC1QhZ1e42g2Zf1rhLnMoki2oNo+QzUdIe6v37i6S784iRg+0ULFdnHj71uYn2DMAnqeG1CQBsxVuyugo2N1Lci4DuImq/CEHir9prgNZlielmTJiL4t5niSUd2C+4FgF2YeLqQJl5K3Q2N8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pqrs.dk; spf=pass smtp.mailfrom=pqrs.dk; dkim=pass (2048-bit key) header.d=pqrs.dk header.i=@pqrs.dk header.b=xoz8tY5e; arc=none smtp.client-ip=91.218.175.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pqrs.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pqrs.dk 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=1708373587; 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=Gr6bVcKnfspMMRxxIcvGJZKYsuRR76HeAUpuoZm3aKc=; b=xoz8tY5ewsOlJ7oHXaqTxeiYFaMy6W01horFeinqzhUWwulruOLAhCSDhnTqMUKCkErvJZ fLt3oYWHpdWgyvKgkHtU18mFqNeIJRsvqXouAAKknv68orETLgmmpAd3vdAg0771VxCYQ+ ZMj8MBgOzoo503u1TxXEWdfBpXJ3x5A7saqC+lAf/Aj0M8Z8OjmudBGtWkBydbfJIKhzXy +Xj4b5EVrguAtukQRLJRwMtwbAEMlzEcdEU7z4TXBFpj2QfZq1SQvNTsmpPChY4OoVt7tt TZW3xvoU1PntWA2HCvQG/x+8Ylj1oLninxrk7n+Sm5Hq8gtJgZEZWrwqJJYEPw== From: =?utf-8?q?Alvin_=C5=A0ipraga?= Date: Mon, 19 Feb 2024 21:12:58 +0100 Subject: [PATCH v3 1/2] drm/bridge: adv7511: rearrange hotplug work code Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20240219-adv7511-cec-edid-v3-1-445aed2f1cd7@bang-olufsen.dk> References: <20240219-adv7511-cec-edid-v3-0-445aed2f1cd7@bang-olufsen.dk> In-Reply-To: <20240219-adv7511-cec-edid-v3-0-445aed2f1cd7@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 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. Reviewed-by: Robert Foss 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 */ -- 2.43.1