Merge "HDMI: Add Hotplug Detection Signal support"

This commit is contained in:
Treehugger Robot 2023-01-03 23:29:58 +00:00 committed by Gerrit Code Review
commit be1d5356f7
9 changed files with 211 additions and 0 deletions

View file

@ -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 <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.tv.hdmi;
@Backing(type="byte") @VintfStability
enum HpdSignal {
HDMI_HPD_PHYSICAL = 0,
HDMI_HPD_STATUS_BIT = 1,
}

View file

@ -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();
}

View file

@ -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 <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.tv.hdmi;
@VintfStability
enum Result {
SUCCESS = 0,
FAILURE_UNKNOWN = 1,
FAILURE_INVALID_ARGS = 2,
FAILURE_INVALID_STATE = 3,
FAILURE_NOT_SUPPORTED = 4,
}

View file

@ -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,
}

View file

@ -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();
}

View file

@ -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,
}

View file

@ -67,6 +67,21 @@ ScopedAStatus HdmiMock::setCallback(const std::shared_ptr<IHdmiCallback>& callba
return ScopedAStatus::ok();
}
ScopedAStatus HdmiMock::setHpdSignal(HpdSignal signal) {
if (mHdmiThreadRun) {
mHpdSignal = signal;
return ScopedAStatus::ok();
} else {
return ScopedAStatus::fromServiceSpecificError(
static_cast<int32_t>(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<HdmiMock*>(user);
self->threadLoop();

View file

@ -15,6 +15,7 @@
*/
#include <aidl/android/hardware/tv/hdmi/BnHdmi.h>
#include <aidl/android/hardware/tv/hdmi/Result.h>
#include <algorithm>
#include <vector>
@ -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<HdmiPortInfo>* _aidl_return) override;
::ndk::ScopedAStatus isConnected(int32_t portId, bool* _aidl_return) override;
::ndk::ScopedAStatus setCallback(const std::shared_ptr<IHdmiCallback>& 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;

View file

@ -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());
}