mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-02 13:49:45 +00:00
Merge "Update the default EVS HAL implementation" into main
This commit is contained in:
@@ -60,12 +60,15 @@ cc_binary {
|
||||
"libyuv",
|
||||
],
|
||||
static_libs: [
|
||||
"android.frameworks.automotive.display-V1-ndk",
|
||||
"android.frameworks.automotive.display-V2-ndk",
|
||||
"android.hardware.automotive.evs-V2-ndk",
|
||||
"android.hardware.common-V2-ndk",
|
||||
"libaidlcommonsupport",
|
||||
"libcutils",
|
||||
],
|
||||
header_libs: [
|
||||
"libgui_aidl_headers",
|
||||
],
|
||||
local_include_dirs: ["include"],
|
||||
include_dirs: ["frameworks/native/include/"],
|
||||
required: ["evs_mock_hal_configuration.xml"],
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <aidl/android/hardware/automotive/evs/IEvsCamera.h>
|
||||
#include <aidl/android/hardware/automotive/evs/IEvsEnumeratorStatusCallback.h>
|
||||
#include <aidl/android/hardware/automotive/evs/Stream.h>
|
||||
#include <android-base/thread_annotations.h>
|
||||
#include <utils/Thread.h>
|
||||
|
||||
#include <atomic>
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <aidl/android/hardware/automotive/evs/BufferDesc.h>
|
||||
#include <aidl/android/hardware/automotive/evs/DisplayDesc.h>
|
||||
#include <aidl/android/hardware/automotive/evs/DisplayState.h>
|
||||
#include <android-base/thread_annotations.h>
|
||||
|
||||
#include <thread>
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <aidl/android/frameworks/automotive/display/ICarDisplayProxy.h>
|
||||
#include <aidl/android/hardware/automotive/evs/BufferDesc.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <bufferqueueconverter/BufferQueueConverter.h>
|
||||
#include <cutils/native_handle.h>
|
||||
|
||||
namespace aidl::android::hardware::automotive::evs::implementation {
|
||||
|
||||
@@ -33,7 +33,6 @@ namespace automotivedisplay = ::aidl::android::frameworks::automotive::display;
|
||||
|
||||
class GlWrapper {
|
||||
public:
|
||||
GlWrapper() : mSurfaceHolder(::android::SurfaceHolderUniquePtr(nullptr, nullptr)) {}
|
||||
bool initialize(const std::shared_ptr<automotivedisplay::ICarDisplayProxy>& svc,
|
||||
uint64_t displayId);
|
||||
void shutdown();
|
||||
@@ -53,9 +52,6 @@ class GlWrapper {
|
||||
unsigned getHeight() { return mHeight; };
|
||||
|
||||
private:
|
||||
::android::sp<::android::hardware::graphics::bufferqueue::V2_0::IGraphicBufferProducer>
|
||||
mGfxBufferProducer;
|
||||
|
||||
EGLDisplay mDisplay;
|
||||
EGLSurface mSurface;
|
||||
EGLContext mContext;
|
||||
@@ -71,9 +67,6 @@ class GlWrapper {
|
||||
// Opaque handle for a native hardware buffer defined in
|
||||
// frameworks/native/opengl/include/EGL/eglplatform.h
|
||||
ANativeWindow* mWindow;
|
||||
|
||||
// Pointer to a Surface wrapper.
|
||||
::android::SurfaceHolderUniquePtr mSurfaceHolder;
|
||||
};
|
||||
|
||||
} // namespace aidl::android::hardware::automotive::evs::implementation
|
||||
|
||||
@@ -352,8 +352,8 @@ ScopedAStatus EvsGlDisplay::getTargetBuffer(BufferDesc* _aidl_return) {
|
||||
BufferDesc bufferDescToSend = {
|
||||
.buffer =
|
||||
{
|
||||
.handle = std::move(::android::dupToAidl(mBuffer.handle)),
|
||||
.description = mBuffer.description,
|
||||
.handle = std::move(::android::dupToAidl(mBuffer.handle)),
|
||||
},
|
||||
.pixelSizeBytes = 4, // RGBA_8888 is 4-byte-per-pixel format
|
||||
.bufferId = mBuffer.fingerprint,
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <aidl/android/frameworks/automotive/display/DisplayDesc.h>
|
||||
#include <aidl/android/hardware/graphics/common/HardwareBufferDescription.h>
|
||||
#include <aidlcommonsupport/NativeHandle.h>
|
||||
#include <gui/view/Surface.h>
|
||||
#include <ui/DisplayMode.h>
|
||||
#include <ui/DisplayState.h>
|
||||
#include <ui/GraphicBuffer.h>
|
||||
@@ -183,20 +184,6 @@ GLuint buildShaderProgram(const char* vtxSrc, const char* pxlSrc) {
|
||||
return program;
|
||||
}
|
||||
|
||||
::android::sp<HGraphicBufferProducer> convertNativeHandleToHGBP(const NativeHandle& aidlHandle) {
|
||||
native_handle_t* handle = ::android::dupFromAidl(aidlHandle);
|
||||
if (handle->numFds != 0 || handle->numInts < std::ceil(sizeof(size_t) / sizeof(int))) {
|
||||
LOG(ERROR) << "Invalid native handle";
|
||||
return nullptr;
|
||||
}
|
||||
::android::hardware::hidl_vec<uint8_t> halToken;
|
||||
halToken.setToExternal(reinterpret_cast<uint8_t*>(const_cast<int*>(&(handle->data[1]))),
|
||||
handle->data[0]);
|
||||
::android::sp<HGraphicBufferProducer> hgbp =
|
||||
HGraphicBufferProducer::castFrom(::android::retrieveHalInterface(halToken));
|
||||
return std::move(hgbp);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace aidl::android::hardware::automotive::evs::implementation {
|
||||
@@ -226,30 +213,19 @@ bool GlWrapper::initialize(const std::shared_ptr<ICarDisplayProxy>& pWindowProxy
|
||||
}
|
||||
LOG(INFO) << "Display resolution is " << mWidth << "x" << mHeight;
|
||||
|
||||
NativeHandle aidlHandle;
|
||||
status = pWindowProxy->getHGraphicBufferProducer(displayId, &aidlHandle);
|
||||
aidl::android::view::Surface shimSurface;
|
||||
status = pWindowProxy->getSurface(displayId, &shimSurface);
|
||||
if (!status.isOk()) {
|
||||
LOG(ERROR) << "Failed to get IGraphicBufferProducer from ICarDisplayProxy.";
|
||||
LOG(ERROR) << "Failed to obtain the surface.";
|
||||
return false;
|
||||
}
|
||||
|
||||
mGfxBufferProducer = convertNativeHandleToHGBP(aidlHandle);
|
||||
if (!mGfxBufferProducer) {
|
||||
LOG(ERROR) << "Failed to convert a NativeHandle to HGBP.";
|
||||
return false;
|
||||
}
|
||||
|
||||
mSurfaceHolder = getSurfaceFromHGBP(mGfxBufferProducer);
|
||||
if (mSurfaceHolder == nullptr) {
|
||||
LOG(ERROR) << "Failed to get a Surface from HGBP.";
|
||||
return false;
|
||||
}
|
||||
|
||||
mWindow = getNativeWindow(mSurfaceHolder.get());
|
||||
mWindow = shimSurface.get();
|
||||
if (mWindow == nullptr) {
|
||||
LOG(ERROR) << "Failed to get a native window from Surface.";
|
||||
return false;
|
||||
}
|
||||
ANativeWindow_acquire(mWindow);
|
||||
|
||||
// Set up our OpenGL ES context associated with the default display
|
||||
mDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
@@ -350,7 +326,12 @@ void GlWrapper::shutdown() {
|
||||
mDisplay = EGL_NO_DISPLAY;
|
||||
|
||||
// Release the window
|
||||
mSurfaceHolder = nullptr;
|
||||
if (mWindow == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
ANativeWindow_release(mWindow);
|
||||
mWindow = nullptr;
|
||||
}
|
||||
|
||||
void GlWrapper::showWindow(const std::shared_ptr<ICarDisplayProxy>& pWindowProxy, uint64_t id) {
|
||||
|
||||
Reference in New Issue
Block a user