mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-23 12:35:33 -04:00
universal7885: libshims: overlay on CameraDevice::open()
Change-Id: Ie8dd056e74a620316e3bd9e97244aac1493b7e76 Signed-off-by: roynatech2544 <whiteshell2544@naver.com>
This commit is contained in:
parent
33c877f914
commit
e1227a4089
3 changed files with 109 additions and 2 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
## Patches needed
|
## Patches needed
|
||||||
|
|
||||||
- sed -i 's/_ZN7android8hardware6camera6device4V3_214implementation12CameraDevice24getCameraCharacteristicsENSt3__18functionIFvNS1_6common4V1_06StatusERKNS0_8hidl_vecIhEEEEE/_ZN7android8hardware6camera6device4V3_214implementation12CameraDevice24getEurekaCharacteristicsENSt3__18functionIFvNS1_6common4V1_06StatusERKNS0_8hidl_vecIhEEEEE/g' camera.device@3.2-impl.so
|
- sed -i 's/_ZN7android8hardware6camera6device4V3_214implementation12CameraDevice24getCameraCharacteristicsENSt3__18functionIFvNS1_6common4V1_06StatusERKNS0_8hidl_vecIhEEEEE/_ZN7android8hardware6camera6device4V3_214implementation12CameraDevice24getEurekaCharacteristicsENSt3__18functionIFvNS1_6common4V1_06StatusERKNS0_8hidl_vecIhEEEEE/g' camera.device@3.2-impl.so
|
||||||
|
- sed -i 's/_ZN7android8hardware6camera6device4V3_214implementation12CameraDevice4openERKNS_2spINS3_21ICameraDeviceCallbackEEENSt3__18functionIFvNS1_6common4V1_06StatusERKNS6_INS3_20ICameraDeviceSessionEEEEEE/_ZN7android8hardware6camera6device4V3_214implementation12CameraDevice4nukeERKNS_2spINS3_21ICameraDeviceCallbackEEENSt3__18functionIFvNS1_6common4V1_06StatusERKNS6_INS3_20ICameraDeviceSessionEEEEEE/g' camera.device@3.2-impl.so
|
||||||
- patchelf --add-needed libcorrectcamera.so camera.device@3.2-impl.so
|
- patchelf --add-needed libcorrectcamera.so camera.device@3.2-impl.so
|
||||||
|
|
||||||
## Camera IDs reported by Exynos camera module
|
## Camera IDs reported by Exynos camera module
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ struct CameraDevice : public virtual RefBase {
|
||||||
|
|
||||||
// Open the device HAL and also return a default capture session
|
// Open the device HAL and also return a default capture session
|
||||||
Return<void> open(const sp<ICameraDeviceCallback>& callback, ICameraDevice::open_cb _hidl_cb);
|
Return<void> open(const sp<ICameraDeviceCallback>& callback, ICameraDevice::open_cb _hidl_cb);
|
||||||
|
Return<void> nuke(const sp<ICameraDeviceCallback>& callback, ICameraDevice::open_cb _hidl_cb);
|
||||||
|
|
||||||
// Forward the dump call to the opened session, or do nothing
|
// Forward the dump call to the opened session, or do nothing
|
||||||
Return<void> dumpState(const ::android::hardware::hidl_handle& fd);
|
Return<void> dumpState(const ::android::hardware::hidl_handle& fd);
|
||||||
|
|
@ -97,6 +97,7 @@ protected:
|
||||||
|
|
||||||
const sp<CameraModule> mModule;
|
const sp<CameraModule> mModule;
|
||||||
const std::string mCameraId;
|
const std::string mCameraId;
|
||||||
|
std::string mCameraID;
|
||||||
// const after ctor
|
// const after ctor
|
||||||
int mCameraIdInt;
|
int mCameraIdInt;
|
||||||
int mDeviceVersion;
|
int mDeviceVersion;
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,112 @@ Return<void> CameraDevice::getEurekaCharacteristics(ICameraDevice::getCameraChar
|
||||||
return CameraDevice::getCameraCharacteristics(_hidl_cb);
|
return CameraDevice::getCameraCharacteristics(_hidl_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Return<void> CameraDevice::open(const sp<ICameraDeviceCallback>& callback,
|
||||||
|
ICameraDevice::open_cb _hidl_cb) {
|
||||||
|
Status status = initStatus();
|
||||||
|
sp<CameraDeviceSession> session = nullptr;
|
||||||
|
|
||||||
|
if (callback == nullptr) {
|
||||||
|
ALOGE("%s: cannot open camera %s. callback is null!",
|
||||||
|
__FUNCTION__, mCameraId.c_str());
|
||||||
|
_hidl_cb(Status::ILLEGAL_ARGUMENT, nullptr);
|
||||||
|
return Void();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status != Status::OK) {
|
||||||
|
// Provider will never pass initFailed device to client, so
|
||||||
|
// this must be a disconnected camera
|
||||||
|
ALOGE("%s: cannot open camera %s. camera is disconnected!",
|
||||||
|
__FUNCTION__, mCameraId.c_str());
|
||||||
|
_hidl_cb(Status::CAMERA_DISCONNECTED, nullptr);
|
||||||
|
return Void();
|
||||||
|
} else {
|
||||||
|
mLock.lock();
|
||||||
|
|
||||||
|
ALOGV("%s: Initializing device for camera %d", __FUNCTION__, mCameraIdInt);
|
||||||
|
session = mSession.promote();
|
||||||
|
if (session != nullptr && !session->isClosed()) {
|
||||||
|
ALOGE("%s: cannot open an already opened camera!", __FUNCTION__);
|
||||||
|
mLock.unlock();
|
||||||
|
_hidl_cb(Status::CAMERA_IN_USE, nullptr);
|
||||||
|
return Void();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Open HAL device */
|
||||||
|
status_t res;
|
||||||
|
camera3_device_t *device;
|
||||||
|
|
||||||
|
mCameraID = mCameraId;
|
||||||
|
if (mCameraIdInt == 1) mCameraIdInt = 2;
|
||||||
|
if (mCameraID == "1") mCameraID = "2";
|
||||||
|
|
||||||
|
res = mModule->open(mCameraID.c_str(),
|
||||||
|
reinterpret_cast<hw_device_t**>(&device));
|
||||||
|
if (res != OK) {
|
||||||
|
ALOGE("%s: cannot open camera %s!", __FUNCTION__, mCameraID.c_str());
|
||||||
|
mLock.unlock();
|
||||||
|
_hidl_cb(getHidlStatus(res), nullptr);
|
||||||
|
return Void();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Cross-check device version */
|
||||||
|
if (device->common.version < CAMERA_DEVICE_API_VERSION_3_2) {
|
||||||
|
ALOGE("%s: Could not open camera: "
|
||||||
|
"Camera device should be at least %x, reports %x instead",
|
||||||
|
__FUNCTION__,
|
||||||
|
CAMERA_DEVICE_API_VERSION_3_2,
|
||||||
|
device->common.version);
|
||||||
|
device->common.close(&device->common);
|
||||||
|
mLock.unlock();
|
||||||
|
_hidl_cb(Status::ILLEGAL_ARGUMENT, nullptr);
|
||||||
|
return Void();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct camera_info info;
|
||||||
|
res = mModule->getCameraInfo(mCameraIdInt, &info);
|
||||||
|
if (res != OK) {
|
||||||
|
ALOGE("%s: Could not open camera: getCameraInfo failed", __FUNCTION__);
|
||||||
|
device->common.close(&device->common);
|
||||||
|
mLock.unlock();
|
||||||
|
_hidl_cb(Status::ILLEGAL_ARGUMENT, nullptr);
|
||||||
|
return Void();
|
||||||
|
}
|
||||||
|
|
||||||
|
session = createSession(
|
||||||
|
device, info.static_camera_characteristics, callback);
|
||||||
|
if (session == nullptr) {
|
||||||
|
ALOGE("%s: camera device session allocation failed", __FUNCTION__);
|
||||||
|
mLock.unlock();
|
||||||
|
_hidl_cb(Status::INTERNAL_ERROR, nullptr);
|
||||||
|
return Void();
|
||||||
|
}
|
||||||
|
if (session->isInitFailed()) {
|
||||||
|
ALOGE("%s: camera device session init failed", __FUNCTION__);
|
||||||
|
session = nullptr;
|
||||||
|
mLock.unlock();
|
||||||
|
_hidl_cb(Status::INTERNAL_ERROR, nullptr);
|
||||||
|
return Void();
|
||||||
|
}
|
||||||
|
mSession = session;
|
||||||
|
|
||||||
|
IF_ALOGV() {
|
||||||
|
session->getInterface()->interfaceChain([](
|
||||||
|
::android::hardware::hidl_vec<::android::hardware::hidl_string> interfaceChain) {
|
||||||
|
ALOGV("Session interface chain:");
|
||||||
|
for (const auto& iface : interfaceChain) {
|
||||||
|
ALOGV(" %s", iface.c_str());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
mLock.unlock();
|
||||||
|
}
|
||||||
|
_hidl_cb(status, session->getInterface());
|
||||||
|
return Void();
|
||||||
|
}
|
||||||
|
Return<void> CameraDevice::nuke(const sp<ICameraDeviceCallback>& callback,
|
||||||
|
ICameraDevice::open_cb _hidl_cb) {
|
||||||
|
return CameraDevice::open(callback, _hidl_cb);
|
||||||
|
}
|
||||||
} // namespace implementation
|
} // namespace implementation
|
||||||
} // namespace V3_2
|
} // namespace V3_2
|
||||||
} // namespace device
|
} // namespace device
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue