From 04ee1a4f68ba31a8e254926a2643d90d5bfcdae4 Mon Sep 17 00:00:00 2001 From: Venkatarama Avadhani Date: Wed, 9 Nov 2022 16:21:55 +0530 Subject: [PATCH] HDMI: Add Hotplug Detection Signal support The HPD (Hotplug Detection) signal indicates the type of signal that the HAL should use. Bug: 258394639 Test: atest VtsHalTvHdmiAidlTargetTest Change-Id: Ic391064d10636aca3c8e5c256c41d40144fbfe9c --- .../android/hardware/tv/hdmi/HpdSignal.aidl | 39 +++++++++++++++ .../android/hardware/tv/hdmi/IHdmi.aidl | 2 + .../android/hardware/tv/hdmi/Result.aidl | 42 ++++++++++++++++ .../android/hardware/tv/hdmi/HpdSignal.aidl | 27 +++++++++++ .../aidl/android/hardware/tv/hdmi/IHdmi.aidl | 14 ++++++ .../aidl/android/hardware/tv/hdmi/Result.aidl | 48 +++++++++++++++++++ tv/hdmi/aidl/default/HdmiMock.cpp | 15 ++++++ tv/hdmi/aidl/default/HdmiMock.h | 8 ++++ .../functional/VtsHalTvHdmiAidlTargetTest.cpp | 16 +++++++ 9 files changed, 211 insertions(+) create mode 100644 tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/HpdSignal.aidl create mode 100644 tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/Result.aidl create mode 100644 tv/hdmi/aidl/android/hardware/tv/hdmi/HpdSignal.aidl create mode 100644 tv/hdmi/aidl/android/hardware/tv/hdmi/Result.aidl diff --git a/tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/HpdSignal.aidl b/tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/HpdSignal.aidl new file mode 100644 index 0000000000..eef4025008 --- /dev/null +++ b/tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/HpdSignal.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 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 -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.tv.hdmi; +@Backing(type="byte") @VintfStability +enum HpdSignal { + HDMI_HPD_PHYSICAL = 0, + HDMI_HPD_STATUS_BIT = 1, +} diff --git a/tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/IHdmi.aidl b/tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/IHdmi.aidl index 3fc7f4144a..809d392be8 100644 --- a/tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/IHdmi.aidl +++ b/tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/IHdmi.aidl @@ -37,4 +37,6 @@ interface IHdmi { android.hardware.tv.hdmi.HdmiPortInfo[] getPortInfo(); boolean isConnected(in int portId); void setCallback(in android.hardware.tv.hdmi.IHdmiCallback callback); + void setHpdSignal(android.hardware.tv.hdmi.HpdSignal signal); + android.hardware.tv.hdmi.HpdSignal getHpdSignal(); } diff --git a/tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/Result.aidl b/tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/Result.aidl new file mode 100644 index 0000000000..b6b0eb318d --- /dev/null +++ b/tv/hdmi/aidl/aidl_api/android.hardware.tv.hdmi/current/android/hardware/tv/hdmi/Result.aidl @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2022 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 -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.tv.hdmi; +@VintfStability +enum Result { + SUCCESS = 0, + FAILURE_UNKNOWN = 1, + FAILURE_INVALID_ARGS = 2, + FAILURE_INVALID_STATE = 3, + FAILURE_NOT_SUPPORTED = 4, +} diff --git a/tv/hdmi/aidl/android/hardware/tv/hdmi/HpdSignal.aidl b/tv/hdmi/aidl/android/hardware/tv/hdmi/HpdSignal.aidl new file mode 100644 index 0000000000..05963f2af3 --- /dev/null +++ b/tv/hdmi/aidl/android/hardware/tv/hdmi/HpdSignal.aidl @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2022 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.tv.hdmi; + +/** + * HPD (Hotplug Detection) Signal Types + */ +@VintfStability +@Backing(type="byte") +enum HpdSignal { + HDMI_HPD_PHYSICAL = 0, + HDMI_HPD_STATUS_BIT = 1, +} diff --git a/tv/hdmi/aidl/android/hardware/tv/hdmi/IHdmi.aidl b/tv/hdmi/aidl/android/hardware/tv/hdmi/IHdmi.aidl index 5536846cf8..457234d146 100644 --- a/tv/hdmi/aidl/android/hardware/tv/hdmi/IHdmi.aidl +++ b/tv/hdmi/aidl/android/hardware/tv/hdmi/IHdmi.aidl @@ -17,6 +17,7 @@ package android.hardware.tv.hdmi; import android.hardware.tv.hdmi.HdmiPortInfo; +import android.hardware.tv.hdmi.HpdSignal; import android.hardware.tv.hdmi.IHdmiCallback; /** @@ -48,4 +49,17 @@ interface IHdmi { * setCallback(null) should deregister the callback. */ void setCallback(in IHdmiCallback callback); + + /** + * Method to set the HPD (Hot Plug Detection) signal the HAL should use for HPD signaling (e.g. + * signaling EDID updates). By default, the HAL will use {@code HDMI_HPD_PHYSICAL} (the physical + * hotplug signal). When set to {@code HDMI_HPD_STATUS_BIT} the HAL should use the HDP status + * bit. + */ + void setHpdSignal(HpdSignal signal); + + /** + * Get the current signal the HAL is using for HPD + */ + HpdSignal getHpdSignal(); } diff --git a/tv/hdmi/aidl/android/hardware/tv/hdmi/Result.aidl b/tv/hdmi/aidl/android/hardware/tv/hdmi/Result.aidl new file mode 100644 index 0000000000..d2a1feff11 --- /dev/null +++ b/tv/hdmi/aidl/android/hardware/tv/hdmi/Result.aidl @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2022 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.tv.hdmi; + +/** + * Result enum for return values. Used by the HDMI related AIDL. + */ +@VintfStability +enum Result { + /** + * The HPD Signal type was set successfully. + */ + SUCCESS = 0, + + /** + * The HPD Signal type could not be set because of an unknown failure. + */ + FAILURE_UNKNOWN = 1, + + /** + * The HPD Signal type could not be set because the arguments were invalid. + */ + FAILURE_INVALID_ARGS = 2, + + /** + * The HPD Signal type could not be set because the HAL is in an invalid state. + */ + FAILURE_INVALID_STATE = 3, + + /** + * The HPD Signal type could not be set as the signal type is not supported. + */ + FAILURE_NOT_SUPPORTED = 4, +} diff --git a/tv/hdmi/aidl/default/HdmiMock.cpp b/tv/hdmi/aidl/default/HdmiMock.cpp index bbc4705814..7cd9bb7081 100644 --- a/tv/hdmi/aidl/default/HdmiMock.cpp +++ b/tv/hdmi/aidl/default/HdmiMock.cpp @@ -67,6 +67,21 @@ ScopedAStatus HdmiMock::setCallback(const std::shared_ptr& callba return ScopedAStatus::ok(); } +ScopedAStatus HdmiMock::setHpdSignal(HpdSignal signal) { + if (mHdmiThreadRun) { + mHpdSignal = signal; + return ScopedAStatus::ok(); + } else { + return ScopedAStatus::fromServiceSpecificError( + static_cast(Result::FAILURE_INVALID_STATE)); + } +} + +ScopedAStatus HdmiMock::getHpdSignal(HpdSignal* _aidl_return) { + *_aidl_return = mHpdSignal; + return ScopedAStatus::ok(); +} + void* HdmiMock::__threadLoop(void* user) { HdmiMock* const self = static_cast(user); self->threadLoop(); diff --git a/tv/hdmi/aidl/default/HdmiMock.h b/tv/hdmi/aidl/default/HdmiMock.h index 05795dd3aa..51abaff031 100644 --- a/tv/hdmi/aidl/default/HdmiMock.h +++ b/tv/hdmi/aidl/default/HdmiMock.h @@ -15,6 +15,7 @@ */ #include +#include #include #include @@ -29,8 +30,10 @@ namespace implementation { using ::aidl::android::hardware::tv::hdmi::BnHdmi; using ::aidl::android::hardware::tv::hdmi::HdmiPortInfo; using ::aidl::android::hardware::tv::hdmi::HdmiPortType; +using ::aidl::android::hardware::tv::hdmi::HpdSignal; using ::aidl::android::hardware::tv::hdmi::IHdmi; using ::aidl::android::hardware::tv::hdmi::IHdmiCallback; +using ::aidl::android::hardware::tv::hdmi::Result; #define HDMI_MSG_IN_FIFO "/dev/hdmi_in_pipe" #define MESSAGE_BODY_MAX_LENGTH 4 @@ -41,6 +44,8 @@ struct HdmiMock : public BnHdmi { ::ndk::ScopedAStatus getPortInfo(std::vector* _aidl_return) override; ::ndk::ScopedAStatus isConnected(int32_t portId, bool* _aidl_return) override; ::ndk::ScopedAStatus setCallback(const std::shared_ptr& callback) override; + ::ndk::ScopedAStatus setHpdSignal(HpdSignal signal) override; + ::ndk::ScopedAStatus getHpdSignal(HpdSignal* _aidl_return) override; void printEventBuf(const char* msg_buf, int len); @@ -62,6 +67,9 @@ struct HdmiMock : public BnHdmi { uint16_t mPhysicalAddress = 0xFFFF; int mTotalPorts = 1; + // HPD Signal being used + HpdSignal mHpdSignal = HpdSignal::HDMI_HPD_PHYSICAL; + // Testing variables // Input file descriptor int mInputFile; diff --git a/tv/hdmi/aidl/vts/functional/VtsHalTvHdmiAidlTargetTest.cpp b/tv/hdmi/aidl/vts/functional/VtsHalTvHdmiAidlTargetTest.cpp index 78c2590a95..fd4d94f628 100644 --- a/tv/hdmi/aidl/vts/functional/VtsHalTvHdmiAidlTargetTest.cpp +++ b/tv/hdmi/aidl/vts/functional/VtsHalTvHdmiAidlTargetTest.cpp @@ -31,6 +31,7 @@ using ::aidl::android::hardware::tv::hdmi::BnHdmiCallback; using ::aidl::android::hardware::tv::hdmi::HdmiPortInfo; using ::aidl::android::hardware::tv::hdmi::HdmiPortType; +using ::aidl::android::hardware::tv::hdmi::HpdSignal; using ::aidl::android::hardware::tv::hdmi::IHdmi; using ::aidl::android::hardware::tv::hdmi::IHdmiCallback; using ::ndk::SpAIBinder; @@ -101,3 +102,18 @@ TEST_P(HdmiTest, IsConnected) { ASSERT_TRUE(hdmi->isConnected(ports[i].portId, &connected).isOk()); } } + +TEST_P(HdmiTest, HdpSignal) { + HpdSignal originalSignal; + HpdSignal signal = HpdSignal::HDMI_HPD_STATUS_BIT; + HpdSignal readSignal; + ASSERT_TRUE(hdmi->getHpdSignal(&originalSignal).isOk()); + ASSERT_TRUE(hdmi->setHpdSignal(signal).isOk()); + ASSERT_TRUE(hdmi->getHpdSignal(&readSignal).isOk()); + EXPECT_EQ(readSignal, signal); + signal = HpdSignal::HDMI_HPD_PHYSICAL; + ASSERT_TRUE(hdmi->setHpdSignal(signal).isOk()); + ASSERT_TRUE(hdmi->getHpdSignal(&readSignal).isOk()); + EXPECT_EQ(readSignal, signal); + ASSERT_TRUE(hdmi->setHpdSignal(originalSignal).isOk()); +}