From 93594abef30dc2bf17ce0478c01d5585f1272ca3 Mon Sep 17 00:00:00 2001 From: Changyeon Jo Date: Mon, 17 Feb 2020 13:28:56 -0800 Subject: [PATCH] Add the camera extended info getter/setter methods This change declares and implement newer version of methods to manage vendor-defined camera extended information. Bug: 142888670 Test: m -j android.hardware.automotive.evs@1.1-service Change-Id: If6baf9cea7eefd13fd269ca8bb5af715cc3a8bab Signed-off-by: Changyeon Jo --- automotive/evs/1.1/IEvsCamera.hal | 37 +++++++++++++++++++ automotive/evs/1.1/default/EvsCamera.cpp | 21 +++++++++++ automotive/evs/1.1/default/EvsCamera.h | 4 ++ .../functional/VtsHalEvsV1_1TargetTest.cpp | 11 ++++++ 4 files changed, 73 insertions(+) diff --git a/automotive/evs/1.1/IEvsCamera.hal b/automotive/evs/1.1/IEvsCamera.hal index fc68e60a1e..38e6c4242c 100644 --- a/automotive/evs/1.1/IEvsCamera.hal +++ b/automotive/evs/1.1/IEvsCamera.hal @@ -178,4 +178,41 @@ interface IEvsCamera extends @1.0::IEvsCamera { * values as backing camera devices. */ getIntParameter(CameraParam id) generates(EvsResult result, vec value); + + /** + * Request driver specific information from the HAL implementation. + * + * The values allowed for opaqueIdentifier are driver specific, + * but no value passed in may crash the driver. The driver should + * return EvsResult::INVALID_ARG for any unrecognized opaqueIdentifier. + * + * @param opaqueIdentifier An unique identifier of the information to + * request. + * @return result EvsResult::OK if the driver recognizes a given + * identifier. + * EvsResult::INVALID_ARG, otherwise. + * @return value Requested information. Zero-size vector is + * returned if the driver does not recognize a + * given identifier. + */ + getExtendedInfo_1_1(uint32_t opaqueIdentifier) + generates (EvsResult result, vec value); + + /** + * Send a driver specific value to the HAL implementation. + * + * This extension is provided to facilitate car specific + * extensions, but no HAL implementation may require this call + * in order to function in a default state. + * INVALID_ARG is returned if the opaqueValue is not meaningful to + * the driver implementation. + * + * @param opaqueIdentifier An unique identifier of the information to + * program. + * opaqueValue A value to program. + * @return result EvsResult::OK is returned if this call is successful. + * EvsResult::INVALID_ARG, otherwise. + */ + setExtendedInfo_1_1(uint32_t opaqueIdentifier, vec opaqueValue) + generates (EvsResult result); }; diff --git a/automotive/evs/1.1/default/EvsCamera.cpp b/automotive/evs/1.1/default/EvsCamera.cpp index f9cdb881d8..5196c9532b 100644 --- a/automotive/evs/1.1/default/EvsCamera.cpp +++ b/automotive/evs/1.1/default/EvsCamera.cpp @@ -334,6 +334,27 @@ Return EvsCamera::getIntParameter(CameraParam id, } +Return EvsCamera::setExtendedInfo_1_1(uint32_t opaqueIdentifier, + const hidl_vec& opaqueValue) { + // Default implementation does not use an extended info. + (void)opaqueIdentifier; + (void)opaqueValue; + return EvsResult::INVALID_ARG; +} + + +Return EvsCamera::getExtendedInfo_1_1(uint32_t opaqueIdentifier, + getExtendedInfo_1_1_cb _hidl_cb) { + // Default implementation does not use an extended info. + (void)opaqueIdentifier; + + hidl_vec value; + _hidl_cb(EvsResult::INVALID_ARG, value); + return Void(); +} + + + bool EvsCamera::setAvailableFrames_Locked(unsigned bufferCount) { if (bufferCount < 1) { ALOGE("Ignoring request to set buffer count to zero"); diff --git a/automotive/evs/1.1/default/EvsCamera.h b/automotive/evs/1.1/default/EvsCamera.h index a49db46521..0fa83b428d 100644 --- a/automotive/evs/1.1/default/EvsCamera.h +++ b/automotive/evs/1.1/default/EvsCamera.h @@ -78,6 +78,10 @@ public: setIntParameter_cb _hidl_cb) override; Return getIntParameter(CameraParam id, getIntParameter_cb _hidl_cb) override; + Return setExtendedInfo_1_1(uint32_t opaqueIdentifier, + const hidl_vec& opaqueValue) override; + Return getExtendedInfo_1_1(uint32_t opaqueIdentifier, + getExtendedInfo_1_1_cb _hidl_cb) override; static sp Create(const char *deviceName); static sp Create(const char *deviceName, diff --git a/automotive/evs/1.1/vts/functional/VtsHalEvsV1_1TargetTest.cpp b/automotive/evs/1.1/vts/functional/VtsHalEvsV1_1TargetTest.cpp index ce02973ac2..2c8c1e1d15 100644 --- a/automotive/evs/1.1/vts/functional/VtsHalEvsV1_1TargetTest.cpp +++ b/automotive/evs/1.1/vts/functional/VtsHalEvsV1_1TargetTest.cpp @@ -296,6 +296,17 @@ TEST_F(EvsHidlTest, CameraOpenClean) { } ); + // Verify methods for extended info + const auto id = 0xFFFFFFFF; // meaningless id + hidl_vec values; + auto err = pCam->setExtendedInfo_1_1(id, values); + ASSERT_EQ(EvsResult::INVALID_ARG, err); + + pCam->getExtendedInfo_1_1(id, [](const auto& result, const auto& data) { + ASSERT_EQ(EvsResult::INVALID_ARG, result); + ASSERT_EQ(0, data.size()); + }); + // Explicitly close the camera so resources are released right away pEnumerator->closeCamera(pCam); }