Merge "USB HAL V1.2 tests"
diff --git a/audio/5.0/config/api/current.txt b/audio/5.0/config/api/current.txt
index 822237e..17f38c1 100644
--- a/audio/5.0/config/api/current.txt
+++ b/audio/5.0/config/api/current.txt
@@ -20,8 +20,10 @@
enum_constant public static final audio.policy.configuration.V5_0.AudioDevice AUDIO_DEVICE_IN_COMMUNICATION;
enum_constant public static final audio.policy.configuration.V5_0.AudioDevice AUDIO_DEVICE_IN_DEFAULT;
enum_constant public static final audio.policy.configuration.V5_0.AudioDevice AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET;
+ enum_constant public static final audio.policy.configuration.V5_0.AudioDevice AUDIO_DEVICE_IN_ECHO_REFERENCE;
enum_constant public static final audio.policy.configuration.V5_0.AudioDevice AUDIO_DEVICE_IN_FM_TUNER;
enum_constant public static final audio.policy.configuration.V5_0.AudioDevice AUDIO_DEVICE_IN_HDMI;
+ enum_constant public static final audio.policy.configuration.V5_0.AudioDevice AUDIO_DEVICE_IN_HDMI_ARC;
enum_constant public static final audio.policy.configuration.V5_0.AudioDevice AUDIO_DEVICE_IN_IP;
enum_constant public static final audio.policy.configuration.V5_0.AudioDevice AUDIO_DEVICE_IN_LINE;
enum_constant public static final audio.policy.configuration.V5_0.AudioDevice AUDIO_DEVICE_IN_LOOPBACK;
@@ -91,6 +93,10 @@
enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_AAC_ERLC;
enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_AAC_HE_V1;
enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_AAC_HE_V2;
+ enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_AAC_LATM;
+ enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_AAC_LATM_HE_V1;
+ enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_AAC_LATM_HE_V2;
+ enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_AAC_LATM_LC;
enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_AAC_LC;
enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_AAC_LD;
enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_AAC_LTP;
@@ -106,7 +112,9 @@
enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_AMR_WB_PLUS;
enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_APE;
enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_APTX;
+ enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_APTX_ADAPTIVE;
enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_APTX_HD;
+ enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_CELT;
enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_DOLBY_TRUEHD;
enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_DSD;
enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_DTS;
@@ -122,6 +130,8 @@
enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_HE_AAC_V2;
enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_IEC61937;
enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_LDAC;
+ enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_LHDC;
+ enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_LHDC_LL;
enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_MAT_1_0;
enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_MAT_2_0;
enum_constant public static final audio.policy.configuration.V5_0.AudioFormat AUDIO_FORMAT_MAT_2_1;
diff --git a/audio/5.0/config/audio_policy_configuration.xsd b/audio/5.0/config/audio_policy_configuration.xsd
index efe93b3..ee3a437 100644
--- a/audio/5.0/config/audio_policy_configuration.xsd
+++ b/audio/5.0/config/audio_policy_configuration.xsd
@@ -277,6 +277,8 @@
<xs:enumeration value="AUDIO_DEVICE_IN_PROXY"/>
<xs:enumeration value="AUDIO_DEVICE_IN_USB_HEADSET"/>
<xs:enumeration value="AUDIO_DEVICE_IN_BLUETOOTH_BLE"/>
+ <xs:enumeration value="AUDIO_DEVICE_IN_HDMI_ARC"/>
+ <xs:enumeration value="AUDIO_DEVICE_IN_ECHO_REFERENCE"/>
<xs:enumeration value="AUDIO_DEVICE_IN_DEFAULT"/>
<xs:enumeration value="AUDIO_DEVICE_IN_STUB"/>
</xs:restriction>
@@ -364,6 +366,14 @@
<xs:enumeration value="AUDIO_FORMAT_MAT_2_1"/>
<xs:enumeration value="AUDIO_FORMAT_AAC_XHE"/>
<xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_XHE"/>
+ <xs:enumeration value="AUDIO_FORMAT_AAC_LATM"/>
+ <xs:enumeration value="AUDIO_FORMAT_AAC_LATM_LC"/>
+ <xs:enumeration value="AUDIO_FORMAT_AAC_LATM_HE_V1"/>
+ <xs:enumeration value="AUDIO_FORMAT_AAC_LATM_HE_V2"/>
+ <xs:enumeration value="AUDIO_FORMAT_CELT"/>
+ <xs:enumeration value="AUDIO_FORMAT_APTX_ADAPTIVE"/>
+ <xs:enumeration value="AUDIO_FORMAT_LHDC"/>
+ <xs:enumeration value="AUDIO_FORMAT_LHDC_LL"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="extendableAudioFormat">
diff --git a/audio/common/5.0/types.hal b/audio/common/5.0/types.hal
index b4e9470..ffe4506 100644
--- a/audio/common/5.0/types.hal
+++ b/audio/common/5.0/types.hal
@@ -235,6 +235,12 @@
LDAC = 0x23000000UL,
/** Dolby Metadata-enhanced Audio Transmission */
MAT = 0x24000000UL,
+ AAC_LATM = 0x25000000UL,
+ CELT = 0x26000000UL,
+ APTX_ADAPTIVE = 0x27000000UL,
+ LHDC = 0x28000000UL,
+ LHDC_LL = 0x29000000UL,
+
/** Deprecated */
MAIN_MASK = 0xFF000000UL,
SUB_MASK = 0x00FFFFFFUL,
@@ -306,6 +312,9 @@
MAT_1_0 = (MAT | MAT_SUB_1_0),
MAT_2_0 = (MAT | MAT_SUB_2_0),
MAT_2_1 = (MAT | MAT_SUB_2_1),
+ AAC_LATM_LC = (AAC_LATM | AAC_SUB_LC),
+ AAC_LATM_HE_V1 = (AAC_LATM | AAC_SUB_HE_V1),
+ AAC_LATM_HE_V2 = (AAC_LATM | AAC_SUB_HE_V2),
};
/**
diff --git a/audio/effect/2.0/xml/audio_effects_conf.xsd b/audio/effect/2.0/xml/audio_effects_conf.xsd
index df281b3..b97b847 100644
--- a/audio/effect/2.0/xml/audio_effects_conf.xsd
+++ b/audio/effect/2.0/xml/audio_effects_conf.xsd
@@ -39,6 +39,7 @@
<xs:enumeration value="voice_recognition"/>
<xs:enumeration value="voice_communication"/>
<xs:enumeration value="unprocessed"/>
+ <xs:enumeration value="voice_performance"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="streamOutputType">
diff --git a/audio/effect/5.0/xml/api/current.txt b/audio/effect/5.0/xml/api/current.txt
index 4a7f88b..473bb10 100644
--- a/audio/effect/5.0/xml/api/current.txt
+++ b/audio/effect/5.0/xml/api/current.txt
@@ -74,6 +74,7 @@
enum_constant public static final audio.effects.V5_0.StreamInputType voice_call;
enum_constant public static final audio.effects.V5_0.StreamInputType voice_communication;
enum_constant public static final audio.effects.V5_0.StreamInputType voice_downlink;
+ enum_constant public static final audio.effects.V5_0.StreamInputType voice_performance;
enum_constant public static final audio.effects.V5_0.StreamInputType voice_recognition;
enum_constant public static final audio.effects.V5_0.StreamInputType voice_uplink;
}
diff --git a/bluetooth/audio/2.0/Android.bp b/bluetooth/audio/2.0/Android.bp
index 6049fe2..5d67f75 100644
--- a/bluetooth/audio/2.0/Android.bp
+++ b/bluetooth/audio/2.0/Android.bp
@@ -16,13 +16,25 @@
],
types: [
"AacObjectType",
+ "AacParameters",
+ "AacVariableBitRate",
+ "AptxParameters",
+ "AudioCapabilities",
+ "AudioConfiguration",
"BitsPerSample",
"ChannelMode",
+ "CodecCapabilities",
"CodecConfiguration",
"CodecType",
"LdacChannelMode",
+ "LdacParameters",
+ "LdacQualityIndex",
+ "PcmParameters",
"SampleRate",
+ "SbcAllocMethod",
+ "SbcBlockLength",
"SbcChannelMode",
+ "SbcParameters",
"SessionType",
"Status",
"TimeSpec",
diff --git a/bluetooth/audio/2.0/IBluetoothAudioPort.hal b/bluetooth/audio/2.0/IBluetoothAudioPort.hal
index 17d13b8..fedc8d3 100644
--- a/bluetooth/audio/2.0/IBluetoothAudioPort.hal
+++ b/bluetooth/audio/2.0/IBluetoothAudioPort.hal
@@ -27,6 +27,9 @@
*
* Moreover, the Audio HAL can also get the presentation position of the stream
* and provide stream metadata.
+ *
+ * Note: For HIDL APIs with a "generates" statement, the callback parameter used
+ * for return value must be invoked synchronously before the API call returns.
*/
interface IBluetoothAudioPort {
/**
diff --git a/bluetooth/audio/2.0/IBluetoothAudioProvider.hal b/bluetooth/audio/2.0/IBluetoothAudioProvider.hal
index bb5eb1b..2b08cc3 100644
--- a/bluetooth/audio/2.0/IBluetoothAudioProvider.hal
+++ b/bluetooth/audio/2.0/IBluetoothAudioProvider.hal
@@ -23,6 +23,9 @@
*
* The Bluetooth stack calls methods in this interface to start and end audio
* sessions and sends callback events to the Audio HAL.
+ *
+ * Note: For HIDL APIs with a "generates" statement, the callback parameter used
+ * for return value must be invoked synchronously before the API call returns.
*/
interface IBluetoothAudioProvider {
@@ -35,8 +38,10 @@
* Note: endSession() must be called to unregister this IBluetoothAudioPort
*
* @param hostIf An instance of IBluetoothAudioPort for stream control
- * @param codecConfig The codec configuration negotiated with the remote
- * device
+ * @param audioConfig The audio configuration negotiated with the remote
+ * device. The PCM parameters are set if software based encoding,
+ * otherwise the correct codec configuration is used for hardware
+ * encoding.
*
* @return status One of the following
* SUCCESS if this IBluetoothAudioPort was successfully registered with
@@ -47,10 +52,10 @@
* any other reason
* @return dataMQ The fast message queue for audio data from this provider.
* Audio data will be in PCM format as specified by the
- * codecConfig.pcmDataConfiguration parameter.
- * nullptr if streaming is offloaded to hardware or on failure.
+ * audioConfig.pcmConfig parameter.
+ * Invalid if streaming is offloaded to hardware or on failure.
*/
- startSession(IBluetoothAudioPort hostIf, CodecConfiguration codecConfig)
+ startSession(IBluetoothAudioPort hostIf, AudioConfiguration audioConfig)
generates (Status status, fmq_sync<uint8_t> dataMQ);
/**
diff --git a/bluetooth/audio/2.0/IBluetoothAudioProvidersFactory.hal b/bluetooth/audio/2.0/IBluetoothAudioProvidersFactory.hal
index 56b8594..1025665 100644
--- a/bluetooth/audio/2.0/IBluetoothAudioProvidersFactory.hal
+++ b/bluetooth/audio/2.0/IBluetoothAudioProvidersFactory.hal
@@ -25,6 +25,9 @@
* When the Bluetooth stack is ready to create an audio session, it must first
* obtain the IBluetoothAudioProvider for that session type by calling
* openProvider().
+ *
+ * Note: For HIDL APIs with a "generates" statement, the callback parameter used
+ * for return value must be invoked synchronously before the API call returns.
*/
interface IBluetoothAudioProvidersFactory {
@@ -43,4 +46,26 @@
*/
openProvider(SessionType sessionType)
generates (Status status, IBluetoothAudioProvider provider);
+
+ /**
+ * Gets a list of audio capabilities for a session type.
+ *
+ * For software encoding, the PCM capabilities are returned.
+ * For hardware encoding, the supported codecs and their capabilities are
+ * returned.
+ *
+ * @param sessionType The session type (e.g.
+ * A2DP_SOFTWARE_ENCODING_DATAPATH).
+ * @return audioCapabilities A list containing all the capabilities
+ * supported by the sesson type. The capabilities is a list of
+ * available options when configuring the codec for the session.
+ * For software encoding it is the PCM data rate.
+ * For hardware encoding it is the list of supported codecs and their
+ * capabilities.
+ * If a provider isn't supported, an empty list should be returned.
+ * Note: Only one entry should exist per codec when using hardware
+ * encoding.
+ */
+ getProviderCapabilities(SessionType sessionType)
+ generates (vec<AudioCapabilities> audioCapabilities);
};
diff --git a/bluetooth/audio/2.0/types.hal b/bluetooth/audio/2.0/types.hal
index 9286948..909dd57 100644
--- a/bluetooth/audio/2.0/types.hal
+++ b/bluetooth/audio/2.0/types.hal
@@ -17,6 +17,14 @@
package android.hardware.bluetooth.audio@2.0;
/**
+ * The different audio parameter structs are used to provide a method to list
+ * all the Capabilities of a codec as well as to configure the codecs. All
+ * fields are bitfields unless specified. If used as a configuration, only one
+ * bit may be enabled. If used for Capabilities, enable all bits corresponding to
+ * supported features.
+ */
+
+/**
* POSIX timespec.
*/
struct TimeSpec {
@@ -85,6 +93,25 @@
MONO = 0x08,
};
+enum SbcBlockLength : uint8_t {
+ BLOCKS_4 = 0x80,
+ BLOCKS_8 = 0x40,
+ BLOCKS_12 = 0x20,
+ BLOCKS_16 = 0x10,
+};
+
+enum SbcNumSubbands : uint8_t {
+ SUBBAND_4 = 0x08,
+ SUBBAND_8 = 0x04,
+};
+
+enum SbcAllocMethod : uint8_t {
+ /** SNR */
+ ALLOC_MD_S = 0x02,
+ /** Loudness */
+ ALLOC_MD_L = 0x01,
+};
+
enum AacObjectType : uint8_t {
/** MPEG-2 Low Complexity. Support is Mandatory. */
MPEG2_LC = 0x80,
@@ -96,6 +123,11 @@
MPEG4_SCALABLE = 0x10,
};
+enum AacVariableBitRate : uint8_t {
+ ENABLED = 0x80,
+ DISABLED = 0x00,
+};
+
enum LdacChannelMode : uint8_t {
/** Channel Mode: 3 bits */
UNKNOWN = 0x00,
@@ -104,67 +136,117 @@
MONO = 0x04,
};
-struct CodecConfiguration {
- /** Audio PCM data configuration */
- struct PcmDataConfiguration {
- /** Sampling rate for encoder */
- SampleRate sampleRate;
- /** Bits per sample for encoder */
- BitsPerSample bitsPerSample;
- /** Channel mode for encoder */
- ChannelMode channelMode;
- } pcmDataConfiguration;
+enum LdacQualityIndex : uint8_t {
+ // 990kbps
+ QUALITY_HIGH = 0x00,
+ // 660kbps
+ QUALITY_MID = 0x01,
+ // 330kbps
+ QUALITY_LOW = 0x02,
+ // Adaptive Bit Rate mode
+ QUALITY_ABR = 0x7F,
+};
- /** Encoded audio data codec configuration. It is used only if the
- * HAL is responsible for encoding the PCM audio data. */
- struct EncodedDataConfiguration {
- /** Bluetooth A2DP codec */
- CodecType codecType;
- /**
- * The encoded audio bitrate in bits / second.
- * 0x00000000 - The audio bitrate is not specified / unused
- * 0x00000001 - 0x00FFFFFF - Encoded audio bitrate in bits/second
- * 0x01000000 - 0xFFFFFFFF - Reserved
- */
- uint32_t encodedAudioBitrate;
- /** Peer MTU (in octets) */
- uint16_t peerMtu;
- /** Content protection by SCMS-T */
- bool isScmstEnabled;
- safe_union CodecSpecific {
- /**
- * SBC Codec specific information
- * Refer to SBC Codec specific information elements in A2DP v1.3
- * Profile Specification.
- */
- struct SbcData {
- /** Reserved: 4 bits | Channel Mode: 4 bits */
- SbcChannelMode channelMode;
- /** Block length: 4 bits | Subbands: 2 bits | Allocation Method: 2 bits */
- uint8_t codecParameters;
- /** Minimum bitpool value */
- uint8_t minBitpool;
- /** Maximum bitpool value */
- uint8_t maxBitpool;
- } sbcData;
- struct AacData {
- /** AAC Object Type */
- AacObjectType aacObjectType;
- /** True if Variable Bit Rate is enabled */
- bool variableBitRateEnabled;
- } aacData;
- struct LdacData {
- /** Reserved: 5 bits | Channel Mode: 3 bits */
- LdacChannelMode channelMode;
- /**
- * LDAC bitrate index value:
- * 0x00 - High
- * 0x01 - Mid
- * 0x02 - Low
- * 0x7F - ABR (Adaptive Bit Rate)
- */
- uint8_t bitrateIndex;
- } ldacData;
- } codecSpecific;
- } encodedDataConfiguration;
+/** Used for Software Encoding audio feed parameters */
+struct PcmParameters {
+ SampleRate sampleRate;
+ ChannelMode channelMode;
+ BitsPerSample bitsPerSample;
+};
+
+/**
+ * Used for Hardware Encoding SBC codec parameters.
+ * minBitpool and maxBitpool are not bitfields.
+ */
+struct SbcParameters {
+ SampleRate sampleRate;
+ SbcChannelMode channelMode;
+ SbcBlockLength blockLength;
+ SbcNumSubbands numSubbands;
+ SbcAllocMethod allocMethod;
+ BitsPerSample bitsPerSample;
+ uint8_t minBitpool;
+ uint8_t maxBitpool;
+};
+
+/** Used for Hardware Encoding AAC codec parameters */
+struct AacParameters {
+ AacObjectType objectType;
+ SampleRate sampleRate;
+ ChannelMode channelMode;
+ AacVariableBitRate variableBitRateEnabled;
+ BitsPerSample bitsPerSample;
+};
+
+/**
+ * Used for Hardware Encoding LDAC codec parameters
+ * Only used when configuring the codec. When Capabilities are requested, this
+ * field is left empty since all qualities must be supported. Not a bitfield.
+ */
+struct LdacParameters {
+ SampleRate sampleRate;
+ LdacChannelMode channelMode;
+ LdacQualityIndex qualityIndex;
+ BitsPerSample bitsPerSample;
+};
+
+/** Used for Hardware Encoding AptX and AptX-HD codec parameters */
+struct AptxParameters {
+ SampleRate sampleRate;
+ ChannelMode channelMode;
+ BitsPerSample bitsPerSample;
+};
+
+/**
+ * Used to specify the capabilities of the codecs supported by Hardware Encoding.
+ * AptX and AptX-HD both use the AptxParameters field.
+ */
+struct CodecCapabilities {
+ CodecType codecType;
+
+ safe_union Capabilities {
+ SbcParameters sbcCapabilities;
+ AacParameters aacCapabilities;
+ LdacParameters ldacCapabilities;
+ AptxParameters aptxCapabilities;
+ } capabilities;
+};
+
+/** Used to specify the capabilities of the different session types. */
+safe_union AudioCapabilities {
+ PcmParameters pcmCapabilities;
+ CodecCapabilities codecCapabilities;
+};
+
+/**
+ * Used to configure a Hardware Encoding session.
+ * AptX and AptX-HD both use the AptxParameters field.
+ */
+struct CodecConfiguration {
+ CodecType codecType;
+ /**
+ * The encoded audio bitrate in bits / second.
+ * 0x00000000 - The audio bitrate is not specified / unused
+ * 0x00000001 - 0x00FFFFFF - Encoded audio bitrate in bits/second
+ * 0x01000000 - 0xFFFFFFFF - Reserved
+ *
+ * The HAL needs to support all legal bitrates for the selected codec.
+ */
+ uint32_t encodedAudioBitrate;
+ /** Peer MTU (in octets) */
+ uint16_t peerMtu;
+ /** Content protection by SCMS-T */
+ bool isScmstEnabled;
+ safe_union CodecSpecific {
+ SbcParameters sbcConfig;
+ AacParameters aacConfig;
+ LdacParameters ldacConfig;
+ AptxParameters aptxConfig;
+ } config;
+};
+
+/** Used to configure either a Hardware or Software Encoding session based on session type */
+safe_union AudioConfiguration {
+ PcmParameters pcmConfig;
+ CodecConfiguration codecConfig;
};
diff --git a/camera/metadata/3.4/types.hal b/camera/metadata/3.4/types.hal
index 61a399e..28c56c8 100644
--- a/camera/metadata/3.4/types.hal
+++ b/camera/metadata/3.4/types.hal
@@ -75,6 +75,14 @@
ANDROID_DEPTH_END_3_4,
+ /** android.logicalMultiCamera.activePhysicalId [dynamic, byte, public]
+ *
+ * <p>String containing the ID of the underlying active physical camera.</p>
+ */
+ ANDROID_LOGICAL_MULTI_CAMERA_ACTIVE_PHYSICAL_ID = android.hardware.camera.metadata@3.3::CameraMetadataTag:ANDROID_LOGICAL_MULTI_CAMERA_END_3_3,
+
+ ANDROID_LOGICAL_MULTI_CAMERA_END_3_4,
+
};
/*
diff --git a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
index c98e328..1556c08 100644
--- a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
+++ b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
@@ -114,6 +114,8 @@
using ::android::hardware::camera::device::V1_0::FrameCallbackFlag;
using ::android::hardware::camera::device::V1_0::HandleTimestampMessage;
using ::android::hardware::camera::metadata::V3_4::CameraMetadataEnumAndroidSensorInfoColorFilterArrangement;
+using ::android::hardware::camera::metadata::V3_4::CameraMetadataTag;
+using ::android::hardware::camera::device::V3_4::PhysicalCameraMetadata;
using ::android::hardware::MessageQueue;
using ::android::hardware::kSynchronizedReadWrite;
using ::android::hidl::allocator::V1_0::IAllocator;
@@ -587,8 +589,8 @@
};
struct DeviceCb : public V3_5::ICameraDeviceCallback {
- DeviceCb(CameraHidlTest *parent, bool checkMonochromeResult) : mParent(parent),
- mCheckMonochromeResult(checkMonochromeResult) {}
+ DeviceCb(CameraHidlTest *parent, int deviceVersion, const camera_metadata_t *staticMeta) :
+ mParent(parent), mDeviceVersion(deviceVersion), mStaticMetadata(staticMeta) {}
Return<void> processCaptureResult_3_4(
const hidl_vec<V3_4::CaptureResult>& results) override;
@@ -607,10 +609,12 @@
void waitForBuffersReturned();
private:
- bool processCaptureResultLocked(const CaptureResult& results);
+ bool processCaptureResultLocked(const CaptureResult& results,
+ hidl_vec<PhysicalCameraMetadata> physicalCameraMetadata);
CameraHidlTest *mParent; // Parent object
- bool mCheckMonochromeResult;
+ int mDeviceVersion;
+ const camera_metadata_t *mStaticMetadata;
bool hasOutstandingBuffersLocked();
/* members for requestStreamBuffers() and returnStreamBuffers()*/
@@ -755,6 +759,8 @@
void verifyStreamCombination(sp<device::V3_5::ICameraDevice> cameraDevice3_5,
const ::android::hardware::camera::device::V3_4::StreamConfiguration &config3_4,
bool expectedStatus);
+ void verifyLogicalCameraResult(const camera_metadata_t* staticMetadata,
+ const ::android::hardware::camera::common::V1_0::helper::CameraMetadata& resultMetadata);
void verifyBuffersReturned(sp<device::V3_2::ICameraDeviceSession> session,
int deviceVerison, int32_t streamId, sp<DeviceCb> cb,
@@ -1008,7 +1014,7 @@
bool notify = false;
std::unique_lock<std::mutex> l(mParent->mLock);
for (size_t i = 0 ; i < results.size(); i++) {
- notify = processCaptureResultLocked(results[i].v3_2);
+ notify = processCaptureResultLocked(results[i].v3_2, results[i].physicalCameraMetadata);
}
l.unlock();
@@ -1027,8 +1033,9 @@
bool notify = false;
std::unique_lock<std::mutex> l(mParent->mLock);
+ ::android::hardware::hidl_vec<PhysicalCameraMetadata> noPhysMetadata;
for (size_t i = 0 ; i < results.size(); i++) {
- notify = processCaptureResultLocked(results[i]);
+ notify = processCaptureResultLocked(results[i], noPhysMetadata);
}
l.unlock();
@@ -1039,7 +1046,8 @@
return Void();
}
-bool CameraHidlTest::DeviceCb::processCaptureResultLocked(const CaptureResult& results) {
+bool CameraHidlTest::DeviceCb::processCaptureResultLocked(const CaptureResult& results,
+ hidl_vec<PhysicalCameraMetadata> physicalCameraMetadata) {
bool notify = false;
uint32_t frameNumber = results.frameNumber;
@@ -1080,6 +1088,20 @@
ADD_FAILURE();
return notify;
}
+
+ std::vector<::android::hardware::camera::device::V3_2::CameraMetadata> physResultMetadata;
+ physResultMetadata.resize(physicalCameraMetadata.size());
+ for (size_t i = 0; i < physicalCameraMetadata.size(); i++) {
+ physResultMetadata[i].resize(physicalCameraMetadata[i].fmqMetadataSize);
+ if (!request->resultQueue->read(physResultMetadata[i].data(),
+ physicalCameraMetadata[i].fmqMetadataSize)) {
+ ALOGE("%s: Frame %d: Cannot read physical camera metadata from fmq,"
+ "size = %" PRIu64, __func__, frameNumber,
+ physicalCameraMetadata[i].fmqMetadataSize);
+ ADD_FAILURE();
+ return notify;
+ }
+ }
resultSize = resultMetadata.size();
} else if (results.result.size() > 0) {
resultMetadata.setToExternal(const_cast<uint8_t *>(
@@ -1137,8 +1159,20 @@
request->collectedResult.sort();
// Verify final result metadata
- if (mCheckMonochromeResult) {
- mParent->verifyMonochromeCameraResult(request->collectedResult);
+ bool isAtLeast_3_5 = mDeviceVersion >= CAMERA_DEVICE_API_VERSION_3_5;
+ if (isAtLeast_3_5) {
+ bool isMonochrome = Status::OK ==
+ CameraHidlTest::isMonochromeCamera(mStaticMetadata);
+ if (isMonochrome) {
+ mParent->verifyMonochromeCameraResult(request->collectedResult);
+ }
+
+ // Verify logical camera result metadata
+ bool isLogicalCamera =
+ Status::OK == CameraHidlTest::isLogicalMultiCamera(mStaticMetadata);
+ if (isLogicalCamera) {
+ mParent->verifyLogicalCameraResult(mStaticMetadata, request->collectedResult);
+ }
}
}
@@ -5058,7 +5092,7 @@
ASSERT_EQ(Status::OK, s);
staticMeta = clone_camera_metadata(
reinterpret_cast<const camera_metadata_t*>(metadata.data()));
- ASSERT_NE(nullptr, staticMeta);
+ ASSERT_NE(nullptr, staticMeta);
});
ASSERT_TRUE(ret.isOk());
@@ -5070,9 +5104,7 @@
*supportsPartialResults = (*partialResultCount > 1);
}
- bool checkMonochromeResultTags = Status::OK == isMonochromeCamera(staticMeta) &&
- deviceVersion >= CAMERA_DEVICE_API_VERSION_3_5;
- sp<DeviceCb> cb = new DeviceCb(this, checkMonochromeResultTags);
+ sp<DeviceCb> cb = new DeviceCb(this, deviceVersion, staticMeta);
sp<ICameraDeviceSession> session;
ret = device3_x->open(
cb,
@@ -5210,9 +5242,7 @@
*supportsPartialResults = (*partialResultCount > 1);
}
- bool checkMonochromeResultTags = Status::OK == isMonochromeCamera(staticMeta) &&
- deviceVersion >= CAMERA_DEVICE_API_VERSION_3_5;
- sp<DeviceCb> cb = new DeviceCb(this, checkMonochromeResultTags);
+ sp<DeviceCb> cb = new DeviceCb(this, deviceVersion, staticMeta);
ret = device3_x->open(
cb,
[&](auto status, const auto& newSession) {
@@ -5441,6 +5471,22 @@
});
ASSERT_TRUE(ret.isOk());
}
+
+ // Make sure ANDROID_LOGICAL_MULTI_CAMERA_ACTIVE_PHYSICAL_ID is available in
+ // result keys.
+ if (deviceVersion >= CAMERA_DEVICE_API_VERSION_3_5) {
+ camera_metadata_ro_entry entry;
+ int retcode = find_camera_metadata_ro_entry(metadata,
+ ANDROID_REQUEST_AVAILABLE_RESULT_KEYS, &entry);
+ if ((0 == retcode) && (entry.count > 0)) {
+ ASSERT_NE(std::find(entry.data.i32, entry.data.i32 + entry.count,
+ static_cast<int32_t>(
+ CameraMetadataTag::ANDROID_LOGICAL_MULTI_CAMERA_ACTIVE_PHYSICAL_ID)),
+ entry.data.i32 + entry.count);
+ } else {
+ ADD_FAILURE() << "Get camera availableResultKeys failed!";
+ }
+ }
}
void CameraHidlTest::verifyCameraCharacteristics(Status status, const CameraMetadata& chars) {
@@ -5649,6 +5695,24 @@
cb->waitForBuffersReturned();
}
+void CameraHidlTest::verifyLogicalCameraResult(const camera_metadata_t* staticMetadata,
+ const ::android::hardware::camera::common::V1_0::helper::CameraMetadata& resultMetadata) {
+ std::unordered_set<std::string> physicalIds;
+ Status rc = getPhysicalCameraIds(staticMetadata, &physicalIds);
+ ASSERT_TRUE(Status::OK == rc);
+ ASSERT_TRUE(physicalIds.size() > 1);
+
+ camera_metadata_ro_entry entry;
+ // Check mainPhysicalId
+ entry = resultMetadata.find(ANDROID_LOGICAL_MULTI_CAMERA_ACTIVE_PHYSICAL_ID);
+ if (entry.count > 0) {
+ std::string mainPhysicalId(reinterpret_cast<const char *>(entry.data.u8));
+ ASSERT_NE(physicalIds.find(mainPhysicalId), physicalIds.end());
+ } else {
+ ADD_FAILURE() << "Get LOGICAL_MULTI_CAMERA_ACTIVE_PHYSICAL_ID failed!";
+ }
+}
+
// Open a device session with empty callbacks and return static metadata.
void CameraHidlTest::openEmptyDeviceSession(const std::string &name, sp<ICameraProvider> provider,
sp<ICameraDeviceSession> *session /*out*/, camera_metadata_t **staticMeta /*out*/,
diff --git a/drm/1.2/IDrmFactory.hal b/drm/1.2/IDrmFactory.hal
index c94e4bb..682889c 100644
--- a/drm/1.2/IDrmFactory.hal
+++ b/drm/1.2/IDrmFactory.hal
@@ -17,6 +17,7 @@
import @1.1::IDrmFactory;
import @1.1::IDrmPlugin;
+import @1.1::SecurityLevel;
/**
* IDrmFactory is the main entry point for interacting with a vendor's
@@ -35,4 +36,16 @@
*/
interface IDrmFactory extends @1.1::IDrmFactory {
+ /**
+ * Determine if a specific security level is supported by the device.
+ * This method only differs from @1.0 isCryptoSchemeSupported
+ * by the addition of a security level.
+ *
+ * @param uuid identifies the crypto scheme in question
+ * @param mimeType identifies the mime type in question
+ * @param securityLevel specifies the security level required
+ * @return isSupported must be true only if the scheme is supported
+ */
+ isCryptoSchemeSupported_1_2(uint8_t[16] uuid, string mimeType,
+ @1.1::SecurityLevel securityLevel) generates(bool isSupported);
};
diff --git a/graphics/mapper/2.1/utils/passthrough/include/mapper-passthrough/2.1/Gralloc1Hal.h b/graphics/mapper/2.1/utils/passthrough/include/mapper-passthrough/2.1/Gralloc1Hal.h
index 08d604e..c9836e5 100644
--- a/graphics/mapper/2.1/utils/passthrough/include/mapper-passthrough/2.1/Gralloc1Hal.h
+++ b/graphics/mapper/2.1/utils/passthrough/include/mapper-passthrough/2.1/Gralloc1Hal.h
@@ -28,7 +28,7 @@
using V2_0::BufferDescriptor;
using V2_0::Error;
-using android::hardware::graphics::common::V1_0::BufferUsage;
+using android::hardware::graphics::common::V1_1::BufferUsage;
namespace detail {
@@ -72,6 +72,8 @@
Error createDescriptor_2_1(const IMapper::BufferDescriptorInfo& descriptorInfo,
BufferDescriptor* outDescriptor) override {
+ if (gralloc1UsageUnsupported(descriptorInfo.usage))
+ return Error::BAD_DESCRIPTOR;
return createDescriptor(
V2_0::IMapper::BufferDescriptorInfo{
descriptorInfo.width, descriptorInfo.height, descriptorInfo.layerCount,
@@ -163,6 +165,16 @@
return consumerUsage;
}
+ static bool gralloc1UsageUnsupported(uint64_t usage) {
+ // Certain newer public usage bits should not be used with gralloc1.
+ // We use a blacklist instead of a whitelist here in order to avoid
+ // breaking private usage flags.
+ constexpr uint64_t unsupportedMask = BufferUsage::GPU_CUBE_MAP |
+ BufferUsage::GPU_MIPMAP_COMPLETE;
+
+ return usage & unsupportedMask;
+ }
+
private:
using BaseType2_0 = V2_0::passthrough::detail::Gralloc1HalImpl<Hal>;
using BaseType2_0::createDescriptor;
diff --git a/light/2.0/default/Android.bp b/light/2.0/default/Android.bp
index 8b5f780..72cc873 100644
--- a/light/2.0/default/Android.bp
+++ b/light/2.0/default/Android.bp
@@ -31,13 +31,11 @@
}
-cc_binary {
- name: "android.hardware.light@2.0-service",
+cc_defaults {
+ name: "light_service_defaults",
relative_install_path: "hw",
defaults: ["hidl_defaults"],
vendor: true,
- init_rc: ["android.hardware.light@2.0-service.rc"],
- srcs: ["service.cpp"],
shared_libs: [
"liblog",
@@ -49,5 +47,19 @@
"libhidltransport",
"android.hardware.light@2.0",
],
+}
-}
\ No newline at end of file
+cc_binary {
+ name: "android.hardware.light@2.0-service",
+ defaults: ["light_service_defaults"],
+ init_rc: ["android.hardware.light@2.0-service.rc"],
+ srcs: ["service.cpp"],
+}
+
+cc_binary {
+ name: "android.hardware.light@2.0-service-lazy",
+ overrides: ["android.hardware.light@2.0-service"],
+ defaults: ["light_service_defaults"],
+ init_rc: ["android.hardware.light@2.0-service-lazy.rc"],
+ srcs: ["serviceLazy.cpp"],
+}
diff --git a/light/2.0/default/android.hardware.light@2.0-service-lazy.rc b/light/2.0/default/android.hardware.light@2.0-service-lazy.rc
new file mode 100644
index 0000000..8a3a59c
--- /dev/null
+++ b/light/2.0/default/android.hardware.light@2.0-service-lazy.rc
@@ -0,0 +1,9 @@
+service vendor.light-hal-2-0 /vendor/bin/hw/android.hardware.light@2.0-service-lazy
+ interface android.hardware.light@2.0::ILight default
+ oneshot
+ disabled
+ class hal
+ user system
+ group system
+ # shutting off lights while powering-off
+ shutdown critical
diff --git a/light/2.0/default/service.cpp b/light/2.0/default/service.cpp
index 70ae565..20f0578 100644
--- a/light/2.0/default/service.cpp
+++ b/light/2.0/default/service.cpp
@@ -14,8 +14,6 @@
* limitations under the License.
*/
-#define LOG_TAG "android.hardware.light@2.0-service"
-
#include <android/hardware/light/2.0/ILight.h>
#include <hidl/LegacySupport.h>
diff --git a/light/2.0/default/serviceLazy.cpp b/light/2.0/default/serviceLazy.cpp
new file mode 100644
index 0000000..5324f46
--- /dev/null
+++ b/light/2.0/default/serviceLazy.cpp
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2019 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.
+ */
+
+#include <android/hardware/light/2.0/ILight.h>
+#include <hidl/LegacySupport.h>
+
+using android::hardware::defaultLazyPassthroughServiceImplementation;
+using android::hardware::light::V2_0::ILight;
+
+int main() {
+ return defaultLazyPassthroughServiceImplementation<ILight>();
+}
diff --git a/neuralnetworks/1.0/vts/functional/Android.bp b/neuralnetworks/1.0/vts/functional/Android.bp
index dd6f934..2920cec 100644
--- a/neuralnetworks/1.0/vts/functional/Android.bp
+++ b/neuralnetworks/1.0/vts/functional/Android.bp
@@ -22,6 +22,9 @@
],
defaults: ["VtsHalTargetTestDefaults"],
export_include_dirs: ["."],
+ shared_libs: [
+ "libnativewindow",
+ ],
static_libs: [
"android.hardware.neuralnetworks@1.0",
"android.hardware.neuralnetworks@1.1",
@@ -47,6 +50,9 @@
"ValidateRequest.cpp",
"VtsHalNeuralnetworks.cpp",
],
+ shared_libs: [
+ "libnativewindow",
+ ],
static_libs: [
"android.hardware.neuralnetworks@1.0",
"android.hardware.neuralnetworks@1.1",
diff --git a/neuralnetworks/1.0/vts/functional/Callbacks.cpp b/neuralnetworks/1.0/vts/functional/Callbacks.cpp
index 03afcd0..c30702c 100644
--- a/neuralnetworks/1.0/vts/functional/Callbacks.cpp
+++ b/neuralnetworks/1.0/vts/functional/Callbacks.cpp
@@ -135,14 +135,18 @@
Return<void> ExecutionCallback::notify(ErrorStatus errorStatus) {
mErrorStatus = errorStatus;
+ mOutputShapes = {};
+ mTiming = {.timeOnDevice = UINT64_MAX, .timeInDriver = UINT64_MAX};
CallbackBase::notify();
return Void();
}
Return<void> ExecutionCallback::notify_1_2(ErrorStatus errorStatus,
- const hidl_vec<OutputShape>& outputShapes) {
+ const hidl_vec<OutputShape>& outputShapes,
+ const Timing& timing) {
mErrorStatus = errorStatus;
mOutputShapes = outputShapes;
+ mTiming = timing;
CallbackBase::notify();
return Void();
}
@@ -157,6 +161,11 @@
return mOutputShapes;
}
+Timing ExecutionCallback::getTiming() {
+ wait();
+ return mTiming;
+}
+
} // namespace implementation
} // namespace V1_2
} // namespace neuralnetworks
diff --git a/neuralnetworks/1.0/vts/functional/Callbacks.h b/neuralnetworks/1.0/vts/functional/Callbacks.h
index 46f29a6..4707d0a 100644
--- a/neuralnetworks/1.0/vts/functional/Callbacks.h
+++ b/neuralnetworks/1.0/vts/functional/Callbacks.h
@@ -308,8 +308,20 @@
* of the output operand in the Request outputs vector.
* outputShapes must be empty unless the status is either
* NONE or OUTPUT_INSUFFICIENT_SIZE.
+ * @return Timing Duration of execution. Unless MeasureTiming::YES was passed when
+ * launching the execution and status is NONE, all times must
+ * be reported as UINT64_MAX. A driver may choose to report
+ * any time as UINT64_MAX, indicating that particular measurement is
+ * not available.
*/
- Return<void> notify_1_2(ErrorStatus status, const hidl_vec<OutputShape>& outputShapes) override;
+ Return<void> notify_1_2(ErrorStatus status, const hidl_vec<OutputShape>& outputShapes,
+ const Timing& timing) override;
+
+ // An overload of the latest notify interface to hide the version from ExecutionBuilder.
+ Return<void> notify(ErrorStatus status, const hidl_vec<OutputShape>& outputShapes,
+ const Timing& timing) {
+ return notify_1_2(status, outputShapes, timing);
+ }
/**
* Retrieves the error status returned from the asynchronous task launched
@@ -350,9 +362,24 @@
*/
const std::vector<OutputShape>& getOutputShapes();
+ /**
+ * Retrieves the duration of execution ofthe asynchronous task launched
+ * by IPreparedModel::execute_1_2. If IPreparedModel::execute_1_2 has not finished
+ * asynchronously executing, this call will block until the asynchronous task
+ * notifies the object.
+ *
+ * If the asynchronous task was launched by IPreparedModel::execute, every time
+ * must be UINT64_MAX.
+ *
+ * @return timing Duration of the execution. Every time must be UINT64_MAX unless
+ * the status is NONE.
+ */
+ Timing getTiming();
+
private:
- ErrorStatus mErrorStatus;
- std::vector<OutputShape> mOutputShapes;
+ ErrorStatus mErrorStatus = ErrorStatus::GENERAL_FAILURE;
+ std::vector<OutputShape> mOutputShapes = {};
+ Timing mTiming = {};
};
diff --git a/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp b/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp
index d45922e..65c425e 100644
--- a/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp
+++ b/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp
@@ -77,29 +77,33 @@
// Top level driver for models and examples generated by test_generator.py
// Test driver for those generated from ml/nn/runtime/test/spec
static Return<ErrorStatus> ExecutePreparedModel(sp<V1_0::IPreparedModel>& preparedModel,
- const Request& request,
+ const Request& request, MeasureTiming,
sp<ExecutionCallback>& callback) {
return preparedModel->execute(request, callback);
}
static Return<ErrorStatus> ExecutePreparedModel(sp<V1_2::IPreparedModel>& preparedModel,
- const Request& request,
+ const Request& request, MeasureTiming measure,
sp<ExecutionCallback>& callback) {
- return preparedModel->execute_1_2(request, callback);
+ return preparedModel->execute_1_2(request, measure, callback);
}
static Return<ErrorStatus> ExecutePreparedModel(sp<V1_0::IPreparedModel>&, const Request&,
- hidl_vec<OutputShape>*) {
+ MeasureTiming, hidl_vec<OutputShape>*, Timing*) {
ADD_FAILURE() << "asking for synchronous execution at V1_0";
return ErrorStatus::GENERAL_FAILURE;
}
static Return<ErrorStatus> ExecutePreparedModel(sp<V1_2::IPreparedModel>& preparedModel,
- const Request& request,
- hidl_vec<OutputShape>* outputShapes) {
+ const Request& request, MeasureTiming measure,
+ hidl_vec<OutputShape>* outputShapes,
+ Timing* timing) {
ErrorStatus result;
Return<void> ret = preparedModel->executeSynchronously(
- request, [&result, &outputShapes](ErrorStatus error, const hidl_vec<OutputShape>& shapes) {
- result = error;
- *outputShapes = shapes;
- });
+ request, measure,
+ [&result, outputShapes, timing](ErrorStatus error, const hidl_vec<OutputShape>& shapes,
+ const Timing& time) {
+ result = error;
+ *outputShapes = shapes;
+ *timing = time;
+ });
if (!ret.isOk()) {
return ErrorStatus::GENERAL_FAILURE;
}
@@ -111,9 +115,8 @@
template <typename T_IPreparedModel>
void EvaluatePreparedModel(sp<T_IPreparedModel>& preparedModel, std::function<bool(int)> is_ignored,
const std::vector<MixedTypedExample>& examples,
- bool hasRelaxedFloat32Model = false, float fpAtol = kDefaultAtol,
- float fpRtol = kDefaultRtol, Synchronously sync = Synchronously::NO,
- bool testDynamicOutputShape = false) {
+ bool hasRelaxedFloat32Model, float fpAtol, float fpRtol,
+ Synchronously sync, MeasureTiming measure, bool testDynamicOutputShape) {
const uint32_t INPUT = 0;
const uint32_t OUTPUT = 1;
@@ -208,6 +211,7 @@
ErrorStatus executionStatus;
hidl_vec<OutputShape> outputShapes;
+ Timing timing;
if (sync == Synchronously::NO) {
SCOPED_TRACE("asynchronous");
@@ -215,8 +219,8 @@
sp<ExecutionCallback> executionCallback = new ExecutionCallback();
ASSERT_NE(nullptr, executionCallback.get());
Return<ErrorStatus> executionLaunchStatus = ExecutePreparedModel(
- preparedModel, {.inputs = inputs_info, .outputs = outputs_info, .pools = pools},
- executionCallback);
+ preparedModel, {.inputs = inputs_info, .outputs = outputs_info, .pools = pools},
+ measure, executionCallback);
ASSERT_TRUE(executionLaunchStatus.isOk());
EXPECT_EQ(ErrorStatus::NONE, static_cast<ErrorStatus>(executionLaunchStatus));
@@ -224,13 +228,14 @@
executionCallback->wait();
executionStatus = executionCallback->getStatus();
outputShapes = executionCallback->getOutputShapes();
+ timing = executionCallback->getTiming();
} else {
SCOPED_TRACE("synchronous");
// execute
Return<ErrorStatus> executionReturnStatus = ExecutePreparedModel(
- preparedModel, {.inputs = inputs_info, .outputs = outputs_info, .pools = pools},
- &outputShapes);
+ preparedModel, {.inputs = inputs_info, .outputs = outputs_info, .pools = pools},
+ measure, &outputShapes, &timing);
ASSERT_TRUE(executionReturnStatus.isOk());
executionStatus = static_cast<ErrorStatus>(executionReturnStatus);
}
@@ -244,6 +249,14 @@
return;
}
ASSERT_EQ(ErrorStatus::NONE, executionStatus);
+ if (measure == MeasureTiming::NO) {
+ EXPECT_EQ(UINT64_MAX, timing.timeOnDevice);
+ EXPECT_EQ(UINT64_MAX, timing.timeInDriver);
+ } else {
+ if (timing.timeOnDevice != UINT64_MAX && timing.timeInDriver != UINT64_MAX) {
+ EXPECT_LE(timing.timeOnDevice, timing.timeInDriver);
+ }
+ }
// Go through all outputs, overwrite output dimensions with returned output shapes
if (testDynamicOutputShape) {
@@ -273,10 +286,10 @@
template <typename T_IPreparedModel>
void EvaluatePreparedModel(sp<T_IPreparedModel>& preparedModel, std::function<bool(int)> is_ignored,
const std::vector<MixedTypedExample>& examples,
- bool hasRelaxedFloat32Model, Synchronously sync,
+ bool hasRelaxedFloat32Model, Synchronously sync, MeasureTiming measure,
bool testDynamicOutputShape) {
EvaluatePreparedModel(preparedModel, is_ignored, examples, hasRelaxedFloat32Model, kDefaultAtol,
- kDefaultRtol, sync, testDynamicOutputShape);
+ kDefaultRtol, sync, measure, testDynamicOutputShape);
}
static void getPreparedModel(sp<PreparedModelCallback> callback,
@@ -333,7 +346,7 @@
float fpAtol = 1e-5f, fpRtol = 5.0f * 1.1920928955078125e-7f;
EvaluatePreparedModel(preparedModel, is_ignored, examples,
/*hasRelaxedFloat32Model=*/false, fpAtol, fpRtol, Synchronously::NO,
- /*testDynamicOutputShape=*/false);
+ MeasureTiming::NO, /*testDynamicOutputShape=*/false);
}
void Execute(const sp<V1_1::IDevice>& device, std::function<V1_1::Model(void)> create_model,
@@ -380,7 +393,7 @@
EvaluatePreparedModel(preparedModel, is_ignored, examples,
model.relaxComputationFloat32toFloat16, 1e-5f, 1e-5f, Synchronously::NO,
- /*testDynamicOutputShape=*/false);
+ MeasureTiming::NO, /*testDynamicOutputShape=*/false);
}
// TODO: Reduce code duplication.
@@ -429,10 +442,16 @@
EvaluatePreparedModel(preparedModel, is_ignored, examples,
model.relaxComputationFloat32toFloat16, Synchronously::NO,
- testDynamicOutputShape);
+ MeasureTiming::NO, testDynamicOutputShape);
EvaluatePreparedModel(preparedModel, is_ignored, examples,
model.relaxComputationFloat32toFloat16, Synchronously::YES,
- testDynamicOutputShape);
+ MeasureTiming::NO, testDynamicOutputShape);
+ EvaluatePreparedModel(preparedModel, is_ignored, examples,
+ model.relaxComputationFloat32toFloat16, Synchronously::NO,
+ MeasureTiming::YES, testDynamicOutputShape);
+ EvaluatePreparedModel(preparedModel, is_ignored, examples,
+ model.relaxComputationFloat32toFloat16, Synchronously::YES,
+ MeasureTiming::YES, testDynamicOutputShape);
}
} // namespace generated_tests
diff --git a/neuralnetworks/1.2/Android.bp b/neuralnetworks/1.2/Android.bp
index d8762b0..9057b94 100644
--- a/neuralnetworks/1.2/Android.bp
+++ b/neuralnetworks/1.2/Android.bp
@@ -8,6 +8,8 @@
},
srcs: [
"types.hal",
+ "IBurstCallback.hal",
+ "IBurstContext.hal",
"IDevice.hal",
"IExecutionCallback.hal",
"IPreparedModel.hal",
@@ -20,6 +22,9 @@
"android.hidl.safe_union@1.0",
],
types: [
+ "DeviceType",
+ "FmqRequestDatum",
+ "FmqResultDatum",
"Model",
"Operand",
"OperandType",
@@ -28,6 +33,7 @@
"OperationType",
"OperationTypeRange",
"OutputShape",
+ "SymmPerChannelQuantParams",
],
gen_java: false,
}
diff --git a/neuralnetworks/1.2/IBurstCallback.hal b/neuralnetworks/1.2/IBurstCallback.hal
new file mode 100644
index 0000000..3f82e31
--- /dev/null
+++ b/neuralnetworks/1.2/IBurstCallback.hal
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2019 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.neuralnetworks@1.2;
+
+import @1.0::ErrorStatus;
+
+/**
+ * Callback object used by a service to retreive memory objects based on unique
+ * identifiers ("slots").
+ */
+interface IBurstCallback {
+ /**
+ * Get the memory regions that correspond to slot ids. The slot ids are are
+ * unique to the burst object.
+ *
+ * @param slots Values uniquely identifying memory regions within a Burst.
+ * @return status Indicates whether the memories were successfully returned;
+ * must be:
+ * - NONE if the memory region was successfully retrieved
+ * - GENERAL_FAILURE if there is an unspecified error
+ * - INVALID_ARGUMENT if a slot number is invalid
+ * @return buffers Memory buffers corresponding to the slot numbers. If an
+ * error occurs, an empty vector must be returned for
+ * buffers, otherwise slots.size() == buffers.size().
+ */
+ getMemories(vec<int32_t> slots) generates (ErrorStatus status, vec<memory> buffers);
+};
diff --git a/neuralnetworks/1.2/IBurstContext.hal b/neuralnetworks/1.2/IBurstContext.hal
new file mode 100644
index 0000000..60bf53b
--- /dev/null
+++ b/neuralnetworks/1.2/IBurstContext.hal
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2019 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.neuralnetworks@1.2;
+
+/**
+ * Context object to manage the resources of a burst.
+ */
+interface IBurstContext {
+ /**
+ * freeMemory is used by the client to signal to the service that a memory
+ * buffer corresponding to a slot number is no longer needed by the client.
+ *
+ * The slot ids are unique to the burst object.
+ *
+ * @param slot Value uniquely identifying a memory region.
+ */
+ freeMemory(int32_t slot);
+};
diff --git a/neuralnetworks/1.2/IExecutionCallback.hal b/neuralnetworks/1.2/IExecutionCallback.hal
index 47de1b6..7f6c9ee 100644
--- a/neuralnetworks/1.2/IExecutionCallback.hal
+++ b/neuralnetworks/1.2/IExecutionCallback.hal
@@ -18,7 +18,6 @@
import @1.0::ErrorStatus;
import @1.0::IExecutionCallback;
-import OutputShape;
/**
* IExecutionCallback must be used to return the error status result from an
@@ -50,6 +49,11 @@
* of the output operand in the Request outputs vector.
* outputShapes must be empty unless the status is either
* NONE or OUTPUT_INSUFFICIENT_SIZE.
+ * @return Timing Duration of execution. Unless MeasureTiming::YES was passed when
+ * launching the execution and status is NONE, all times must
+ * be reported as UINT64_MAX. A driver may choose to report
+ * any time as UINT64_MAX, indicating that particular measurement is
+ * not available.
*/
- oneway notify_1_2(ErrorStatus status, vec<OutputShape> outputShapes);
+ oneway notify_1_2(ErrorStatus status, vec<OutputShape> outputShapes, Timing timing);
};
diff --git a/neuralnetworks/1.2/IPreparedModel.hal b/neuralnetworks/1.2/IPreparedModel.hal
index 044ca28..5d2d80f 100644
--- a/neuralnetworks/1.2/IPreparedModel.hal
+++ b/neuralnetworks/1.2/IPreparedModel.hal
@@ -19,6 +19,8 @@
import @1.0::ErrorStatus;
import @1.0::IPreparedModel;
import @1.0::Request;
+import IBurstCallback;
+import IBurstContext;
import IExecutionCallback;
/**
@@ -57,6 +59,10 @@
*
* @param request The input and output information on which the prepared
* model is to be executed.
+ * @param measure Specifies whether or not to measure duration of the execution.
+ * The duration runs from the time the driver sees the call
+ * to the execute_1_2 function to the time the driver invokes
+ * the callback.
* @param callback A callback object used to return the error status of
* the execution. The callback object's notify function must
* be called exactly once, even if the execution was
@@ -70,7 +76,7 @@
* - INVALID_ARGUMENT if one of the input arguments is
* invalid
*/
- execute_1_2(Request request, IExecutionCallback callback)
+ execute_1_2(Request request, MeasureTiming measure, IExecutionCallback callback)
generates (ErrorStatus status);
/**
@@ -96,6 +102,10 @@
*
* @param request The input and output information on which the prepared
* model is to be executed.
+ * @param measure Specifies whether or not to measure duration of the execution.
+ * The duration runs from the time the driver sees the call
+ * to the executeSynchronously function to the time the driver
+ * returns from the function.
* @return status Error status of the execution, must be:
* - NONE if execution is performed successfully
* - DEVICE_UNAVAILABLE if driver is offline or busy
@@ -110,7 +120,41 @@
* of the output operand in the Request outputs vector.
* outputShapes must be empty unless the status is either
* NONE or OUTPUT_INSUFFICIENT_SIZE.
+ * @return Timing Duration of execution. Unless measure is YES and status is
+ * NONE, all times must be reported as UINT64_MAX. A driver may
+ * choose to report any time as UINT64_MAX, indicating that
+ * measurement is not available.
*/
- executeSynchronously(Request request)
- generates (ErrorStatus status, vec<OutputShape> outputShapes);
+ executeSynchronously(Request request, MeasureTiming measure)
+ generates (ErrorStatus status, vec<OutputShape> outputShapes, Timing timing);
+
+ /**
+ * Configure a Burst object used to execute multiple inferences on a
+ * prepared model in rapid succession.
+ *
+ * @param callback A callback object used to retrieve memory resources
+ * corresponding to a unique identifiers ("slots").
+ * @param requestChannel Used by the client to send a serialized Request to
+ * the Burst for execution. requestChannel must not be
+ * used to pass a second Request object until a result
+ * has been received from resultChannel.
+ * @param resultChannel Used by the service to return the results of an
+ * execution to the client: the status of the execution
+ * and OutputShape of all output tensors. resultChannel
+ * must be used to return the results if a Request was
+ * sent through the requestChannel.
+ * @return status Error status of configuring the execution burst, must be:
+ * - NONE if the burst is successfully configured
+ * - DEVICE_UNAVAILABLE if driver is offline or busy
+ * - GENERAL_FAILURE if there is an unspecified error
+ * - INVALID_ARGUMENT if one of the input arguments is
+ * invalid
+ * @return context Object containing all resources (such as cached
+ * hidl_memory) related to a Burst if successful, otherwise
+ * nullptr.
+ */
+ configureExecutionBurst(IBurstCallback callback,
+ fmq_sync<FmqRequestDatum> requestChannel,
+ fmq_sync<FmqResultDatum> resultChannel)
+ generates (ErrorStatus status, IBurstContext context);
};
diff --git a/neuralnetworks/1.2/types.hal b/neuralnetworks/1.2/types.hal
index ac944c8..bd8354f 100644
--- a/neuralnetworks/1.2/types.hal
+++ b/neuralnetworks/1.2/types.hal
@@ -17,6 +17,7 @@
package android.hardware.neuralnetworks@1.2;
import @1.0::DataLocation;
+import @1.0::ErrorStatus;
import @1.0::OperandLifeTime;
import @1.0::OperandType;
import @1.0::PerformanceInfo;
@@ -113,17 +114,17 @@
*/
enum OperationType : @1.1::OperationType {
// TODO(b/116445845): Sync docs when all ops are implemented.
- ARGMAX = 38,
- ARGMIN = 39,
- PAD_V2 = 40,
+ ABS = 38,
+ ARGMAX = 39,
+ ARGMIN = 40,
AXIS_ALIGNED_BBOX_TRANSFORM = 41,
BIDIRECTIONAL_SEQUENCE_LSTM = 42,
BIDIRECTIONAL_SEQUENCE_RNN = 43,
BOX_WITH_NMS_LIMIT = 44,
CAST = 45,
CHANNEL_SHUFFLE = 46,
- DETECTION_OUTPUT = 47,
- EMBEDDING_LOOKUP_SPARSE = 48,
+ DETECTION_POSTPROCESSING = 47,
+ EQUAL = 48,
EXP = 49,
EXPAND_DIMS = 50,
GATHER = 51,
@@ -132,47 +133,43 @@
GREATER_EQUAL = 54,
GROUPED_CONV_2D = 55,
HEATMAP_MAX_KEYPOINT = 56,
- LESS = 57,
- LESS_EQUAL = 58,
- LOG = 59,
- LOGICAL_AND = 60,
- LOGICAL_NOT = 61,
- LOGICAL_OR = 62,
- LOG_SOFTMAX = 63,
- MAXIMUM = 64,
- MINIMUM = 65,
- NEG = 66,
- POW = 67,
- PRELU = 68,
- PRIOR_BOX = 69,
- QUANTIZE = 70,
- QUANTIZED_16BIT_LSTM = 71,
- RANDOM_MULTINOMIAL = 72,
- REDUCE_PROD = 73,
- ROI_ALIGN = 74,
- RSQRT = 75,
- SELECT = 76,
- SIN = 77,
- SLICE = 78,
- SPARSE_TO_DENSE = 79,
- SPLIT = 80,
- SQRT = 81,
- TILE = 82,
- TOPK_V2 = 83,
- TRANSPOSE_CONV_2D = 84,
- UNIDIRECTIONAL_SEQUENCE_LSTM = 85,
- UNIDIRECTIONAL_SEQUENCE_RNN = 86,
- DETECTION_POSTPROCESSING = 87,
- ABS = 88,
- ROI_POOLING = 89,
- EQUAL = 90,
- NOT_EQUAL = 91,
- REDUCE_SUM = 92,
- REDUCE_MAX = 93,
- REDUCE_MIN = 94,
- REDUCE_ANY = 95,
- REDUCE_ALL = 96,
- INSTANCE_NORMALIZATION = 97,
+ INSTANCE_NORMALIZATION = 57,
+ LESS = 58,
+ LESS_EQUAL = 59,
+ LOG = 60,
+ LOGICAL_AND = 61,
+ LOGICAL_NOT = 62,
+ LOGICAL_OR = 63,
+ LOG_SOFTMAX = 64,
+ MAXIMUM = 65,
+ MINIMUM = 66,
+ NEG = 67,
+ NOT_EQUAL = 68,
+ PAD_V2 = 69,
+ POW = 70,
+ PRELU = 71,
+ QUANTIZE = 72,
+ QUANTIZED_16BIT_LSTM = 73,
+ RANDOM_MULTINOMIAL = 74,
+ REDUCE_ALL = 75,
+ REDUCE_ANY = 76,
+ REDUCE_MAX = 77,
+ REDUCE_MIN = 78,
+ REDUCE_PROD = 79,
+ REDUCE_SUM = 80,
+ ROI_ALIGN = 81,
+ ROI_POOLING = 82,
+ RSQRT = 83,
+ SELECT = 84,
+ SIN = 85,
+ SLICE = 86,
+ SPLIT = 87,
+ SQRT = 88,
+ TILE = 89,
+ TOPK_V2 = 90,
+ TRANSPOSE_CONV_2D = 91,
+ UNIDIRECTIONAL_SEQUENCE_LSTM = 92,
+ UNIDIRECTIONAL_SEQUENCE_RNN = 93,
/* ADDING A NEW FUNDAMENTAL OPERATION REQUIRES UPDATING THE VALUE OF
* OperationTypeRange::OPERATION_FUNDAMENTAL_MAX.
*/
@@ -186,7 +183,7 @@
*/
enum OperationTypeRange : uint32_t {
OPERATION_FUNDAMENTAL_MIN = 0,
- OPERATION_FUNDAMENTAL_MAX = 97,
+ OPERATION_FUNDAMENTAL_MAX = 93,
OPERATION_OEM_MIN = 10000,
OPERATION_OEM_MAX = 10000,
};
@@ -444,3 +441,240 @@
*/
bool isSufficient;
};
+
+/**
+ * Specifies whether or not to measure timing information during execution.
+ */
+enum MeasureTiming : int32_t {
+ NO = 0,
+ YES = 1,
+};
+
+/**
+
+ * Timing information measured during execution. Each time is a duration from
+ * the beginning of some task to the end of that task, including time when that
+ * task is not active (for example, preempted by some other task, or
+ * waiting for some resource to become available).
+ *
+ * Times are measured in microseconds.
+ * When a time is not available, it must be reported as UINT64_MAX.
+ */
+struct Timing {
+ /** Execution time on device (not driver, which runs on host processor). */
+ uint64_t timeOnDevice;
+ /** Execution time in driver (including time on device). */
+ uint64_t timeInDriver;
+};
+
+/**
+ * FmqRequestDatum is a single element of a serialized representation of an
+ * execution request (a {@link @1.0::Request} object and a {@link MeasureTiming}
+ * value) which is sent across FastMessageQueue.
+ *
+ * The serialized representation for a particular execution is referred to later
+ * in these descriptions as a 'packet'.
+ *
+ * FastMessageQueue can only pass HIDL-defined types that do not involve nested
+ * buffers, handles, or interfaces.
+ *
+ * The request is serialized as follows:
+ * 1) 'packetInformation'
+ * 2) For each input operand:
+ * 2.1) 'inputOperandInformation'
+ * 2.2) For each dimension element of the operand:
+ * 2.2.1) 'inputOperandDimensionValue'
+ * 3) For each output operand:
+ * 3.1) 'outputOperandInformation'
+ * 3.2) For each dimension element of the operand:
+ * 3.2.1) 'outputOperandDimensionValue'
+ * 4) For each pool:
+ * 4.1) 'poolIdentifier'
+ * 5) 'measureTiming'
+ */
+safe_union FmqRequestDatum {
+ /**
+ * Type to describe the high-level layout of the packet.
+ */
+ struct PacketInformation {
+ /**
+ * How many elements the packet contains, including the
+ * "packetInformation" datum.
+ */
+ uint32_t packetSize;
+
+ /**
+ * Number of input operands.
+ */
+ uint32_t numberOfInputOperands;
+
+ /**
+ * Number of output operands.
+ */
+ uint32_t numberOfOutputOperands;
+
+ /**
+ * Number of pool identifiers.
+ */
+ uint32_t numberOfPools;
+ };
+
+ /**
+ * Type representing the information for each operand.
+ */
+ struct OperandInformation {
+ /**
+ * If true, the argument does not have a value. This can be used for
+ * operations that take optional arguments. If true, the fields of
+ * 'location' are set to 0, 'numberOfDimensions' is set to 0, and the
+ * dimensions information is omitted from the serialization.
+ */
+ bool hasNoValue;
+
+ /**
+ * The location within one of the memory pools passed in the Request.
+ */
+ DataLocation location;
+
+ /**
+ * Number of subsequent elements that belong to the dimensions vector.
+ */
+ uint32_t numberOfDimensions;
+ };
+
+ /**
+ * packetInformation is the first element of the packet and describes the
+ * remainder of the packet.
+ */
+ PacketInformation packetInformation;
+
+ /**
+ * Information for each input operand.
+ */
+ OperandInformation inputOperandInformation;
+
+ /**
+ * Element of the dimensions vector.
+ */
+ uint32_t inputOperandDimensionValue;
+
+ /**
+ * Information for each output operand.
+ */
+ OperandInformation outputOperandInformation;
+
+ /**
+ * Element of the dimensions vector.
+ */
+ uint32_t outputOperandDimensionValue;
+
+ /**
+ * Unique identifier for a pool.
+ *
+ * A {@link @1.0::Request} passes across one or more pools of shared memory
+ * for the inputs and outputs of an execution. However, these memory pools
+ * are not able to be sent across FastMessageQueue directly. Instead, the
+ * producing side of the FMQ represents each different pool with a unique
+ * identifier, and sends this identifier across the FMQ. Whenever the
+ * consuming side of the FMQ needs the memory corresponding to this unique
+ * identifier, it can pass the identifier to
+ * {@link IBurstCallback::getMemories} to retreive the memory. Although this
+ * HIDL Binder call is expensive compared to communication across FMQ, it is
+ * only needed in the cases when the consumer does not recognize the unique
+ * identifier.
+ */
+ int32_t poolIdentifier;
+
+ /**
+ * Specifies whether or not to measure duration of the execution. The
+ * duration runs from the time the driver dequeues the request from a
+ * FastMessageQueue to the time the driver enqueues results to a
+ * FastMessageQueue.
+ */
+ MeasureTiming measureTiming;
+};
+
+/**
+ * FmqResultDatum is a single element of a serialized representation of the
+ * values returned from an execution ({@link @1.0::ErrorStatus},
+ * vec<{@link OutputShape}>, and {@link Timing}) which is returned via
+ * FastMessageQueue.
+ *
+ * The serialized representation for a particular execution is referred to later
+ * in these descriptions as a 'packet'.
+ *
+ * FastMessageQueue can only pass HIDL-defined types that do not involve nested
+ * buffers, handles, or interfaces.
+ *
+ * The execution return values ({@link @1.0::ErrorStatus} and
+ * vec<{@link OutputShape}>) are serialized as follows:
+ * 1) 'packetInformation'
+ * 2) For each returned operand:
+ * 2.1) 'operandInformation'
+ * 2.2) For each dimension element of the operand:
+ * 2.2.1) 'operandDimensionValue'
+ * 3) 'executionTiming'
+ */
+safe_union FmqResultDatum {
+ /**
+ * Type to describe the high-level layout of the packet.
+ */
+ struct PacketInformation {
+ /**
+ * How many elements the packet contains, including the
+ * "packetInformation" datum.
+ */
+ uint32_t packetSize;
+
+ /**
+ * Status of the execution.
+ */
+ ErrorStatus errorStatus;
+
+ /**
+ * Number of returned operands.
+ */
+ uint32_t numberOfOperands;
+ };
+
+ /**
+ * Type representing the information for each operand.
+ */
+ struct OperandInformation {
+ /**
+ * Indicates whether the operand's output buffer is large enough to
+ * store the operand's result data.
+ */
+ bool isSufficient;
+
+ /**
+ * Number of subsequent elements that belong to the dimensions vector.
+ */
+ uint32_t numberOfDimensions;
+ };
+
+ /**
+ * packetInformation is the first element of the packet and describes the
+ * remainder of the packet. It additionally includes the status of the
+ * execution.
+ */
+ PacketInformation packetInformation;
+
+ /**
+ * Information for each returned operand.
+ */
+ OperandInformation operandInformation;
+
+ /**
+ * Element of the dimensions vector.
+ */
+ uint32_t operandDimensionValue;
+
+ /**
+ * Duration of execution. Unless measurement was requested and execution
+ * succeeds, all times must be reported as UINT64_MAX. A driver may choose
+ * to report any time as UINT64_MAX, indicating that measurement is not
+ * available.
+ */
+ Timing executionTiming;
+};
diff --git a/neuralnetworks/1.2/vts/functional/ValidateRequest.cpp b/neuralnetworks/1.2/vts/functional/ValidateRequest.cpp
index 1eaea4b..00a7c3e 100644
--- a/neuralnetworks/1.2/vts/functional/ValidateRequest.cpp
+++ b/neuralnetworks/1.2/vts/functional/ValidateRequest.cpp
@@ -42,6 +42,10 @@
///////////////////////// UTILITY FUNCTIONS /////////////////////////
+static bool badTiming(Timing timing) {
+ return timing.timeOnDevice == UINT64_MAX && timing.timeInDriver == UINT64_MAX;
+}
+
static void createPreparedModel(const sp<IDevice>& device, const Model& model,
sp<IPreparedModel>* preparedModel) {
ASSERT_NE(nullptr, preparedModel);
@@ -98,31 +102,46 @@
Request request, const std::function<void(Request*)>& mutation) {
mutation(&request);
+ // We'd like to test both with timing requested and without timing
+ // requested. Rather than running each test both ways, we'll decide whether
+ // to request timing by hashing the message. We do not use std::hash because
+ // it is not guaranteed stable across executions.
+ char hash = 0;
+ for (auto c : message) {
+ hash ^= c;
+ };
+ MeasureTiming measure = (hash & 1) ? MeasureTiming::YES : MeasureTiming::NO;
+
{
SCOPED_TRACE(message + " [execute_1_2]");
sp<ExecutionCallback> executionCallback = new ExecutionCallback();
ASSERT_NE(nullptr, executionCallback.get());
Return<ErrorStatus> executeLaunchStatus =
- preparedModel->execute_1_2(request, executionCallback);
+ preparedModel->execute_1_2(request, measure, executionCallback);
ASSERT_TRUE(executeLaunchStatus.isOk());
ASSERT_EQ(ErrorStatus::INVALID_ARGUMENT, static_cast<ErrorStatus>(executeLaunchStatus));
executionCallback->wait();
ErrorStatus executionReturnStatus = executionCallback->getStatus();
const auto& outputShapes = executionCallback->getOutputShapes();
+ Timing timing = executionCallback->getTiming();
ASSERT_EQ(ErrorStatus::INVALID_ARGUMENT, executionReturnStatus);
ASSERT_EQ(outputShapes.size(), 0);
+ ASSERT_TRUE(badTiming(timing));
}
{
SCOPED_TRACE(message + " [executeSynchronously]");
Return<void> executeStatus = preparedModel->executeSynchronously(
- request, [](ErrorStatus error, const hidl_vec<OutputShape>& outputShapes) {
- ASSERT_EQ(ErrorStatus::INVALID_ARGUMENT, error);
- EXPECT_EQ(outputShapes.size(), 0);
- });
+ request, measure,
+ [](ErrorStatus error, const hidl_vec<OutputShape>& outputShapes,
+ const Timing& timing) {
+ ASSERT_EQ(ErrorStatus::INVALID_ARGUMENT, error);
+ EXPECT_EQ(outputShapes.size(), 0);
+ EXPECT_TRUE(badTiming(timing));
+ });
ASSERT_TRUE(executeStatus.isOk());
}
}
diff --git a/radio/1.4/IRadio.hal b/radio/1.4/IRadio.hal
index dd69607..21c5097 100644
--- a/radio/1.4/IRadio.hal
+++ b/radio/1.4/IRadio.hal
@@ -128,6 +128,10 @@
* does not support the emergency service category or emergency uniform resource names, the
* field 'categories' or 'urns' may be ignored.
*
+ * 'fromEmergencyDialer' indicates if this request originated from emergency dialer/shortcut,
+ * which means an explicit intent from the user to dial an emergency number. The modem must
+ * treat this as an actual emergency dial and not try to disambiguate.
+ *
* If 'isTesting' is true, this request is for testing purpose, and must not be sent to a real
* emergency service; otherwise it's for a real emergency call request.
*
@@ -142,12 +146,14 @@
* of the call.
* @param urns the emergency Uniform Resource Names (URN)
* @param routing @1.4::EmergencyCallRouting the emergency call routing information.
+ * @param fromEmergencyDialer Flag indicating if this request originated from emergency dialer.
+ * @param isTesting Flag indicating if this request is for testing purpose.
*
* Response function is IRadioResponse.emergencyDialResponse()
*/
oneway emergencyDial(int32_t serial, Dial dialInfo,
bitfield<EmergencyServiceCategory> categories, vec<string> urns,
- EmergencyCallRouting routing, bool isTesting);
+ EmergencyCallRouting routing, bool fromEmergencyDialer, bool isTesting);
/**
* Starts a network scan
diff --git a/sensors/2.0/default/Android.bp b/sensors/2.0/default/Android.bp
index db0b148..d83a9c3 100644
--- a/sensors/2.0/default/Android.bp
+++ b/sensors/2.0/default/Android.bp
@@ -35,4 +35,5 @@
"libpower",
"libutils",
],
+ vintf_fragments: ["android.hardware.sensors@2.0.xml"],
}
diff --git a/sensors/2.0/default/android.hardware.sensors@2.0.xml b/sensors/2.0/default/android.hardware.sensors@2.0.xml
new file mode 100644
index 0000000..1acc8e6
--- /dev/null
+++ b/sensors/2.0/default/android.hardware.sensors@2.0.xml
@@ -0,0 +1,11 @@
+<manifest version="1.0" type="device">
+ <hal format="hidl">
+ <name>android.hardware.sensors</name>
+ <transport>hwbinder</transport>
+ <version>2.0</version>
+ <interface>
+ <name>ISensors</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+</manifest>
diff --git a/tv/cec/2.0/Android.bp b/tv/cec/2.0/Android.bp
new file mode 100644
index 0000000..998cb23
--- /dev/null
+++ b/tv/cec/2.0/Android.bp
@@ -0,0 +1,46 @@
+// This file is autogenerated by hidl-gen -Landroidbp.
+
+hidl_interface {
+ name: "android.hardware.tv.cec@2.0",
+ root: "android.hardware",
+ vndk: {
+ enabled: true,
+ },
+ srcs: [
+ "types.hal",
+ "IHdmiCec.hal",
+ "IHdmiCecCallback.hal",
+ ],
+ interfaces: [
+ "android.hidl.base@1.0",
+ "android.hidl.safe_union@1.0",
+ ],
+ types: [
+ "AbortReason",
+ "CecAllDeviceTypeValue",
+ "CecDeviceFeature",
+ "CecDeviceInfo",
+ "CecDeviceType",
+ "CecLogicalAddress",
+ "CecMessage",
+ "CecMessageType",
+ "CecPowerState",
+ "CecRcProfile",
+ "CecRcProfile1",
+ "CecRcProfileId",
+ "CecRcProfileSource",
+ "CecTopologyEvent",
+ "CecTopologyEventType",
+ "CecUICommandCodes",
+ "CecVersion",
+ "HdmiPortInfo",
+ "HdmiPortType",
+ "HotplugEvent",
+ "MaxLength",
+ "OptionKey",
+ "Result",
+ "SendMessageResult",
+ ],
+ gen_java: true,
+}
+
diff --git a/tv/cec/2.0/IHdmiCec.hal b/tv/cec/2.0/IHdmiCec.hal
new file mode 100644
index 0000000..0723bad
--- /dev/null
+++ b/tv/cec/2.0/IHdmiCec.hal
@@ -0,0 +1,209 @@
+/*
+ * Copyright (C) 2019 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.cec@2.0;
+
+import IHdmiCecCallback;
+
+/**
+ * HDMI-CEC HAL interface definition.
+ */
+interface IHdmiCec {
+ /**
+ * Passes Primary Device Type that must be used in this system.
+ *
+ * HAL must use it to allocate logical address as specified in CEC section
+ * 11.3.2 of the CEC spec 2.0b. Then CEC commands addressed the given
+ * logical address can be filtered in.
+ * This method shall be able to be called up to twice to support two Primary
+ * Device Type as specified in CEC Table 11-8 of the CEC spec 2.0b.
+ *
+ * @param deviceType that must be used in this system. It must be a valid
+ * value in CecDeviceType for the call to succeed.
+ * @return result Result status of the operation. SUCCESS if successful,
+ * FAILURE_INVALID_ARGS if the given device type is invalid,
+ * FAILURE_BUSY if device or resource is busy
+ */
+ @callflow(next={"*"})
+ addDeviceType(CecDeviceType deviceType) generates (Result result);
+
+ /**
+ * Clears all Primary Device Types.
+ *
+ * It is used when the system plan to reconfigure Primary Device Type,
+ * hence to tell HAL to release all logical address associated to them,
+ * and change the state back to the beginning.
+ */
+ @callflow(next="addDeviceType")
+ @exit
+ clearDeviceTypes();
+
+ /**
+ * Set All Device Types for a Primary Device Type.
+ *
+ * This value must be used in REPORT_FEATURES message to response
+ * GIVE_FEATURES message in HAL.
+ *
+ * @param allDeviceTypes device all device types for a Primary Device Type.
+ */
+ @callflow(next="addDeviceType")
+ setAllDeviceTypes(CecAllDeviceTypes allDeviceTypes);
+
+ /**
+ * Set Device Features for a Primary Device Type.
+ *
+ * This value must be used in REPORT_FEATURES message to response
+ * GIVE_FEATURES message in HAL.
+ *
+ * @param deviceType The device Primary Device Type.
+ * @param deviceFeatures device features for a Primary Device Type.
+ */
+ @callflow(next="addDeviceType")
+ setDeviceFeatures(CecDeviceType deviceType,
+ CecDeviceFeatures deviceFeatures);
+
+ /**
+ * Set Remote Control Profile for a Primary Device Type.
+ *
+ * This value must be used in REPORT_FEATURES message to response
+ * GIVE_FEATURES message in HAL.
+ *
+ * @param deviceType The device Primary Device Type.
+ * @param rcProliles remote control profiles for a Primary Device Type.
+ */
+ @callflow(next="addDeviceType")
+ setRcProfile(CecDeviceType deviceType, CecRcProfile rcProfile);
+
+ /**
+ * Retrieve CEC device information.
+ *
+ * CEC section 11.3 of the CEC spec 2.0b specify that a device should not
+ * ask for static information that another device has already supplied.
+ * Therefore, CEC 2.0 software stack need a map to store all cec
+ * devices’ information of current CEC network.
+ * The device information is broadcasted by a device after it allocates a
+ * logical address. Messages used to send out these information are
+ * REPORT_FEATURES, REPORT_PHYSICAL_ADDRESS, DEVICE_VENDOR_ID.
+ * The spec also requires less than 1 second between REPORT_FEATURES and
+ * REPORT_PHYSICAL_ADDRESS message, and less than 2 second between
+ * REPORT_PHYSICAL_ADDRESS and DEVICE_VENDOR_ID. An Implementation of
+ * device information map in hal can help to meet the timing constraints.
+ * Logical addressing is part of the process to build this map, so the
+ * implementation shall include allocating logical address too.
+ * Whenever a device plug/unplug, the topology of CEC network changes.
+ * The hal implementation shall update devices’ information map, and
+ * send out onTopologyEvent to Android system. Then Android system
+ * will use readDeviceInfo to retreive latest devices’ information of CEC
+ * network.
+ * If SYSTEM_CEC_CONTROL is false, the hal implementation need continue to
+ * maintain and update device information map, and send out pending
+ * onTopologyEvent to Android system when SYSTEM_CEC_CONTROL is
+ * changed to true.
+ *
+ * @param logicalAddress logical address of CEC device.
+ * @param physicalAddress physical address of CEC device.
+ * @return CecDeviceInfo from device information map.
+ * @return result Result status of the operation. SUCCESS if successful,
+ * FAILURE_INVALID_ARGS if logical or physical address is invalid.
+ * FAILURE_INVALID_STATE if device information isn't available yet.
+ */
+ @callflow(next="onTopologyChangeEvent")
+ readDeviceInfo(CecLogicalAddress logicalAddress,
+ CecPhysicalAddress physicalAddress)
+ generates (Result result, CecDeviceInfo deviceInfo);
+
+ /**
+ * Transmits HDMI-CEC message to other HDMI device.
+ *
+ * The method must be designed to return in a certain amount of time and not
+ * hanging forever. This method MUST complete with in 1 second.
+ *
+ * It must try retransmission at least once as specified in the section '7.1
+ * Frame Re-transmissions' of the CEC Spec 1.4b.
+ *
+ * @param message CEC message to be sent to other HDMI device.
+ * @return result Result status of the operation. SUCCESS if successful,
+ * NACK if the sent message is not acknowledged,
+ * BUSY if the CEC bus is busy.
+ */
+ @callflow(next="*")
+ sendMessage(CecMessage message) generates (SendMessageResult result);
+
+ /**
+ * Set the callback
+ *
+ * It is used by the framework to receive CecMessages, HDMI hotplug event
+ * and topology update event. Only one callback client is supported.
+ *
+ * @param callback Callback object to pass hdmi events to the system. The
+ * previously registered callback must be replaced with this one.
+ */
+ @callflow(next={"*"})
+ @entry
+ setCallback(IHdmiCecCallback callback);
+
+ /**
+ * Gets the hdmi port information of underlying hardware.
+ *
+ * @return infos The list of HDMI port information
+ */
+ @callflow(next={"*"})
+ getPortInfo() generates (vec<HdmiPortInfo> infos);
+
+ /**
+ * Sets flags controlling the way HDMI-CEC service works down to HAL
+ * implementation. Those flags must be used in case the feature needs update
+ * in HAL itself, firmware or microcontroller.
+ *
+ * @param key The key of the option to be updated with a new value.
+ * @param value Value to be set.
+ */
+ @callflow(next="*")
+ setOption(OptionKey key, bool value);
+
+ /**
+ * Passes the updated language information of Android system. Contains
+ * three-letter code as defined in ISO/FDIS 639-2. Must be used for HAL to
+ * respond to <Get Menu Language> while in standby mode.
+ *
+ * @param language Three-letter code defined in ISO/FDIS 639-2. Must be
+ * lowercase letters. (e.g., eng for English)
+ */
+ @callflow(next="*")
+ setLanguage(string language);
+
+ /**
+ * Configures ARC circuit in the hardware logic to start or stop the
+ * feature.
+ *
+ * @param portId Port id to be configured.
+ * @param enable Flag must be either true to start the feature or false to
+ * stop it.
+ */
+ @callflow(next="*")
+ enableAudioReturnChannel(HdmiPortId portId, bool enable);
+
+ /**
+ * Gets the connection status of the specified port.
+ *
+ * It's specified in CEC section 10.8 of the CEC spec 2.0b
+ *
+ * @param portId Port id to be inspected for the connection status.
+ * @return status True if a device is connected, otherwise false.
+ */
+ @callflow(next="*")
+ isConnected(HdmiPortId portId) generates (bool connected);
+};
diff --git a/tv/cec/2.0/IHdmiCecCallback.hal b/tv/cec/2.0/IHdmiCecCallback.hal
new file mode 100644
index 0000000..1a8a489
--- /dev/null
+++ b/tv/cec/2.0/IHdmiCecCallback.hal
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2019 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.cec@2.0;
+
+interface IHdmiCecCallback {
+ /**
+ * The callback function that must be called by HAL implementation to notify
+ * the system of new CEC message arrival.
+ */
+ oneway onCecMessage(CecMessage message);
+
+ /**
+ * The callback function that must be called by HAL implementation to notify
+ * the system of new hotplug event.
+ */
+ oneway onHotplugEvent(HotplugEvent event);
+
+ /**
+ * The callback function must be called by HAL implementation to notify the
+ * system whenever CEC device information of CEC network change.
+ * HAL shall be ready for readDeviceInfo call before invoke this callback.
+ * This event is triggered by topology change of whole CEC network. It's
+ * different from HotplugEvent which is triggered between devices which are
+ * connected directly through HDMI cable.
+ */
+ oneway onTopologyEvent(CecTopologyEvent event);
+};
diff --git a/tv/cec/2.0/default/Android.bp b/tv/cec/2.0/default/Android.bp
new file mode 100644
index 0000000..6e624e3
--- /dev/null
+++ b/tv/cec/2.0/default/Android.bp
@@ -0,0 +1,42 @@
+cc_library_shared {
+ name: "android.hardware.tv.cec@2.0-impl",
+ defaults: ["hidl_defaults"],
+ vendor: true,
+ relative_install_path: "hw",
+ srcs: ["HdmiCec.cpp"],
+
+ shared_libs: [
+ "libhidlbase",
+ "libhidltransport",
+ "liblog",
+ "libbase",
+ "libutils",
+ "libhardware",
+ "android.hardware.tv.cec@2.0",
+ ],
+
+}
+
+cc_binary {
+ name: "android.hardware.tv.cec@2.0-service",
+ vintf_fragments: ["android.hardware.tv.cec@2.0-service.xml"],
+ defaults: ["hidl_defaults"],
+ relative_install_path: "hw",
+ vendor: true,
+ init_rc: ["android.hardware.tv.cec@2.0-service.rc"],
+ srcs: ["service.cpp"],
+
+ shared_libs: [
+ "liblog",
+ "libcutils",
+ "libdl",
+ "libbase",
+ "libutils",
+ "libhardware_legacy",
+ "libhardware",
+ "libhidlbase",
+ "libhidltransport",
+ "android.hardware.tv.cec@2.0",
+ ],
+
+}
diff --git a/tv/cec/2.0/default/HdmiCec.cpp b/tv/cec/2.0/default/HdmiCec.cpp
new file mode 100644
index 0000000..f451719
--- /dev/null
+++ b/tv/cec/2.0/default/HdmiCec.cpp
@@ -0,0 +1,421 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#define LOG_TAG "android.hardware.tv.cec@2.0-impl"
+#include <android-base/logging.h>
+
+#include <hardware/hardware.h>
+#include <hardware/hdmi_cec.h>
+#include "HdmiCec.h"
+
+namespace android {
+namespace hardware {
+namespace tv {
+namespace cec {
+namespace V2_0 {
+namespace implementation {
+
+static_assert(CEC_DEVICE_INACTIVE == static_cast<int>(CecDeviceType::INACTIVE),
+ "CecDeviceType::INACTIVE must match legacy value.");
+static_assert(CEC_DEVICE_TV == static_cast<int>(CecDeviceType::TV),
+ "CecDeviceType::TV must match legacy value.");
+static_assert(CEC_DEVICE_RECORDER == static_cast<int>(CecDeviceType::RECORDER),
+ "CecDeviceType::RECORDER must match legacy value.");
+static_assert(CEC_DEVICE_TUNER == static_cast<int>(CecDeviceType::TUNER),
+ "CecDeviceType::TUNER must match legacy value.");
+static_assert(CEC_DEVICE_PLAYBACK == static_cast<int>(CecDeviceType::PLAYBACK),
+ "CecDeviceType::PLAYBACK must match legacy value.");
+static_assert(CEC_DEVICE_AUDIO_SYSTEM == static_cast<int>(CecDeviceType::AUDIO_SYSTEM),
+ "CecDeviceType::AUDIO_SYSTEM must match legacy value.");
+/* TODO: Adjust for cec@2.0
+static_assert(CEC_DEVICE_MAX == static_cast<int>(CecDeviceType::MAX),
+ "CecDeviceType::MAX must match legacy value.");
+*/
+static_assert(CEC_ADDR_TV == static_cast<int>(CecLogicalAddress::TV),
+ "CecLogicalAddress::TV must match legacy value.");
+static_assert(CEC_ADDR_RECORDER_1 == static_cast<int>(CecLogicalAddress::RECORDER_1),
+ "CecLogicalAddress::RECORDER_1 must match legacy value.");
+static_assert(CEC_ADDR_RECORDER_2 == static_cast<int>(CecLogicalAddress::RECORDER_2),
+ "CecLogicalAddress::RECORDER_2 must match legacy value.");
+static_assert(CEC_ADDR_TUNER_1 == static_cast<int>(CecLogicalAddress::TUNER_1),
+ "CecLogicalAddress::TUNER_1 must match legacy value.");
+static_assert(CEC_ADDR_PLAYBACK_1 == static_cast<int>(CecLogicalAddress::PLAYBACK_1),
+ "CecLogicalAddress::PLAYBACK_1 must match legacy value.");
+static_assert(CEC_ADDR_AUDIO_SYSTEM == static_cast<int>(CecLogicalAddress::AUDIO_SYSTEM),
+ "CecLogicalAddress::AUDIO_SYSTEM must match legacy value.");
+static_assert(CEC_ADDR_TUNER_2 == static_cast<int>(CecLogicalAddress::TUNER_2),
+ "CecLogicalAddress::TUNER_2 must match legacy value.");
+static_assert(CEC_ADDR_TUNER_3 == static_cast<int>(CecLogicalAddress::TUNER_3),
+ "CecLogicalAddress::TUNER_3 must match legacy value.");
+static_assert(CEC_ADDR_PLAYBACK_2 == static_cast<int>(CecLogicalAddress::PLAYBACK_2),
+ "CecLogicalAddress::PLAYBACK_2 must match legacy value.");
+static_assert(CEC_ADDR_RECORDER_3 == static_cast<int>(CecLogicalAddress::RECORDER_3),
+ "CecLogicalAddress::RECORDER_3 must match legacy value.");
+static_assert(CEC_ADDR_TUNER_4 == static_cast<int>(CecLogicalAddress::TUNER_4),
+ "CecLogicalAddress::TUNER_4 must match legacy value.");
+static_assert(CEC_ADDR_PLAYBACK_3 == static_cast<int>(CecLogicalAddress::PLAYBACK_3),
+ "CecLogicalAddress::PLAYBACK_3 must match legacy value.");
+/* TODO: Adjust for cec@2.0
+static_assert(CEC_ADDR_FREE_USE == static_cast<int>(CecLogicalAddress::FREE_USE),
+ "CecLogicalAddress::FREE_USE must match legacy value.");
+*/
+static_assert(CEC_ADDR_UNREGISTERED == static_cast<int>(CecLogicalAddress::UNREGISTERED),
+ "CecLogicalAddress::UNREGISTERED must match legacy value.");
+static_assert(CEC_ADDR_BROADCAST == static_cast<int>(CecLogicalAddress::BROADCAST),
+ "CecLogicalAddress::BROADCAST must match legacy value.");
+
+static_assert(CEC_MESSAGE_FEATURE_ABORT == static_cast<int>(CecMessageType::FEATURE_ABORT),
+ "CecMessageType::FEATURE_ABORT must match legacy value.");
+static_assert(CEC_MESSAGE_IMAGE_VIEW_ON == static_cast<int>(CecMessageType::IMAGE_VIEW_ON),
+ "CecMessageType::IMAGE_VIEW_ON must match legacy value.");
+static_assert(CEC_MESSAGE_TUNER_STEP_INCREMENT ==
+ static_cast<int>(CecMessageType::TUNER_STEP_INCREMENT),
+ "CecMessageType::TUNER_STEP_INCREMENT must match legacy value.");
+static_assert(CEC_MESSAGE_TUNER_STEP_DECREMENT ==
+ static_cast<int>(CecMessageType::TUNER_STEP_DECREMENT),
+ "CecMessageType::TUNER_STEP_DECREMENT must match legacy value.");
+static_assert(CEC_MESSAGE_TUNER_DEVICE_STATUS ==
+ static_cast<int>(CecMessageType::TUNER_DEVICE_STATUS),
+ "CecMessageType::TUNER_DEVICE_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_GIVE_TUNER_DEVICE_STATUS ==
+ static_cast<int>(CecMessageType::GIVE_TUNER_DEVICE_STATUS),
+ "CecMessageType::GIVE_TUNER_DEVICE_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_RECORD_ON == static_cast<int>(CecMessageType::RECORD_ON),
+ "CecMessageType::RECORD_ON must match legacy value.");
+static_assert(CEC_MESSAGE_RECORD_STATUS == static_cast<int>(CecMessageType::RECORD_STATUS),
+ "CecMessageType::RECORD_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_RECORD_OFF == static_cast<int>(CecMessageType::RECORD_OFF),
+ "CecMessageType::RECORD_OFF must match legacy value.");
+static_assert(CEC_MESSAGE_TEXT_VIEW_ON == static_cast<int>(CecMessageType::TEXT_VIEW_ON),
+ "CecMessageType::TEXT_VIEW_ON must match legacy value.");
+static_assert(CEC_MESSAGE_RECORD_TV_SCREEN == static_cast<int>(CecMessageType::RECORD_TV_SCREEN),
+ "CecMessageType::RECORD_TV_SCREEN must match legacy value.");
+static_assert(CEC_MESSAGE_GIVE_DECK_STATUS == static_cast<int>(CecMessageType::GIVE_DECK_STATUS),
+ "CecMessageType::GIVE_DECK_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_STANDBY == static_cast<int>(CecMessageType::STANDBY),
+ "CecMessageType::STANDBY must match legacy value.");
+static_assert(CEC_MESSAGE_PLAY == static_cast<int>(CecMessageType::PLAY),
+ "CecMessageType::PLAY must match legacy value.");
+static_assert(CEC_MESSAGE_DECK_CONTROL == static_cast<int>(CecMessageType::DECK_CONTROL),
+ "CecMessageType::DECK_CONTROL must match legacy value.");
+static_assert(CEC_MESSAGE_TIMER_CLEARED_STATUS ==
+ static_cast<int>(CecMessageType::TIMER_CLEARED_STATUS),
+ "CecMessageType::TIMER_CLEARED_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_USER_CONTROL_PRESSED ==
+ static_cast<int>(CecMessageType::USER_CONTROL_PRESSED),
+ "CecMessageType::USER_CONTROL_PRESSED must match legacy value.");
+static_assert(CEC_MESSAGE_USER_CONTROL_RELEASED ==
+ static_cast<int>(CecMessageType::USER_CONTROL_RELEASED),
+ "CecMessageType::USER_CONTROL_RELEASED must match legacy value.");
+static_assert(CEC_MESSAGE_GIVE_OSD_NAME == static_cast<int>(CecMessageType::GIVE_OSD_NAME),
+ "CecMessageType::GIVE_OSD_NAME must match legacy value.");
+static_assert(CEC_MESSAGE_SET_OSD_NAME == static_cast<int>(CecMessageType::SET_OSD_NAME),
+ "CecMessageType::SET_OSD_NAME must match legacy value.");
+static_assert(CEC_MESSAGE_SYSTEM_AUDIO_MODE_REQUEST ==
+ static_cast<int>(CecMessageType::SYSTEM_AUDIO_MODE_REQUEST),
+ "CecMessageType::SYSTEM_AUDIO_MODE_REQUEST must match legacy value.");
+static_assert(CEC_MESSAGE_GIVE_AUDIO_STATUS == static_cast<int>(CecMessageType::GIVE_AUDIO_STATUS),
+ "CecMessageType::GIVE_AUDIO_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_SET_SYSTEM_AUDIO_MODE ==
+ static_cast<int>(CecMessageType::SET_SYSTEM_AUDIO_MODE),
+ "CecMessageType::SET_SYSTEM_AUDIO_MODE must match legacy value.");
+static_assert(CEC_MESSAGE_REPORT_AUDIO_STATUS ==
+ static_cast<int>(CecMessageType::REPORT_AUDIO_STATUS),
+ "CecMessageType::REPORT_AUDIO_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_GIVE_SYSTEM_AUDIO_MODE_STATUS ==
+ static_cast<int>(CecMessageType::GIVE_SYSTEM_AUDIO_MODE_STATUS),
+ "CecMessageType::GIVE_SYSTEM_AUDIO_MODE_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_SYSTEM_AUDIO_MODE_STATUS ==
+ static_cast<int>(CecMessageType::SYSTEM_AUDIO_MODE_STATUS),
+ "CecMessageType::SYSTEM_AUDIO_MODE_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_ROUTING_CHANGE == static_cast<int>(CecMessageType::ROUTING_CHANGE),
+ "CecMessageType::ROUTING_CHANGE must match legacy value.");
+static_assert(CEC_MESSAGE_ROUTING_INFORMATION ==
+ static_cast<int>(CecMessageType::ROUTING_INFORMATION),
+ "CecMessageType::ROUTING_INFORMATION must match legacy value.");
+static_assert(CEC_MESSAGE_ACTIVE_SOURCE == static_cast<int>(CecMessageType::ACTIVE_SOURCE),
+ "CecMessageType::ACTIVE_SOURCE must match legacy value.");
+static_assert(CEC_MESSAGE_GIVE_PHYSICAL_ADDRESS ==
+ static_cast<int>(CecMessageType::GIVE_PHYSICAL_ADDRESS),
+ "CecMessageType::GIVE_PHYSICAL_ADDRESS must match legacy value.");
+static_assert(CEC_MESSAGE_REPORT_PHYSICAL_ADDRESS ==
+ static_cast<int>(CecMessageType::REPORT_PHYSICAL_ADDRESS),
+ "CecMessageType::REPORT_PHYSICAL_ADDRESS must match legacy value.");
+static_assert(CEC_MESSAGE_REQUEST_ACTIVE_SOURCE ==
+ static_cast<int>(CecMessageType::REQUEST_ACTIVE_SOURCE),
+ "CecMessageType::REQUEST_ACTIVE_SOURCE must match legacy value.");
+static_assert(CEC_MESSAGE_SET_STREAM_PATH == static_cast<int>(CecMessageType::SET_STREAM_PATH),
+ "CecMessageType::SET_STREAM_PATH must match legacy value.");
+static_assert(CEC_MESSAGE_DEVICE_VENDOR_ID == static_cast<int>(CecMessageType::DEVICE_VENDOR_ID),
+ "CecMessageType::DEVICE_VENDOR_ID must match legacy value.");
+static_assert(CEC_MESSAGE_VENDOR_COMMAND == static_cast<int>(CecMessageType::VENDOR_COMMAND),
+ "CecMessageType::VENDOR_COMMAND must match legacy value.");
+static_assert(CEC_MESSAGE_VENDOR_REMOTE_BUTTON_DOWN ==
+ static_cast<int>(CecMessageType::VENDOR_REMOTE_BUTTON_DOWN),
+ "CecMessageType::VENDOR_REMOTE_BUTTON_DOWN must match legacy value.");
+static_assert(CEC_MESSAGE_VENDOR_REMOTE_BUTTON_UP ==
+ static_cast<int>(CecMessageType::VENDOR_REMOTE_BUTTON_UP),
+ "CecMessageType::VENDOR_REMOTE_BUTTON_UP must match legacy value.");
+static_assert(CEC_MESSAGE_GIVE_DEVICE_VENDOR_ID ==
+ static_cast<int>(CecMessageType::GIVE_DEVICE_VENDOR_ID),
+ "CecMessageType::GIVE_DEVICE_VENDOR_ID must match legacy value.");
+static_assert(CEC_MESSAGE_MENU_REQUEST == static_cast<int>(CecMessageType::MENU_REQUEST),
+ "CecMessageType::MENU_REQUEST must match legacy value.");
+static_assert(CEC_MESSAGE_MENU_STATUS == static_cast<int>(CecMessageType::MENU_STATUS),
+ "CecMessageType::MENU_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_GIVE_DEVICE_POWER_STATUS ==
+ static_cast<int>(CecMessageType::GIVE_DEVICE_POWER_STATUS),
+ "CecMessageType::GIVE_DEVICE_POWER_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_REPORT_POWER_STATUS ==
+ static_cast<int>(CecMessageType::REPORT_POWER_STATUS),
+ "CecMessageType::REPORT_POWER_STATUS must match legacy value.");
+static_assert(CEC_MESSAGE_GET_MENU_LANGUAGE == static_cast<int>(CecMessageType::GET_MENU_LANGUAGE),
+ "CecMessageType::GET_MENU_LANGUAGE must match legacy value.");
+static_assert(CEC_MESSAGE_SELECT_ANALOG_SERVICE ==
+ static_cast<int>(CecMessageType::SELECT_ANALOG_SERVICE),
+ "CecMessageType::SELECT_ANALOG_SERVICE must match legacy value.");
+static_assert(CEC_MESSAGE_SELECT_DIGITAL_SERVICE ==
+ static_cast<int>(CecMessageType::SELECT_DIGITAL_SERVICE),
+ "CecMessageType::SELECT_DIGITAL_SERVICE must match legacy value.");
+static_assert(CEC_MESSAGE_SET_DIGITAL_TIMER == static_cast<int>(CecMessageType::SET_DIGITAL_TIMER),
+ "CecMessageType::SET_DIGITAL_TIMER must match legacy value.");
+static_assert(CEC_MESSAGE_CLEAR_DIGITAL_TIMER ==
+ static_cast<int>(CecMessageType::CLEAR_DIGITAL_TIMER),
+ "CecMessageType::CLEAR_DIGITAL_TIMER must match legacy value.");
+static_assert(CEC_MESSAGE_SET_AUDIO_RATE == static_cast<int>(CecMessageType::SET_AUDIO_RATE),
+ "CecMessageType::SET_AUDIO_RATE must match legacy value.");
+static_assert(CEC_MESSAGE_INACTIVE_SOURCE == static_cast<int>(CecMessageType::INACTIVE_SOURCE),
+ "CecMessageType::INACTIVE_SOURCE must match legacy value.");
+static_assert(CEC_MESSAGE_CEC_VERSION == static_cast<int>(CecMessageType::CEC_VERSION),
+ "CecMessageType::CEC_VERSION must match legacy value.");
+static_assert(CEC_MESSAGE_GET_CEC_VERSION == static_cast<int>(CecMessageType::GET_CEC_VERSION),
+ "CecMessageType::GET_CEC_VERSION must match legacy value.");
+static_assert(CEC_MESSAGE_VENDOR_COMMAND_WITH_ID ==
+ static_cast<int>(CecMessageType::VENDOR_COMMAND_WITH_ID),
+ "CecMessageType::VENDOR_COMMAND_WITH_ID must match legacy value.");
+static_assert(CEC_MESSAGE_CLEAR_EXTERNAL_TIMER ==
+ static_cast<int>(CecMessageType::CLEAR_EXTERNAL_TIMER),
+ "CecMessageType::CLEAR_EXTERNAL_TIMER must match legacy value.");
+static_assert(CEC_MESSAGE_SET_EXTERNAL_TIMER ==
+ static_cast<int>(CecMessageType::SET_EXTERNAL_TIMER),
+ "CecMessageType::SET_EXTERNAL_TIMER must match legacy value.");
+static_assert(CEC_MESSAGE_INITIATE_ARC == static_cast<int>(CecMessageType::INITIATE_ARC),
+ "CecMessageType::INITIATE_ARC must match legacy value.");
+static_assert(CEC_MESSAGE_REPORT_ARC_INITIATED ==
+ static_cast<int>(CecMessageType::REPORT_ARC_INITIATED),
+ "CecMessageType::REPORT_ARC_INITIATED must match legacy value.");
+static_assert(CEC_MESSAGE_REPORT_ARC_TERMINATED ==
+ static_cast<int>(CecMessageType::REPORT_ARC_TERMINATED),
+ "CecMessageType::REPORT_ARC_TERMINATED must match legacy value.");
+static_assert(CEC_MESSAGE_REQUEST_ARC_INITIATION ==
+ static_cast<int>(CecMessageType::REQUEST_ARC_INITIATION),
+ "CecMessageType::REQUEST_ARC_INITIATION must match legacy value.");
+static_assert(CEC_MESSAGE_REQUEST_ARC_TERMINATION ==
+ static_cast<int>(CecMessageType::REQUEST_ARC_TERMINATION),
+ "CecMessageType::REQUEST_ARC_TERMINATION must match legacy value.");
+static_assert(CEC_MESSAGE_TERMINATE_ARC == static_cast<int>(CecMessageType::TERMINATE_ARC),
+ "CecMessageType::TERMINATE_ARC must match legacy value.");
+static_assert(CEC_MESSAGE_ABORT == static_cast<int>(CecMessageType::ABORT),
+ "CecMessageType::ABORT must match legacy value.");
+
+static_assert(ABORT_UNRECOGNIZED_MODE == static_cast<int>(AbortReason::UNRECOGNIZED_MODE),
+ "AbortReason::UNRECOGNIZED_MODE must match legacy value.");
+static_assert(ABORT_NOT_IN_CORRECT_MODE == static_cast<int>(AbortReason::NOT_IN_CORRECT_MODE),
+ "AbortReason::NOT_IN_CORRECT_MODE must match legacy value.");
+static_assert(ABORT_CANNOT_PROVIDE_SOURCE == static_cast<int>(AbortReason::CANNOT_PROVIDE_SOURCE),
+ "AbortReason::CANNOT_PROVIDE_SOURCE must match legacy value.");
+static_assert(ABORT_INVALID_OPERAND == static_cast<int>(AbortReason::INVALID_OPERAND),
+ "AbortReason::INVALID_OPERAND must match legacy value.");
+static_assert(ABORT_REFUSED == static_cast<int>(AbortReason::REFUSED),
+ "AbortReason::REFUSED must match legacy value.");
+static_assert(ABORT_UNABLE_TO_DETERMINE == static_cast<int>(AbortReason::UNABLE_TO_DETERMINE),
+ "AbortReason::UNABLE_TO_DETERMINE must match legacy value.");
+
+static_assert(HDMI_RESULT_SUCCESS == static_cast<int>(SendMessageResult::SUCCESS),
+ "SendMessageResult::SUCCESS must match legacy value.");
+static_assert(HDMI_RESULT_NACK == static_cast<int>(SendMessageResult::NACK),
+ "SendMessageResult::NACK must match legacy value.");
+static_assert(HDMI_RESULT_BUSY == static_cast<int>(SendMessageResult::BUSY),
+ "SendMessageResult::BUSY must match legacy value.");
+static_assert(HDMI_RESULT_FAIL == static_cast<int>(SendMessageResult::FAIL),
+ "SendMessageResult::FAIL must match legacy value.");
+
+static_assert(HDMI_INPUT == static_cast<int>(HdmiPortType::INPUT),
+ "HdmiPortType::INPUT must match legacy value.");
+static_assert(HDMI_OUTPUT == static_cast<int>(HdmiPortType::OUTPUT),
+ "HdmiPortType::OUTPUT must match legacy value.");
+
+static_assert(HDMI_OPTION_WAKEUP == static_cast<int>(OptionKey::WAKEUP),
+ "OptionKey::WAKEUP must match legacy value.");
+static_assert(HDMI_OPTION_ENABLE_CEC == static_cast<int>(OptionKey::ENABLE_CEC),
+ "OptionKey::ENABLE_CEC must match legacy value.");
+static_assert(HDMI_OPTION_SYSTEM_CEC_CONTROL == static_cast<int>(OptionKey::SYSTEM_CEC_CONTROL),
+ "OptionKey::SYSTEM_CEC_CONTROL must match legacy value.");
+
+sp<IHdmiCecCallback> HdmiCec::mCallback = nullptr;
+
+HdmiCec::HdmiCec(hdmi_cec_device_t* device) : mDevice(device) {}
+
+// Methods from ::android::hardware::tv::cec::V2_0::IHdmiCec follow.
+Return<Result> HdmiCec::addDeviceType(CecDeviceType deviceType) {
+ // TODO implement
+ if (deviceType <= CecDeviceType::MAX) {
+ return Result::SUCCESS;
+ } else {
+ return Result::FAILURE_INVALID_ARGS;
+ }
+}
+
+Return<void> HdmiCec::clearDeviceTypes() {
+ // TODO implement
+ return Void();
+}
+
+Return<void> HdmiCec::setAllDeviceTypes(CecAllDeviceTypes allDeviceTypes) {
+ // TODO implement
+ if (allDeviceTypes == 1) {
+ }
+ return Void();
+}
+
+Return<void> HdmiCec::setDeviceFeatures(CecDeviceType deviceType,
+ CecDeviceFeatures /* deviceFeatures */) {
+ // TODO implement
+ if (deviceType != CecDeviceType::MAX) {
+ }
+ return Void();
+}
+
+Return<void> HdmiCec::setRcProfile(CecDeviceType deviceType, const CecRcProfile& /* rcProfile */) {
+ // TODO implement
+ if (deviceType != CecDeviceType::MAX) {
+ }
+ return Void();
+}
+
+Return<void> HdmiCec::readDeviceInfo(CecLogicalAddress logicalAddress,
+ CecPhysicalAddress physicalAddress,
+ const readDeviceInfo_cb _hidl_cb) {
+ // TODO implement
+ CecDeviceInfo deviceInfo;
+
+ if (logicalAddress == CecLogicalAddress::TV) {
+ _hidl_cb(Result::SUCCESS, deviceInfo);
+ if (physicalAddress) {
+ }
+ }
+ return Void();
+}
+
+Return<SendMessageResult> HdmiCec::sendMessage(const CecMessage& message) {
+ cec_message_t legacyMessage{
+ .initiator = static_cast<cec_logical_address_t>(message.initiator),
+ .destination = static_cast<cec_logical_address_t>(message.destination),
+ .length = message.body.size(),
+ };
+ for (size_t i = 0; i < message.body.size(); ++i) {
+ legacyMessage.body[i] = static_cast<unsigned char>(message.body[i]);
+ }
+ return static_cast<SendMessageResult>(mDevice->send_message(mDevice, &legacyMessage));
+}
+
+Return<void> HdmiCec::setCallback(const sp<IHdmiCecCallback>& callback) {
+ if (mCallback != nullptr) {
+ mCallback->unlinkToDeath(this);
+ mCallback = nullptr;
+ }
+
+ if (callback != nullptr) {
+ mCallback = callback;
+ mCallback->linkToDeath(this, 0 /*cookie*/);
+ mDevice->register_event_callback(mDevice, eventCallback, nullptr);
+ }
+ return Void();
+}
+
+Return<void> HdmiCec::getPortInfo(getPortInfo_cb _hidl_cb) {
+ struct hdmi_port_info* legacyPorts;
+ int numPorts;
+ hidl_vec<HdmiPortInfo> portInfos;
+ mDevice->get_port_info(mDevice, &legacyPorts, &numPorts);
+ portInfos.resize(numPorts);
+ for (int i = 0; i < numPorts; ++i) {
+ portInfos[i] = {.type = static_cast<HdmiPortType>(legacyPorts[i].type),
+ .portId = static_cast<HdmiPortId>(legacyPorts[i].port_id),
+ .cecSupported = legacyPorts[i].cec_supported != 0,
+ .arcSupported = legacyPorts[i].arc_supported != 0,
+ .physicalAddress = legacyPorts[i].physical_address};
+ }
+ _hidl_cb(portInfos);
+ return Void();
+}
+
+Return<void> HdmiCec::setOption(OptionKey key, bool value) {
+ mDevice->set_option(mDevice, static_cast<int>(key), value ? 1 : 0);
+ return Void();
+}
+
+Return<void> HdmiCec::setLanguage(const hidl_string& language) {
+ if (language.size() != 3) {
+ LOG(ERROR) << "Wrong language code: expected 3 letters, but it was " << language.size()
+ << ".";
+ return Void();
+ }
+ const char* languageStr = language.c_str();
+ int convertedLanguage = ((languageStr[0] & 0xFF) << 16) | ((languageStr[1] & 0xFF) << 8) |
+ (languageStr[2] & 0xFF);
+ mDevice->set_option(mDevice, HDMI_OPTION_SET_LANG, convertedLanguage);
+ return Void();
+}
+
+Return<void> HdmiCec::enableAudioReturnChannel(HdmiPortId portId, bool enable) {
+ mDevice->set_audio_return_channel(mDevice, portId, enable ? 1 : 0);
+ return Void();
+}
+
+Return<bool> HdmiCec::isConnected(HdmiPortId portId) {
+ return mDevice->is_connected(mDevice, portId) > 0;
+}
+
+IHdmiCec* HIDL_FETCH_IHdmiCec(const char* hal) {
+ hdmi_cec_device_t* hdmi_cec_device;
+ int ret = 0;
+ const hw_module_t* hw_module = nullptr;
+
+ ret = hw_get_module(HDMI_CEC_HARDWARE_MODULE_ID, &hw_module);
+ if (ret == 0) {
+ ret = hdmi_cec_open(hw_module, &hdmi_cec_device);
+ if (ret != 0) {
+ LOG(ERROR) << "hdmi_cec_open " << hal << " failed: " << ret;
+ }
+ } else {
+ LOG(ERROR) << "hw_get_module " << hal << " failed: " << ret;
+ }
+
+ if (ret == 0) {
+ return new HdmiCec(hdmi_cec_device);
+ } else {
+ LOG(ERROR) << "Passthrough failed to load legacy HAL.";
+ return nullptr;
+ }
+}
+
+} // namespace implementation
+} // namespace V2_0
+} // namespace cec
+} // namespace tv
+} // namespace hardware
+} // namespace android
diff --git a/tv/cec/2.0/default/HdmiCec.h b/tv/cec/2.0/default/HdmiCec.h
new file mode 100644
index 0000000..ab54770
--- /dev/null
+++ b/tv/cec/2.0/default/HdmiCec.h
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#ifndef ANDROID_HARDWARE_TV_CEC_V2_0_HDMICEC_H
+#define ANDROID_HARDWARE_TV_CEC_V2_0_HDMICEC_H
+
+#include <algorithm>
+
+#include <android/hardware/tv/cec/2.0/IHdmiCec.h>
+#include <hardware/hardware.h>
+#include <hardware/hdmi_cec.h>
+#include <hidl/Status.h>
+
+#include <hidl/MQDescriptor.h>
+namespace android {
+namespace hardware {
+namespace tv {
+namespace cec {
+namespace V2_0 {
+namespace implementation {
+
+using ::android::sp;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::tv::cec::V2_0::CecLogicalAddress;
+using ::android::hardware::tv::cec::V2_0::CecMessage;
+using ::android::hardware::tv::cec::V2_0::CecPhysicalAddress;
+using ::android::hardware::tv::cec::V2_0::HdmiPortId;
+using ::android::hardware::tv::cec::V2_0::HdmiPortInfo;
+using ::android::hardware::tv::cec::V2_0::IHdmiCec;
+using ::android::hardware::tv::cec::V2_0::IHdmiCecCallback;
+using ::android::hardware::tv::cec::V2_0::MaxLength;
+using ::android::hardware::tv::cec::V2_0::OptionKey;
+using ::android::hardware::tv::cec::V2_0::Result;
+using ::android::hardware::tv::cec::V2_0::SendMessageResult;
+
+struct HdmiCec : public IHdmiCec, public hidl_death_recipient {
+ HdmiCec(hdmi_cec_device_t* device);
+ // Methods from ::android::hardware::tv::cec::V2_0::IHdmiCec follow.
+ Return<Result> addDeviceType(CecDeviceType deviceType) override;
+ Return<void> clearDeviceTypes() override;
+ Return<void> setAllDeviceTypes(CecAllDeviceTypes allDeviceTypes) override;
+ Return<void> setDeviceFeatures(CecDeviceType deviceType,
+ CecDeviceFeatures /* deviceFeatures */) override;
+ Return<void> setRcProfile(CecDeviceType deviceType,
+ const CecRcProfile& /* rcProfile */) override;
+ Return<void> readDeviceInfo(CecLogicalAddress logicalAddress,
+ CecPhysicalAddress physicalAddress,
+ const readDeviceInfo_cb _hidl_cb) override;
+ Return<SendMessageResult> sendMessage(const CecMessage& message) override;
+ Return<void> setCallback(const sp<IHdmiCecCallback>& callback) override;
+ Return<void> getPortInfo(getPortInfo_cb _hidl_cb) override;
+ Return<void> setOption(OptionKey key, bool value) override;
+ Return<void> setLanguage(const hidl_string& language) override;
+ Return<void> enableAudioReturnChannel(HdmiPortId portId, bool enable) override;
+ Return<bool> isConnected(HdmiPortId portId) override;
+
+ static void eventCallback(const hdmi_event_t* event, void* /* arg */) {
+ if (mCallback != nullptr && event != nullptr) {
+ if (event->type == HDMI_EVENT_CEC_MESSAGE) {
+ size_t length =
+ std::min(event->cec.length, static_cast<size_t>(MaxLength::MESSAGE_BODY));
+ CecMessage cecMessage{
+ .initiator = static_cast<CecLogicalAddress>(event->cec.initiator),
+ .destination = static_cast<CecLogicalAddress>(event->cec.destination),
+ };
+ cecMessage.body.resize(length);
+ for (size_t i = 0; i < length; ++i) {
+ cecMessage.body[i] = static_cast<uint8_t>(event->cec.body[i]);
+ }
+ mCallback->onCecMessage(cecMessage);
+ } else if (event->type == HDMI_EVENT_HOT_PLUG) {
+ HotplugEvent hotplugEvent{
+ .connected = event->hotplug.connected > 0,
+ .portId = static_cast<HdmiPortId>(event->hotplug.port_id)};
+ mCallback->onHotplugEvent(hotplugEvent);
+ }
+ }
+ }
+
+ virtual void serviceDied(uint64_t /*cookie*/,
+ const wp<::android::hidl::base::V1_0::IBase>& /*who*/) {
+ setCallback(nullptr);
+ }
+
+ private:
+ static sp<IHdmiCecCallback> mCallback;
+ const hdmi_cec_device_t* mDevice;
+};
+
+extern "C" IHdmiCec* HIDL_FETCH_IHdmiCec(const char* name);
+
+} // namespace implementation
+} // namespace V2_0
+} // namespace cec
+} // namespace tv
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_TV_CEC_V2_0_HDMICEC_H
diff --git a/tv/cec/2.0/default/OWNERS b/tv/cec/2.0/default/OWNERS
new file mode 100644
index 0000000..1b3d095
--- /dev/null
+++ b/tv/cec/2.0/default/OWNERS
@@ -0,0 +1,4 @@
+nchalko@google.com
+amyjojo@google.com
+shubang@google.com
+quxiangfang@google.com
diff --git a/tv/cec/2.0/default/android.hardware.tv.cec@2.0-service.rc b/tv/cec/2.0/default/android.hardware.tv.cec@2.0-service.rc
new file mode 100644
index 0000000..1e8cd80
--- /dev/null
+++ b/tv/cec/2.0/default/android.hardware.tv.cec@2.0-service.rc
@@ -0,0 +1,4 @@
+service vendor.cec-hal-2-0 /vendor/bin/hw/android.hardware.tv.cec@2.0-service
+ class hal
+ user system
+ group system
diff --git a/tv/cec/2.0/default/android.hardware.tv.cec@2.0-service.xml b/tv/cec/2.0/default/android.hardware.tv.cec@2.0-service.xml
new file mode 100644
index 0000000..61fb1bb
--- /dev/null
+++ b/tv/cec/2.0/default/android.hardware.tv.cec@2.0-service.xml
@@ -0,0 +1,11 @@
+<manifest version="1.0" type="device">
+ <hal format="hidl">
+ <name>android.hardware.tv.cec</name>
+ <transport>hwbinder</transport>
+ <version>2.0</version>
+ <interface>
+ <name>IHdmiCec</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+</manifest>
diff --git a/tv/cec/2.0/default/service.cpp b/tv/cec/2.0/default/service.cpp
new file mode 100644
index 0000000..dacc38c
--- /dev/null
+++ b/tv/cec/2.0/default/service.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#define LOG_TAG "android.hardware.tv.cec@2.0-service"
+
+#include <android/hardware/tv/cec/2.0/IHdmiCec.h>
+#include <hidl/LegacySupport.h>
+
+using android::hardware::defaultPassthroughServiceImplementation;
+using android::hardware::tv::cec::V2_0::IHdmiCec;
+
+int main() {
+ return defaultPassthroughServiceImplementation<IHdmiCec>();
+}
diff --git a/tv/cec/2.0/types.hal b/tv/cec/2.0/types.hal
new file mode 100644
index 0000000..cad6c39
--- /dev/null
+++ b/tv/cec/2.0/types.hal
@@ -0,0 +1,548 @@
+/*
+ * Copyright (C) 2019 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.cec@2.0;
+
+import android.hidl.safe_union@1.0;
+
+/**
+ * CEC device type as specified in CEC Table 11-7 of the CEC spec 2.0b.
+ */
+enum CecDeviceType : int32_t {
+ INACTIVE = -1,
+ TV = 0,
+ RECORDER = 1,
+ TUNER = 3,
+ PLAYBACK = 4,
+ AUDIO_SYSTEM = 5,
+ PURE_CEC_SWITCH = 6,
+ PROCESSOR = 7,
+ MAX = PROCESSOR,
+};
+
+/**
+ * CEC logical address as specified in CEC Table 11-9 of the CEC spec 2.0b.
+ */
+enum CecLogicalAddress : int32_t {
+ TV = 0,
+ RECORDER_1 = 1,
+ RECORDER_2 = 2,
+ TUNER_1 = 3,
+ PLAYBACK_1 = 4,
+ AUDIO_SYSTEM = 5,
+ TUNER_2 = 6,
+ TUNER_3 = 7,
+ PLAYBACK_2 = 8,
+ RECORDER_3 = 9,
+ TUNER_4 = 10,
+ PLAYBACK_3 = 11,
+ BACKUP_1 = 12, // backup1 for Playback/Recording/Tuner/Processor device
+ BACKUP_2 = 13, // backup2 for Playback/Recording/Tuner/Processor device
+ SPECIFIC_USE = 14,
+ UNREGISTERED = 15, // as Initiator address
+ BROADCAST = 15, // as Destination address
+};
+
+/**
+ * HDMI CEC message types.
+ *
+ * The assigned values represent opcode used in CEC frame as specified in
+ * Section 11.10 of the CEC spec 2.0b on top of Section CEC 15 of the CEC
+ * Spec 1.4b.
+ */
+enum CecMessageType : int32_t {
+ FEATURE_ABORT = 0x00,
+ IMAGE_VIEW_ON = 0x04,
+ TUNER_STEP_INCREMENT = 0x05,
+ TUNER_STEP_DECREMENT = 0x06,
+ TUNER_DEVICE_STATUS = 0x07,
+ GIVE_TUNER_DEVICE_STATUS = 0x08,
+ RECORD_ON = 0x09,
+ RECORD_STATUS = 0x0A,
+ RECORD_OFF = 0x0B,
+ TEXT_VIEW_ON = 0x0D,
+ RECORD_TV_SCREEN = 0x0F,
+ GIVE_DECK_STATUS = 0x1A,
+ DECK_STATUS = 0x1B,
+ SET_MENU_LANGUAGE = 0x32,
+ CLEAR_ANALOG_TIMER = 0x33,
+ SET_ANALOG_TIMER = 0x34,
+ TIMER_STATUS = 0x35,
+ STANDBY = 0x36,
+ PLAY = 0x41,
+ DECK_CONTROL = 0x42,
+ TIMER_CLEARED_STATUS = 0x43,
+ USER_CONTROL_PRESSED = 0x44,
+ USER_CONTROL_RELEASED = 0x45,
+ GIVE_OSD_NAME = 0x46,
+ SET_OSD_NAME = 0x47,
+ SET_OSD_STRING = 0x64,
+ SET_TIMER_PROGRAM_TITLE = 0x67,
+ SYSTEM_AUDIO_MODE_REQUEST = 0x70,
+ GIVE_AUDIO_STATUS = 0x71,
+ SET_SYSTEM_AUDIO_MODE = 0x72,
+ REPORT_AUDIO_STATUS = 0x7A,
+ GIVE_SYSTEM_AUDIO_MODE_STATUS = 0x7D,
+ SYSTEM_AUDIO_MODE_STATUS = 0x7E,
+ ROUTING_CHANGE = 0x80,
+ ROUTING_INFORMATION = 0x81,
+ ACTIVE_SOURCE = 0x82,
+ GIVE_PHYSICAL_ADDRESS = 0x83,
+ REPORT_PHYSICAL_ADDRESS = 0x84,
+ REQUEST_ACTIVE_SOURCE = 0x85,
+ SET_STREAM_PATH = 0x86,
+ DEVICE_VENDOR_ID = 0x87,
+ VENDOR_COMMAND = 0x89,
+ VENDOR_REMOTE_BUTTON_DOWN = 0x8A,
+ VENDOR_REMOTE_BUTTON_UP = 0x8B,
+ GIVE_DEVICE_VENDOR_ID = 0x8C,
+ MENU_REQUEST = 0x8D,
+ MENU_STATUS = 0x8E,
+ GIVE_DEVICE_POWER_STATUS = 0x8F,
+ REPORT_POWER_STATUS = 0x90,
+ GET_MENU_LANGUAGE = 0x91,
+ SELECT_ANALOG_SERVICE = 0x92,
+ SELECT_DIGITAL_SERVICE = 0x93,
+ SET_DIGITAL_TIMER = 0x97,
+ CLEAR_DIGITAL_TIMER = 0x99,
+ SET_AUDIO_RATE = 0x9A,
+ INACTIVE_SOURCE = 0x9D,
+ CEC_VERSION = 0x9E,
+ GET_CEC_VERSION = 0x9F,
+ VENDOR_COMMAND_WITH_ID = 0xA0,
+ CLEAR_EXTERNAL_TIMER = 0xA1,
+ SET_EXTERNAL_TIMER = 0xA2,
+ REPORT_SHORT_AUDIO_DESCRIPTOR = 0xA3,
+ REQUEST_SHORT_AUDIO_DESCRIPTOR = 0xA4,
+ GIVE_FEATURES = 0XA5,
+ REPORT_FEATURES = 0xA6,
+ REQUEST_CURRENT_LATENCY = 0xA7,
+ REPORT_CURRENT_LATENCY = 0xA8,
+ INITIATE_ARC = 0xC0,
+ REPORT_ARC_INITIATED = 0xC1,
+ REPORT_ARC_TERMINATED = 0xC2,
+ REQUEST_ARC_INITIATION = 0xC3,
+ REQUEST_ARC_TERMINATION = 0xC4,
+ TERMINATE_ARC = 0xC5,
+ ABORT = 0xFF,
+ POLLING_MESSAGE = 0xFFFFFF00, // used for cec polling message
+};
+
+/**
+ * Abort Reason as specified in CEC Table 29 of the CEC spec 1.4b.
+ */
+enum AbortReason : int32_t {
+ UNRECOGNIZED_MODE = 0,
+ NOT_IN_CORRECT_MODE = 1,
+ CANNOT_PROVIDE_SOURCE = 2,
+ INVALID_OPERAND = 3,
+ REFUSED = 4,
+ UNABLE_TO_DETERMINE = 5,
+};
+
+enum MaxLength : int32_t {
+ MESSAGE_BODY = 14,
+};
+
+struct CecMessage {
+ /** logical address of sender */
+ CecLogicalAddress initiator;
+
+ /** logical address of receiver */
+ CecLogicalAddress destination;
+
+ /** cec message type */
+ CecMessageType cecMessageType;
+
+ /**
+ * The maximum size of body is 14 (MaxLength::MESSAGE_BODY) as specified in
+ * the section 6 of the CEC Spec 1.4b. Overflowed data must be ignored.
+ */
+ vec<uint8_t> body;
+};
+
+/**
+ * error code used for send_message.
+ */
+enum SendMessageResult : int32_t {
+ SUCCESS = 0,
+ NACK = 1, // not acknowledged
+ BUSY = 2, // bus is busy
+ FAIL = 3,
+};
+
+/**
+ * CEC All Device Type Value as specified in Table 11-30 of the CEC spec 2.0b.
+ */
+enum CecAllDeviceTypeValue : uint8_t {
+ RESERVED_DEVICE_2 = 1 << 0,
+ RESERVED_DEVICE_1 = 1 << 1,
+ CEC_SWITCH_DEVICE = 1 << 2,
+ AUDIO_DEVICE = 1 << 3,
+ PLAYBACK_DEVICE = 1 << 4,
+ TUNER_DEVICE = 1 << 5,
+ RECORDING_DEVICE = 1 << 6,
+ TV_DEVICE = 1 << 7,
+};
+
+/**
+ * CEC All Device Types
+ *
+ * It is a combination of all supported type from CecAllDeviceTypeValue.
+ * For example a record with tuner functionalitye,
+ * cecAllDeviceTypes = ((CecAllDeviceTypeValue::RECORDING_DEVICE)
+ * |(CecAllDeviceTypeValue::TUNER_DEVICE))
+ */
+typedef bitfield<CecAllDeviceTypeValue> CecAllDeviceTypes;
+
+/**
+ * CEC Versions as specified in CEC Table 11-30 of the CEC spec 2.0b.
+ */
+enum CecVersion : int32_t {
+ V_1_3_A = 0x04,
+ V_1_4 = 0x05, // indicate CEC 1.4, 1.4a or 1.4b
+ V_2_0 = 0x06,
+};
+
+/**
+ * Device Feature
+ *
+ * It is specified in CEC Table 11-30 of the CEC spec 2.0b. As a uint32 there
+ * is room for future extensions aka DeviceFeature2 through DeviceFeature4.
+ */
+enum CecDeviceFeature : uint32_t {
+ RESERVED = 1 << 0,
+ SOURCE_SUPPORT_ARC_RX = 1 << 1,
+ SINK_SUPPORT_ARC_TX = 1 << 2,
+ SOURCE_SUPPORT_SET_AUDIO_RATE = 1 << 3,
+ SUPPORT_CONTROLLED_BY_DECK = 1 << 4,
+ TV_SUPPORT_SET_OSD_STRINGS = 1 << 5,
+ TV_SUPPORT_RECORD_TV_SCREEN = 1 << 6,
+};
+
+/**
+ * CEC Device Features
+ *
+ * It is a combination of all supported features from CecDeviceFeature.
+ * For example a TV with OSD and ARC capabilities,
+ * CecDeviceFeatures = ((CecDeviceFeature::TV_SUPPORT_SET_OSD_STRINGS)
+ * |(CecDeviceFeature::SINK_SUPPORT_ARC_TX))
+ */
+typedef bitfield<CecDeviceFeature> CecDeviceFeatures;
+
+/**
+ * Remote Control Profile
+ *
+ * It is specified in CEC Table 11-30 of the CEC spec 2.0b.
+ */
+enum CecRcProfileId : uint8_t {
+ NONE = 0, // TV doesn’t support any of these profiles
+ RC_PROFILE_1 = 0x02, // minimalistic zapper (low button count)
+ RC_PROFILE_2 = 0x06, // intermediate between profile 1 and profile 3
+ RC_PROFILE_3 = 0x0A, // typical TV remote
+ RC_PROFILE_4 = 0x0E, // extended form of profile 3
+};
+
+/**
+ * Remote Control Profile Source
+ *
+ * It is specified in CEC Table 11-30 of the CEC spec 2.0b.
+ */
+enum CecRcProfileSource : uint8_t {
+ MEDIA_CONTEXT_SENSITIVE = 1 << 0, // source can handle UI command 0x11
+ MEDIA_TO = 1 << 1, // source can handle UI command 0x10
+ CONTENTS = 1 << 2, // source can handle UI command 0x0B
+ DEVICE_SETUP = 1 << 3, // source can handle UI command 0x0A
+ DEVICE_ROOT = 1 << 4, // source can handle UI command 0x09
+ SOURCE_FLAG = 1 << 6, // Indicate the profile is for source
+};
+
+/**
+ * Remote Control Profile for either TV or Source.
+ */
+safe_union CecRcProfile1 {
+ /** CEC remote control profile for TV. */
+ CecRcProfileId profileId;
+
+ /* CEC remote control profile for source
+ *
+ * It is a combination of all supported profiles from CecRcProfileSource.
+ * For example a playback device support root menu and setup menu,
+ * profileSource = ((CecRcProfileSource::DEVICE_ROOT)
+ * |(CecRcProfileSource::DEVICE_SETUP)
+ * |(CecRcProfileSource::SOURCE_FLAG))
+ */
+ bitfield<CecRcProfileSource> profileSource;
+};
+
+/**
+ * CEC Remote Control Profiles
+ *
+ * CEC 2.0 only use one byte to represent Remote Control Profile.
+ */
+struct CecRcProfile {
+ CecRcProfile1 rcProfile1;
+};
+
+/**
+ * CEC device power states as specified in CEC Table 11-10 of the CEC spec 2.0b
+ */
+enum CecPowerState : int8_t {
+ ON = 0,
+ STANDBY = 1,
+ ON_TO_STANDBY = 2,
+ STANDBY_TO_ON = 4,
+ UNKNOWN = 0xFF, // some devices may not report power status
+};
+
+/** CEC physical address of device */
+typedef uint16_t CecPhysicalAddress;
+
+/**
+ * CEC device information
+ *
+ * It is initially built during addressing specified in CEC section 11.3 of
+ * the CEC spec 2.0b. It may be updated with cec devices's status changed.
+ */
+struct CecDeviceInfo {
+ /** CEC version which device supports */
+ CecVersion version;
+
+ /** CEC device primary type */
+ CecDeviceType devceType;
+
+ /** CEC all device types */
+ CecAllDeviceTypes allDeviceTypes;
+
+ /** CEC device features */
+ CecDeviceFeatures deviceFeatures;
+
+ /** CEC Device Remote Control Profile */
+ CecRcProfile rcProfile;
+
+ /** CEC Device Vendor ID */
+ uint32_t vendorId;
+
+ /** logical address of device */
+ CecLogicalAddress logicalAddress;
+
+ /** physical of device */
+ CecPhysicalAddress physicalAddress;
+
+ /** power status of device */
+ CecPowerState powerState;
+};
+
+/**
+ * Topology Event Type.
+ */
+enum CecTopologyEventType : int32_t {
+ DEVICE_ADDED,
+ DEVICE_REMOVED,
+ DEVICE_UPDATED,
+};
+
+/**
+ * Topology Event.
+ */
+struct CecTopologyEvent {
+ CecTopologyEventType eventType;
+ CecLogicalAddress logicalAddress;
+ CecPhysicalAddress physicalAddress;
+
+ /** true if the event is about the device which the system run on */
+ bool isHostDevice;
+};
+
+
+/**
+ * CEC UI Command Codes as specified in CEC Table 11-31 of the CEC spec 2.0b
+ */
+enum CecUICommandCodes : int32_t {
+ SELECT_OK = 0x00,
+ UP = 0x01,
+ DOWN = 0x02,
+ LEFT = 0x03,
+ RIGHT = 0x04,
+ RIGHT_UP = 0x05,
+ RIGHT_DOWN = 0x06,
+ LEFT_UP = 0x07,
+ LEFT_DOWN = 0x08,
+ DEVICE_ROOT_MENU = 0x09,
+ DEVICE_SETUP_MENU = 0x0A,
+ CONTENTS_MENU = 0x0B,
+ FAVORITE_MENU = 0x0C,
+ BACK = 0x0D,
+ MEDIA_TOP_MENU = 0x10,
+ MEDIA_CONTEXT_SENSITIVE_MENU = 0x11,
+ NUMBER_ENTRY_MODE = 0x1D,
+ NUMBER_11 = 0x1E,
+ NUMBER_12 = 0x1F,
+ NUMBER_0 = 0x20, // or NUMBER 10
+ NUMBER_1 = 0x21,
+ NUMBER_2 = 0x22,
+ NUMBER_3 = 0x23,
+ NUMBER_4 = 0x24,
+ NUMBER_5 = 0x25,
+ NUMBER_6 = 0x26,
+ NUMBER_7 = 0x27,
+ NUMBER_8 = 0x28,
+ NUMBER_9 = 0x29,
+ DOT = 0x2A,
+ ENTER = 0x2B,
+ CLEAR = 0x2C,
+ NEXT_FAVORITE = 0x2F,
+ CHANNEL_UP = 0x30,
+ CHANNEL_DOWN = 0x31,
+ PREVIOUS_CHANNEL = 0x32,
+ SOUND_SELECT = 0x33,
+ INPUT_SELECT = 0x34,
+ DISPLAY_INFORMATION = 0x35,
+ HELP = 0x36,
+ PAGE_UP = 0x37,
+ PAGE_DOWN = 0x38,
+ POWER = 0x40,
+ VOLUME_UP = 0x41,
+ VOLUME_DOWN = 0x42,
+ MUTE = 0x43,
+ PLAY = 0x44,
+ STOP = 0x45,
+ PAUSE = 0x46,
+ RECORD = 0x47,
+ REWIND = 0x48,
+ FAST_FORWARD = 0x49,
+ EJECT = 0x4A,
+ SKIP_FORWARD = 0x4B,
+ SKIP_BACKWARD = 0x4C,
+ STOP_RECORD = 0x4D,
+ PAUSE_RECORD = 0x4E,
+ ANGLE = 0x50,
+ SUB_PICTURE = 0x51,
+ VIDEO_ON_DEMAND = 0x52,
+ ELECTRONIC_PROGRAM_GUIDE = 0x53,
+ TIMER_PROGRAMMING = 0x54,
+ INITIAL_CONFIGURATION = 0x55,
+ SELECT_BROADCAST_TYPE = 0x56,
+ SELECT_SOUND_PRESENTATION = 0x57,
+ AUDIO_DESCRIPTION = 0x58,
+ INTERNET = 0x59,
+ THREE_DIMENSIONAL_MODE = 0x5A,
+ PLAY_FUNCTION = 0x60,
+ PAUSE_PLAY_FUNCTION = 0x61,
+ RECORD_FUNCTION = 0x62,
+ PAUSE_RECORD_FUNCTION = 0x63,
+ STOP_FUNCTION = 0x64,
+ MUTE_FUNCTION = 0x65,
+ RESTORE_VOLUME_FUNCTION = 0x66,
+ TUNE_FUNCTION = 0x67,
+ SELECT_MEDIA_FUNCTION = 0x68,
+ SELECT_AV_INPUT_FUNCTION = 0x69,
+ SELECT_AUDIO_INPUT_FUNCTION = 0x6A,
+ POWER_TOGGLE_FUNCTION = 0x6B,
+ POWER_OFF_FUNCTION = 0x6C,
+ POWER_ON_FUNCTION = 0x6D,
+ F1 = 0x71, // BLUE
+ F2 = 0x72, // RED
+ F3 = 0x73, // GREEN
+ F4 = 0x74, // YELLOW
+ F5 = 0x75,
+ DATA = 0x76,
+};
+
+/**
+ * HDMI port type.
+ */
+enum HdmiPortType : int32_t {
+ INPUT = 0,
+ OUTPUT = 1,
+};
+
+/**
+ * Options used for IHdmiCec.setOption()
+ */
+enum OptionKey : int32_t {
+ /**
+ * When set to false, HAL does not wake up the system upon receiving <Image
+ * View On> or <Text View On>. Used when user changes the TV settings to
+ * disable the auto TV on functionality.
+ * Deprecated since <Image View On> and <Text View On> become mandatory
+ * featrues for CEC device. Use ENABLE_CEC OptionKey to disable CEC
+ * functionality instead.
+ * True by Default
+ */
+ WAKEUP = 1,
+
+ /**
+ * When set to false, all the CEC commands are discarded. if logical address
+ * is ever used, it shall be released. Used when user changes the TV
+ * settings to disable CEC functionality.
+ * True by default.
+ *
+ */
+ ENABLE_CEC = 2,
+
+ /**
+ * Setting this flag to false means Android system must stop handling CEC
+ * service and yield the control over to the microprocessor that is powered
+ * on through the standby mode.The microprocessor shall keep current logical
+ * and physical address. It shall response POLLING_MESSAGE, GIVE_FEATURES,
+ * GIVE_DEVICE_POWER_STATUS,GIVE_DEVICE_VENDOR_ID and GIVE_PHYSICAL_ADDRESS
+ * to allow other CEC devices to build CEC devices map specified in CEC
+ * section 11.3 of the CEC spec 2.0b.
+ * When set to true, the system must gain the control over, hence telling
+ * the microprocessor to start forwarding CEC messages to Android system.
+ * For example, this may be called when system goes in and out of
+ * standby mode to notify the microprocessor that it should start/stop
+ * handling CEC commands on behalf of the system.
+ * True by default.
+ */
+ SYSTEM_CEC_CONTROL = 3,
+
+ /* Option 4 not used */
+};
+
+/**
+ * Hdmi port ID.
+ *
+ * It shall start from 1 which corresponds to HDMI "port 1".
+ */
+typedef uint32_t HdmiPortId;
+
+/** Hdmi hotplug event */
+struct HotplugEvent {
+ bool connected;
+ HdmiPortId portId;
+};
+
+/**
+ * HDMI port descriptor
+ */
+struct HdmiPortInfo {
+ HdmiPortType type;
+ HdmiPortId portId;
+ bool cecSupported;
+ bool arcSupported;
+ CecPhysicalAddress physicalAddress;
+};
+
+enum Result : int32_t {
+ SUCCESS = 0,
+ FAILURE_UNKNOWN = 1,
+ FAILURE_INVALID_ARGS = 2,
+ FAILURE_INVALID_STATE = 3,
+ FAILURE_NOT_SUPPORTED = 4,
+ FAILURE_BUSY = 5,
+};
diff --git a/wifi/hostapd/1.0/vts/OWNERS b/wifi/hostapd/1.0/vts/OWNERS
new file mode 100644
index 0000000..8bfb148
--- /dev/null
+++ b/wifi/hostapd/1.0/vts/OWNERS
@@ -0,0 +1,2 @@
+rpius@google.com
+etancohen@google.com
diff --git a/wifi/hostapd/1.0/vts/functional/Android.bp b/wifi/hostapd/1.0/vts/functional/Android.bp
index 79c5183..93867d2 100644
--- a/wifi/hostapd/1.0/vts/functional/Android.bp
+++ b/wifi/hostapd/1.0/vts/functional/Android.bp
@@ -24,6 +24,7 @@
static_libs: [
"VtsHalWifiV1_0TargetTestUtil",
"android.hardware.wifi.hostapd@1.0",
+ "android.hardware.wifi.hostapd@1.1",
"android.hardware.wifi@1.0",
"libcrypto",
"libgmock",
@@ -43,6 +44,7 @@
"VtsHalWifiV1_0TargetTestUtil",
"VtsHalWifiHostapdV1_0TargetTestUtil",
"android.hardware.wifi.hostapd@1.0",
+ "android.hardware.wifi.hostapd@1.1",
"android.hardware.wifi@1.0",
"libcrypto",
"libgmock",
diff --git a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test.cpp b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test.cpp
index 504f4c8..fa780f9 100644
--- a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test.cpp
+++ b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test.cpp
@@ -138,9 +138,11 @@
* Access point creation should pass.
*/
TEST_F(HostapdHidlTest, AddPskAccessPointWithAcs) {
- auto status = HIDL_INVOKE(hostapd_, addAccessPoint, getIfaceParamsWithAcs(),
- getPskNwParams());
- EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
+ if (!is_1_1(hostapd_)) {
+ auto status = HIDL_INVOKE(hostapd_, addAccessPoint,
+ getIfaceParamsWithAcs(), getPskNwParams());
+ EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
+ }
}
/**
@@ -148,9 +150,11 @@
* Access point creation should pass.
*/
TEST_F(HostapdHidlTest, AddOpenAccessPointWithAcs) {
- auto status = HIDL_INVOKE(hostapd_, addAccessPoint, getIfaceParamsWithAcs(),
- getOpenNwParams());
- EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
+ if (!is_1_1(hostapd_)) {
+ auto status = HIDL_INVOKE(hostapd_, addAccessPoint,
+ getIfaceParamsWithAcs(), getOpenNwParams());
+ EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
+ }
}
/**
@@ -158,9 +162,11 @@
* Access point creation should pass.
*/
TEST_F(HostapdHidlTest, AddPskAccessPointWithoutAcs) {
- auto status = HIDL_INVOKE(hostapd_, addAccessPoint,
- getIfaceParamsWithoutAcs(), getPskNwParams());
- EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
+ if (!is_1_1(hostapd_)) {
+ auto status = HIDL_INVOKE(hostapd_, addAccessPoint,
+ getIfaceParamsWithoutAcs(), getPskNwParams());
+ EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
+ }
}
/**
@@ -168,9 +174,12 @@
* Access point creation should pass.
*/
TEST_F(HostapdHidlTest, AddOpenAccessPointWithoutAcs) {
- auto status = HIDL_INVOKE(hostapd_, addAccessPoint,
- getIfaceParamsWithoutAcs(), getOpenNwParams());
- EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
+ if (!is_1_1(hostapd_)) {
+ auto status =
+ HIDL_INVOKE(hostapd_, addAccessPoint, getIfaceParamsWithoutAcs(),
+ getOpenNwParams());
+ EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
+ }
}
/**
@@ -178,12 +187,14 @@
* Access point creation & removal should pass.
*/
TEST_F(HostapdHidlTest, RemoveAccessPointWithAcs) {
- auto status = HIDL_INVOKE(hostapd_, addAccessPoint, getIfaceParamsWithAcs(),
- getPskNwParams());
- EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
- status =
- HIDL_INVOKE(hostapd_, removeAccessPoint, getPrimaryWlanIfaceName());
- EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
+ if (!is_1_1(hostapd_)) {
+ auto status = HIDL_INVOKE(hostapd_, addAccessPoint,
+ getIfaceParamsWithAcs(), getPskNwParams());
+ EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
+ status =
+ HIDL_INVOKE(hostapd_, removeAccessPoint, getPrimaryWlanIfaceName());
+ EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
+ }
}
/**
@@ -191,12 +202,14 @@
* Access point creation & removal should pass.
*/
TEST_F(HostapdHidlTest, RemoveAccessPointWithoutAcs) {
- auto status = HIDL_INVOKE(hostapd_, addAccessPoint,
- getIfaceParamsWithoutAcs(), getPskNwParams());
- EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
- status =
- HIDL_INVOKE(hostapd_, removeAccessPoint, getPrimaryWlanIfaceName());
- EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
+ if (!is_1_1(hostapd_)) {
+ auto status = HIDL_INVOKE(hostapd_, addAccessPoint,
+ getIfaceParamsWithoutAcs(), getPskNwParams());
+ EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
+ status =
+ HIDL_INVOKE(hostapd_, removeAccessPoint, getPrimaryWlanIfaceName());
+ EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
+ }
}
/**
@@ -204,10 +217,12 @@
* Access point creation should fail.
*/
TEST_F(HostapdHidlTest, AddPskAccessPointWithInvalidChannel) {
- auto status =
- HIDL_INVOKE(hostapd_, addAccessPoint,
- getIfaceParamsWithInvalidChannel(), getPskNwParams());
- EXPECT_NE(HostapdStatusCode::SUCCESS, status.code);
+ if (!is_1_1(hostapd_)) {
+ auto status =
+ HIDL_INVOKE(hostapd_, addAccessPoint,
+ getIfaceParamsWithInvalidChannel(), getPskNwParams());
+ EXPECT_NE(HostapdStatusCode::SUCCESS, status.code);
+ }
}
/**
@@ -215,10 +230,12 @@
* Access point creation should fail.
*/
TEST_F(HostapdHidlTest, AddInvalidPskAccessPointWithoutAcs) {
- auto status =
- HIDL_INVOKE(hostapd_, addAccessPoint, getIfaceParamsWithoutAcs(),
- getInvalidPskNwParams());
- EXPECT_NE(HostapdStatusCode::SUCCESS, status.code);
+ if (!is_1_1(hostapd_)) {
+ auto status =
+ HIDL_INVOKE(hostapd_, addAccessPoint, getIfaceParamsWithoutAcs(),
+ getInvalidPskNwParams());
+ EXPECT_NE(HostapdStatusCode::SUCCESS, status.code);
+ }
}
/*
diff --git a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.cpp b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.cpp
index e5ba8ef..22dbb52 100644
--- a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.cpp
+++ b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.cpp
@@ -130,6 +130,12 @@
ASSERT_TRUE(notification_listener->waitForHidlService(200, service_name));
}
+bool is_1_1(const sp<IHostapd>& hostapd) {
+ sp<::android::hardware::wifi::hostapd::V1_1::IHostapd> hostapd_1_1 =
+ ::android::hardware::wifi::hostapd::V1_1::IHostapd::castFrom(hostapd);
+ return hostapd_1_1.get() != nullptr;
+}
+
sp<IHostapd> getHostapd() {
return ::testing::VtsHalHidlTargetTestBase::getService<IHostapd>(
gEnv->getServiceName<IHostapd>());
diff --git a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.h b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.h
index 1b92477..8e2f1a3 100644
--- a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.h
+++ b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.h
@@ -18,6 +18,7 @@
#define HOSTAPD_HIDL_TEST_UTILS_H
#include <android/hardware/wifi/hostapd/1.0/IHostapd.h>
+#include <android/hardware/wifi/hostapd/1.1/IHostapd.h>
#include <VtsHalHidlTargetTestEnvBase.h>
@@ -34,6 +35,8 @@
// These helper functions should be modified to return vectors if we support
// multiple instances.
android::sp<android::hardware::wifi::hostapd::V1_0::IHostapd> getHostapd();
+bool is_1_1(const android::sp<android::hardware::wifi::hostapd::V1_0::IHostapd>&
+ hostapd);
class WifiHostapdHidlEnvironment
: public ::testing::VtsHalHidlTargetTestEnvBase {
diff --git a/wifi/hostapd/1.1/vts/OWNERS b/wifi/hostapd/1.1/vts/OWNERS
new file mode 100644
index 0000000..8bfb148
--- /dev/null
+++ b/wifi/hostapd/1.1/vts/OWNERS
@@ -0,0 +1,2 @@
+rpius@google.com
+etancohen@google.com
diff --git a/wifi/hostapd/1.1/vts/functional/Android.bp b/wifi/hostapd/1.1/vts/functional/Android.bp
new file mode 100644
index 0000000..bbf5246
--- /dev/null
+++ b/wifi/hostapd/1.1/vts/functional/Android.bp
@@ -0,0 +1,58 @@
+//
+// Copyright (C) 2019 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.
+//
+
+cc_library_static {
+ name: "VtsHalWifiHostapdV1_1TargetTestUtil",
+ defaults: ["VtsHalTargetTestDefaults"],
+ srcs: ["hostapd_hidl_test_utils_1_1.cpp"],
+ export_include_dirs: [
+ "."
+ ],
+ static_libs: [
+ "VtsHalWifiV1_0TargetTestUtil",
+ "VtsHalWifiHostapdV1_0TargetTestUtil",
+ "android.hardware.wifi.hostapd@1.0",
+ "android.hardware.wifi.hostapd@1.1",
+ "android.hardware.wifi@1.0",
+ "libcrypto",
+ "libgmock",
+ "libwifi-system",
+ "libwifi-system-iface",
+ ],
+}
+
+cc_test {
+ name: "VtsHalWifiHostapdV1_1TargetTest",
+ defaults: ["VtsHalTargetTestDefaults"],
+ srcs: [
+ "VtsHalWifiHostapdV1_1TargetTest.cpp",
+ "hostapd_hidl_test.cpp",
+ ],
+ static_libs: [
+ "VtsHalWifiV1_0TargetTestUtil",
+ "VtsHalWifiHostapdV1_0TargetTestUtil",
+ "VtsHalWifiHostapdV1_1TargetTestUtil",
+ "android.hardware.wifi.hostapd@1.0",
+ "android.hardware.wifi.hostapd@1.1",
+ "android.hardware.wifi@1.0",
+ "libcrypto",
+ "libgmock",
+ "libwifi-system",
+ "libwifi-system-iface",
+ ],
+ test_suites: ["general-tests"],
+}
+
diff --git a/wifi/hostapd/1.1/vts/functional/VtsHalWifiHostapdV1_1TargetTest.cpp b/wifi/hostapd/1.1/vts/functional/VtsHalWifiHostapdV1_1TargetTest.cpp
new file mode 100644
index 0000000..6916db2
--- /dev/null
+++ b/wifi/hostapd/1.1/vts/functional/VtsHalWifiHostapdV1_1TargetTest.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#include <android-base/logging.h>
+#include <android/hardware/wifi/1.0/IWifi.h>
+
+#include "hostapd_hidl_test_utils.h"
+#include "hostapd_hidl_test_utils_1_1.h"
+
+class WifiHostapdHidlEnvironment_1_1 : public WifiHostapdHidlEnvironment {
+ public:
+ // get the test environment singleton
+ static WifiHostapdHidlEnvironment_1_1* Instance() {
+ static WifiHostapdHidlEnvironment_1_1* instance =
+ new WifiHostapdHidlEnvironment_1_1;
+ return instance;
+ }
+
+ virtual void registerTestServices() override {
+ registerTestService<::android::hardware::wifi::V1_0::IWifi>();
+ registerTestService<android::hardware::wifi::hostapd::V1_0::IHostapd>();
+ registerTestService<android::hardware::wifi::hostapd::V1_1::IHostapd>();
+ }
+
+ private:
+ WifiHostapdHidlEnvironment_1_1() {}
+};
+
+WifiHostapdHidlEnvironment* gEnv = WifiHostapdHidlEnvironment_1_1::Instance();
+
+int main(int argc, char** argv) {
+ ::testing::AddGlobalTestEnvironment(gEnv);
+ ::testing::InitGoogleTest(&argc, argv);
+ gEnv->init(&argc, argv);
+ int status = RUN_ALL_TESTS();
+ LOG(INFO) << "Test result = " << status;
+ return status;
+}
diff --git a/wifi/hostapd/1.1/vts/functional/hostapd_hidl_test.cpp b/wifi/hostapd/1.1/vts/functional/hostapd_hidl_test.cpp
new file mode 100644
index 0000000..d1af655
--- /dev/null
+++ b/wifi/hostapd/1.1/vts/functional/hostapd_hidl_test.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#include <android-base/logging.h>
+#include <cutils/properties.h>
+
+#include <VtsHalHidlTargetTestBase.h>
+
+#include <android/hardware/wifi/hostapd/1.1/IHostapd.h>
+
+#include "hostapd_hidl_call_util.h"
+#include "hostapd_hidl_test_utils.h"
+#include "hostapd_hidl_test_utils_1_1.h"
+
+using ::android::sp;
+using ::android::hardware::hidl_string;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::wifi::hostapd::V1_0::HostapdStatus;
+using ::android::hardware::wifi::hostapd::V1_0::HostapdStatusCode;
+using ::android::hardware::wifi::hostapd::V1_1::IHostapd;
+using ::android::hardware::wifi::hostapd::V1_1::IHostapdCallback;
+
+class HostapdHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+ public:
+ virtual void SetUp() override {
+ startHostapdAndWaitForHidlService();
+ hostapd_ = getHostapd_1_1();
+ ASSERT_NE(hostapd_.get(), nullptr);
+ }
+
+ virtual void TearDown() override { stopHostapd(); }
+
+ protected:
+ // IHostapd object used for all tests in this fixture.
+ sp<IHostapd> hostapd_;
+};
+
+class IfaceCallback : public IHostapdCallback {
+ Return<void> onFailure(
+ const hidl_string& /* Name of the interface */) override {
+ return Void();
+ }
+};
+
+/*
+ * RegisterCallback
+ */
+TEST_F(HostapdHidlTest, registerCallback) {
+ hostapd_->registerCallback(
+ new IfaceCallback(), [](const HostapdStatus& status) {
+ EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
+ });
+}
diff --git a/wifi/hostapd/1.1/vts/functional/hostapd_hidl_test_utils_1_1.cpp b/wifi/hostapd/1.1/vts/functional/hostapd_hidl_test_utils_1_1.cpp
new file mode 100644
index 0000000..8bb72a1
--- /dev/null
+++ b/wifi/hostapd/1.1/vts/functional/hostapd_hidl_test_utils_1_1.cpp
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#include <VtsHalHidlTargetTestBase.h>
+#include <android-base/logging.h>
+
+#include "hostapd_hidl_test_utils.h"
+#include "hostapd_hidl_test_utils_1_1.h"
+
+using ::android::sp;
+using ::android::hardware::wifi::hostapd::V1_1::IHostapd;
+
+sp<IHostapd> getHostapd_1_1() { return IHostapd::castFrom(getHostapd()); }
diff --git a/wifi/hostapd/1.1/vts/functional/hostapd_hidl_test_utils_1_1.h b/wifi/hostapd/1.1/vts/functional/hostapd_hidl_test_utils_1_1.h
new file mode 100644
index 0000000..c43ddfa
--- /dev/null
+++ b/wifi/hostapd/1.1/vts/functional/hostapd_hidl_test_utils_1_1.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#ifndef HOSTAPD_HIDL_TEST_UTILS_1_1_H
+#define HOSTAPD_HIDL_TEST_UTILS_1_1_H
+
+#include <android/hardware/wifi/hostapd/1.1/IHostapd.h>
+
+#include <VtsHalHidlTargetTestEnvBase.h>
+
+// Helper functions to obtain references to the various HIDL interface objects.
+// Note: We only have a single instance of each of these objects currently.
+// These helper functions should be modified to return vectors if we support
+// multiple instances.
+android::sp<android::hardware::wifi::hostapd::V1_1::IHostapd> getHostapd_1_1();
+
+#endif /* HOSTAPD_HIDL_TEST_UTILS_1_1_H */