aboutsummaryrefslogtreecommitdiffstats
path: root/evs
diff options
context:
space:
mode:
authorChangyeon Jo <changyeon@google.com>2020-06-07 11:08:19 -0700
committerChangyeon Jo <changyeon@google.com>2020-06-08 16:49:25 -0700
commit386f369fddec8408498c6ed45b8fffd78edb5560 (patch)
tree398111547450ef53be7edc7f86d656d1bb1f41b0 /evs
parent1a7883fd9604078ae6df7a53dbc97aacd45381f6 (diff)
downloadplatform_packages_services_Car-386f369fddec8408498c6ed45b8fffd78edb5560.tar.gz
platform_packages_services_Car-386f369fddec8408498c6ed45b8fffd78edb5560.tar.bz2
platform_packages_services_Car-386f369fddec8408498c6ed45b8fffd78edb5560.zip
Retrieves v4l2 camera controls from the device
This CL modifies a reference EVS HAL implementation to retrieve a list of available camera controls from the device in run-time instead of using a static parameter list from the configuration file. Fix: 149311708 Test: Runs /vendor/bin/android.hardware.automotive.evs@1.1-sample and programs camera controls Change-Id: I8c2b4650f12b7cf9e328980c5718d344efa76000
Diffstat (limited to 'evs')
-rw-r--r--evs/sampleDriver/EvsV4lCamera.cpp9
-rw-r--r--evs/sampleDriver/EvsV4lCamera.h2
-rw-r--r--evs/sampleDriver/VideoCapture.cpp23
-rw-r--r--evs/sampleDriver/VideoCapture.h6
4 files changed, 33 insertions, 7 deletions
diff --git a/evs/sampleDriver/EvsV4lCamera.cpp b/evs/sampleDriver/EvsV4lCamera.cpp
index fdb893775..cd2a3a4ee 100644
--- a/evs/sampleDriver/EvsV4lCamera.cpp
+++ b/evs/sampleDriver/EvsV4lCamera.cpp
@@ -863,11 +863,7 @@ bool EvsV4lCamera::convertToV4l2CID(CameraParam id, uint32_t& v4l2cid) {
return false;
}
- if (mCameraInfo != nullptr) {
- return mCameraInfo->controls.find(id) != mCameraInfo->controls.end();
- } else {
- return false;
- }
+ return mCameraControls.find(v4l2cid) != mCameraControls.end();
}
@@ -939,6 +935,9 @@ sp<EvsV4lCamera> EvsV4lCamera::Create(const char *deviceName,
}
}
+ // List available camera parameters
+ evsCamera->mCameraControls = evsCamera->mVideo.enumerateCameraControls();
+
// Please note that the buffer usage flag does not come from a given stream
// configuration.
evsCamera->mUsage = GRALLOC_USAGE_HW_TEXTURE |
diff --git a/evs/sampleDriver/EvsV4lCamera.h b/evs/sampleDriver/EvsV4lCamera.h
index c5b15a953..90cde5710 100644
--- a/evs/sampleDriver/EvsV4lCamera.h
+++ b/evs/sampleDriver/EvsV4lCamera.h
@@ -135,6 +135,8 @@ private:
unsigned mFramesAllowed; // How many buffers are we currently using
unsigned mFramesInUse; // How many buffers are currently outstanding
+ std::set<uint32_t> mCameraControls; // Available camera controls
+
// Which format specific function we need to use to move camera imagery into our output buffers
void(*mFillBufferFromVideo)(const BufferDesc& tgtBuff, uint8_t* tgt,
void* imgData, unsigned imgStride);
diff --git a/evs/sampleDriver/VideoCapture.cpp b/evs/sampleDriver/VideoCapture.cpp
index 070e33fa0..9663bf694 100644
--- a/evs/sampleDriver/VideoCapture.cpp
+++ b/evs/sampleDriver/VideoCapture.cpp
@@ -323,3 +323,26 @@ int VideoCapture::getParameter(v4l2_control& control) {
return status;
}
+
+
+std::set<uint32_t> VideoCapture::enumerateCameraControls() {
+ // Retrieve available camera controls
+ struct v4l2_queryctrl ctrl = {
+ .id = V4L2_CTRL_FLAG_NEXT_CTRL
+ };
+
+ std::set<uint32_t> ctrlIDs;
+ while (0 == ioctl(mDeviceFd, VIDIOC_QUERYCTRL, &ctrl)) {
+ if (!(ctrl.flags & V4L2_CTRL_FLAG_DISABLED)) {
+ ctrlIDs.emplace(ctrl.id);
+ }
+
+ ctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL;
+ }
+
+ if (errno != EINVAL) {
+ PLOG(WARNING) << "Failed to run VIDIOC_QUERYCTRL";
+ }
+
+ return std::move(ctrlIDs);
+}
diff --git a/evs/sampleDriver/VideoCapture.h b/evs/sampleDriver/VideoCapture.h
index e205c36fd..42a5ef46c 100644
--- a/evs/sampleDriver/VideoCapture.h
+++ b/evs/sampleDriver/VideoCapture.h
@@ -17,10 +17,11 @@
#define ANDROID_HARDWARE_AUTOMOTIVE_EVS_V1_1_VIDEOCAPTURE_H
#include <atomic>
-#include <thread>
#include <functional>
-#include <linux/videodev2.h>
+#include <set>
+#include <thread>
+#include <linux/videodev2.h>
typedef v4l2_buffer imageBuffer;
@@ -49,6 +50,7 @@ public:
int setParameter(struct v4l2_control& control);
int getParameter(struct v4l2_control& control);
+ std::set<uint32_t> enumerateCameraControls();
private:
void collectFrames();