From patchwork Sun Dec 11 19:37:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Badhri Jagan Sridharan X-Patchwork-Id: 32200 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1897699wrr; Sun, 11 Dec 2022 12:01:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf4D2/vdovAjwy5nqjdJOi7+V3D2kFpgzi6ut4EB/Q1dkjG2bsRxtDNUKZ6+BQNphLsCGPxe X-Received: by 2002:a17:907:2dab:b0:7c0:eba9:cf0f with SMTP id gt43-20020a1709072dab00b007c0eba9cf0fmr15794931ejc.30.1670788913933; Sun, 11 Dec 2022 12:01:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670788913; cv=none; d=google.com; s=arc-20160816; b=T5/uoPQPmgKEEpabNhE8B59WtPTekAlilMxZSjBn2qM0nmNvRpBlU9VQi7R25AaffW lvwT5qs7xLfApH18BKwXm41xBBTRja2gk5tC22vQD9ohX25an1nTONcB7MuNNCbpwL0Y jdh9K4n/cvBzUNbjwUIZaXgm4qUF7WPkRio+UXVHU9JyHOtbZoVHceWt8zUpdsNRn0EV /uKpB+Ds760cn8fRZa97pc+t+K9zkdDFIdO/9sVyRfKqYMz1Ap13gSVNzqitAjby3tRL 1jYxqMhTCWjn/HskYd8LbJ6J9pjVWYtYiUwCZuOtoPXQlGnE+yDABCIzBvZOchJp2GSy 9q0A== 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:from:subject :message-id:mime-version:date:dkim-signature; bh=RgALFf7PGAYeLm7qK7ef+qSJDgWYIBq1PtAWuUeE+QU=; b=CzZln/TO9yL+ZGk6CnPVc4cm9rWJ81M7LubYAwuMx97SDaOe6T1pgNtYUMote4C6By r8xCcXZ/vYJqO3L5K8Cwi4haqr4plEAtSjnCnvKTQylDdoNZsoW5roE2GkbG0lCIyPP3 iP4RknPds3edQ/rM+2ej72Ww9+tknQEldOyHIxuNwjLghpJl2tiLhEO+SZEtaN5jfIr9 pEj/8uXQM2FuwqwkZEj14+KtXn2842CFPnGi7LgsWZeUBT4Pt/iFoqXidYwKhbYagTlE 21m9zMSG++zdh4ik8y37gBqV3yOgIyf78Br4EAl8XTmp8NexIR2GGDsnp5RF7YB/A8x3 0iAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="EIC/vFnX"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l16-20020a170906795000b007ba89a4fd85si5001308ejo.487.2022.12.11.12.01.11; Sun, 11 Dec 2022 12:01:53 -0800 (PST) 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=@google.com header.s=20210112 header.b="EIC/vFnX"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229475AbiLKTiG (ORCPT + 99 others); Sun, 11 Dec 2022 14:38:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229471AbiLKTiE (ORCPT ); Sun, 11 Dec 2022 14:38:04 -0500 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7895D95AB for ; Sun, 11 Dec 2022 11:38:03 -0800 (PST) Received: by mail-pl1-x649.google.com with SMTP id d2-20020a170902cec200b001899479b1d8so8756336plg.22 for ; Sun, 11 Dec 2022 11:38:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:from:to:cc:subject:date:message-id:reply-to; bh=RgALFf7PGAYeLm7qK7ef+qSJDgWYIBq1PtAWuUeE+QU=; b=EIC/vFnXWam/5mn41nXwqZAMPXeKHbmC3C2uEEyQyGcNwdefXhyEjulzMVKpiE4JBO b9K5G/e95BFG+rWcTR7SK/a4vRA4dfMQW7/TmYRzUxor5ncTOIqiNFciWY51BvuBOog+ FhYaueQUw+lGcpVI9ehSFAi6Njr4gGR8sPxWYQmqN9VjjFikWd1kmZlzSMYR7wEi4/N4 dimcNIXvd63jI7HJHQe+J5sGCZC7L6Bzirsf+QgUIYm+2drZA2Kr+MqFTn7oA/CiW5MX G2B3TGkAYEsFXlhheiOdZIuufLD7Bwn+A+rhSnVvr3ruQS2OIt2ATvuYRmUK+k2bGuA+ 5BIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=RgALFf7PGAYeLm7qK7ef+qSJDgWYIBq1PtAWuUeE+QU=; b=tAwlhHOe/tTpYyIVvuNGUctNCLYo8Il/tSlho3yoT2MUt8GfQWCQ/jE9gNvg17+md6 SjWcTAJ746aaufuMqTbqfM6aF6sWJJu31RxHjQPRIHruTfHLMDBe/VFD7zMWpATlK0oG tD/CGJlCdk2gcH0tDTUvgu9iYUdqxIJOEWYLAOfaMIBzgR5hcCeJcuL8suwwJ6QOiZYm ctdkRLUZ0fQxjjGxgzYUgF1dDoxARo652TS6/BL/H9BQLgS/I+Oi6zgwpEV+QdgxKeMo E4wi42B3+/ubTEo5b3mxzH6m/d5bgwt9xOb7EN5khenBc89EqzAI1s3YVQNxdyA4IKYB QKsQ== X-Gm-Message-State: ANoB5pnvJPtietxEvLD59Fe7ba5ivDIeWJiVPmEck4bcIBqyDrBMXkrP 6Bl0fh/+NpNP7Yd0s29/jGuneDIBu0k= X-Received: from badhri.mtv.corp.google.com ([2620:15c:211:201:6e12:1d4:7ea0:48cd]) (user=badhri job=sendgmr) by 2002:a17:90a:2a88:b0:220:1f03:129b with SMTP id j8-20020a17090a2a8800b002201f03129bmr149467pjd.0.1670787482696; Sun, 11 Dec 2022 11:38:02 -0800 (PST) Date: Sun, 11 Dec 2022 11:37:55 -0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.39.0.rc1.256.g54fd8350bd-goog Message-ID: <20221211193755.1392128-1-badhri@google.com> Subject: [PATCH v1] usb: typec: altmodes/displayport: Add hpd sysfs attribute From: Badhri Jagan Sridharan To: Heikki Krogerus , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, RD Babiera , Badhri Jagan Sridharan X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751949156235182195?= X-GMAIL-MSGID: =?utf-8?q?1751949156235182195?= Exporsing HotPlugDetect(HPD) helps userspace to infer HPD state as defined by VESA DisplayPort Alt Mode on USB Type-C Standard. This allows userspace to notify users for self help, for instance, to hint user that the display port cable is probably detached (or) the display port sink (viz., monitors ect.,) is un-powered. Also helps to debug issues reported from field. This change adds an additional attribute "hpd" to the existing "displayport" attributes. VESA DisplayPort Alt Mode on USB Type-C Standard defines how HotPlugDetect(HPD) shall be supported on the USB-C connector when operating in DisplayPort Alt Mode. This is a read only node which reflects the current state of HPD. Valid values: - 1 when HPD’s logical state is high (HPD_High) - 0 when HPD’s logical state is low (HPD_Low) Signed-off-by: Badhri Jagan Sridharan Reviewed-by: Heikki Krogerus --- .../ABI/testing/sysfs-driver-typec-displayport | 15 +++++++++++++++ drivers/usb/typec/altmodes/displayport.c | 10 ++++++++++ 2 files changed, 25 insertions(+) base-commit: 81c25247a2a03a0f97e4805d7aff7541ccff6baa diff --git a/Documentation/ABI/testing/sysfs-driver-typec-displayport b/Documentation/ABI/testing/sysfs-driver-typec-displayport index 231471ad0d4b..256c87c5219a 100644 --- a/Documentation/ABI/testing/sysfs-driver-typec-displayport +++ b/Documentation/ABI/testing/sysfs-driver-typec-displayport @@ -47,3 +47,18 @@ Description: USB SuperSpeed protocol. From user perspective pin assignments C and E are equal, where all channels on the connector are used for carrying DisplayPort protocol (allowing higher resolutions). + +What: /sys/bus/typec/devices/.../displayport/hpd +Date: Dec 2022 +Contact: Badhri Jagan Sridharan +Description: + VESA DisplayPort Alt Mode on USB Type-C Standard defines how + HotPlugDetect(HPD) shall be supported on the USB-C connector when + operating in DisplayPort Alt Mode. This is a read only node which + reflects the current state of HPD. + + Valid values: + - 1: when HPD’s logical state is high (HPD_High) as defined + by VESA DisplayPort Alt Mode on USB Type-C Standard. + - 0 when HPD’s logical state is low (HPD_Low) as defined by + VESA DisplayPort Alt Mode on USB Type-C Standard. diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c index de66a2949e33..06fb4732f8cd 100644 --- a/drivers/usb/typec/altmodes/displayport.c +++ b/drivers/usb/typec/altmodes/displayport.c @@ -146,6 +146,7 @@ static int dp_altmode_status_update(struct dp_altmode *dp) if (dp->hpd != hpd) { drm_connector_oob_hotplug_event(dp->connector_fwnode); dp->hpd = hpd; + sysfs_notify(&dp->alt->dev.kobj, "displayport", "hpd"); } } @@ -508,9 +509,18 @@ static ssize_t pin_assignment_show(struct device *dev, } static DEVICE_ATTR_RW(pin_assignment); +static ssize_t hpd_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct dp_altmode *dp = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", dp->hpd); +} +static DEVICE_ATTR_RO(hpd); + static struct attribute *dp_altmode_attrs[] = { &dev_attr_configuration.attr, &dev_attr_pin_assignment.attr, + &dev_attr_hpd.attr, NULL };