Add hpd and link training status to AltModeData
Adds DisplayPort hpd and link training attributes within
DisplayPortAltModeData in USB HAL layer to more accurately
populate frameworks API fields. Within DisplayPortAltModeData are
new fields hpd and linkTrainingStatus.
Test: atest VtsAidlUsbTargetTest
Bug: 253534975
Change-Id: I3eb4b1527f457ba63bf127fbb14bd583ef6caf2f
diff --git a/usb/aidl/aidl_api/android.hardware.usb/current/android/hardware/usb/AltModeData.aidl b/usb/aidl/aidl_api/android.hardware.usb/current/android/hardware/usb/AltModeData.aidl
index 8e9dd00..d25ee84 100644
--- a/usb/aidl/aidl_api/android.hardware.usb/current/android/hardware/usb/AltModeData.aidl
+++ b/usb/aidl/aidl_api/android.hardware.usb/current/android/hardware/usb/AltModeData.aidl
@@ -40,5 +40,7 @@
android.hardware.usb.DisplayPortAltModeStatus partnerSinkStatus = android.hardware.usb.DisplayPortAltModeStatus.UNKNOWN;
android.hardware.usb.DisplayPortAltModeStatus cableStatus = android.hardware.usb.DisplayPortAltModeStatus.UNKNOWN;
android.hardware.usb.DisplayPortAltModePinAssignment pinAssignment = android.hardware.usb.DisplayPortAltModePinAssignment.NONE;
+ boolean hpd = false;
+ android.hardware.usb.LinkTrainingStatus linkTrainingStatus = android.hardware.usb.LinkTrainingStatus.UNKNOWN;
}
}
diff --git a/usb/aidl/aidl_api/android.hardware.usb/current/android/hardware/usb/LinkTrainingStatus.aidl b/usb/aidl/aidl_api/android.hardware.usb/current/android/hardware/usb/LinkTrainingStatus.aidl
new file mode 100644
index 0000000..1f0b2dc
--- /dev/null
+++ b/usb/aidl/aidl_api/android.hardware.usb/current/android/hardware/usb/LinkTrainingStatus.aidl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.usb;
+@Backing(type="int") @VintfStability
+enum LinkTrainingStatus {
+ UNKNOWN = 0,
+ SUCCESS = 1,
+ FAILURE = 2,
+}
diff --git a/usb/aidl/android/hardware/usb/AltModeData.aidl b/usb/aidl/android/hardware/usb/AltModeData.aidl
index e103ff9..0b1e06a 100644
--- a/usb/aidl/android/hardware/usb/AltModeData.aidl
+++ b/usb/aidl/android/hardware/usb/AltModeData.aidl
@@ -18,6 +18,7 @@
import android.hardware.usb.DisplayPortAltModePinAssignment;
import android.hardware.usb.DisplayPortAltModeStatus;
+import android.hardware.usb.LinkTrainingStatus;
@VintfStability
union AltModeData {
@@ -42,6 +43,18 @@
* negotiated between the device, port partner, and cable.
*/
DisplayPortAltModePinAssignment pinAssignment = DisplayPortAltModePinAssignment.NONE;
+ /**
+ * Indicates DisplayPort Hot Plug Detection (HPD) status for a partner
+ * sink device. If true, then a DisplayPort Alt Mode partner sink is
+ * connected and powered on, and if false, the partner sink is not
+ * powered or no partner sink is connected.
+ */
+ boolean hpd = false;
+ /**
+ * Indicates the current status of DisplayPort link training over USB-C
+ * for the attached DisplayPort Alt Mode partner sink.
+ */
+ LinkTrainingStatus linkTrainingStatus = LinkTrainingStatus.UNKNOWN;
}
DisplayPortAltModeData displayPortAltModeData;
}
diff --git a/usb/aidl/android/hardware/usb/LinkTrainingStatus.aidl b/usb/aidl/android/hardware/usb/LinkTrainingStatus.aidl
new file mode 100644
index 0000000..9f3b3c3
--- /dev/null
+++ b/usb/aidl/android/hardware/usb/LinkTrainingStatus.aidl
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.usb;
+
+@VintfStability
+@Backing(type="int")
+/**
+ * Indicates the current status of DisplayPort link training over USB-C for the
+ * attached DisplayPort Alt Mode partner sink as described in DisplayPort
+ * v1.4/2.1.
+ */
+enum LinkTrainingStatus {
+ /*
+ * Indicates the link training result is not available because link training
+ * has not completed or initiated yet.
+ */
+ UNKNOWN = 0,
+ /*
+ * Indicates that link training has completed and optimal settings for data
+ * transmission between the sink and source device have successfully been
+ * negotiated.
+ */
+ SUCCESS = 1,
+ /*
+ * Indicates that link training has failed and the link initialization has
+ * terminated.
+ */
+ FAILURE = 2,
+}
diff --git a/usb/aidl/vts/VtsAidlUsbTargetTest.cpp b/usb/aidl/vts/VtsAidlUsbTargetTest.cpp
index 480c826..e9aa65b 100644
--- a/usb/aidl/vts/VtsAidlUsbTargetTest.cpp
+++ b/usb/aidl/vts/VtsAidlUsbTargetTest.cpp
@@ -49,6 +49,7 @@
using ::aidl::android::hardware::usb::DisplayPortAltModeStatus;
using ::aidl::android::hardware::usb::IUsb;
using ::aidl::android::hardware::usb::IUsbCallback;
+using ::aidl::android::hardware::usb::LinkTrainingStatus;
using ::aidl::android::hardware::usb::PlugOrientation;
using ::aidl::android::hardware::usb::PortDataRole;
using ::aidl::android::hardware::usb::PortMode;
@@ -724,6 +725,10 @@
(int)DisplayPortAltModePinAssignment::NONE);
EXPECT_TRUE((int)displayPortAltModeData.pinAssignment <=
(int)DisplayPortAltModePinAssignment::F);
+
+ EXPECT_TRUE((int)displayPortAltModeData.linkTrainingStatus >=
+ (int)LinkTrainingStatus::UNKNOWN);
+ EXPECT_TRUE((int)displayPortAltModeData.pinAssignment <= (int)LinkTrainingStatus::FAILURE);
}
}