aboutsummaryrefslogtreecommitdiff
path: root/camera
diff options
context:
space:
mode:
authorLuK1337 <priv.luk@gmail.com>2017-09-05 09:41:33 +0200
committerdd3boh <dade.garberi@gmail.com>2017-10-31 12:34:43 +0100
commit1032d3d4332b1677ca64dfcdf12c5d841ed00212 (patch)
tree14b2f121fad39b9f5c6d18291e797d85cffcec26 /camera
parent101ee2c92ce71cf8e9a7ccf655ae347bd3d421d0 (diff)
Camera: zuk: Add support for non-treble camera blobs
* Camera HALs before Treble used to pass camera id in user field, in Treble they are meant to pass pointer to CameraDevice. * This patch workarounds this by storing local pointer to CameraDevice and not relying on user field. * Similar to demon000's CameraWrapper solution but it doesn't require wrapping the HAL which could theoretically break HAL3 compatibility. Change-Id: Iadf0359878f71f4da0a3f952b3af5b914bd49fa8
Diffstat (limited to 'camera')
-rw-r--r--camera/zuk/CameraDevice.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/camera/zuk/CameraDevice.cpp b/camera/zuk/CameraDevice.cpp
index 81bc215..02c1b02 100644
--- a/camera/zuk/CameraDevice.cpp
+++ b/camera/zuk/CameraDevice.cpp
@@ -36,6 +36,8 @@ using ::android::hardware::graphics::common::V1_0::PixelFormat;
HandleImporter CameraDevice::sHandleImporter;
+CameraDevice* sCameraDevice;
+
Status CameraDevice::getHidlStatus(const int& status) {
switch (status) {
case 0: return Status::OK;
@@ -361,7 +363,8 @@ CameraDevice::CameraHeapMemory::~CameraHeapMemory() {
// shared memory methods
camera_memory_t* CameraDevice::sGetMemory(int fd, size_t buf_size, uint_t num_bufs, void *user) {
ALOGV("%s", __FUNCTION__);
- CameraDevice* object = static_cast<CameraDevice*>(user);
+ CameraDevice* object = sCameraDevice;
+ (void)(user);
if (object->mDeviceCallback == nullptr) {
ALOGE("%s: camera HAL request memory while camera is not opened!", __FUNCTION__);
return nullptr;
@@ -405,7 +408,8 @@ void CameraDevice::sPutMemory(camera_memory_t *data) {
// Callback forwarding methods
void CameraDevice::sNotifyCb(int32_t msg_type, int32_t ext1, int32_t ext2, void *user) {
ALOGV("%s", __FUNCTION__);
- CameraDevice* object = static_cast<CameraDevice*>(user);
+ CameraDevice* object = sCameraDevice;
+ (void)(user);
if (object->mDeviceCallback != nullptr) {
object->mDeviceCallback->notifyCallback((NotifyCallbackMsg) msg_type, ext1, ext2);
}
@@ -414,7 +418,8 @@ void CameraDevice::sNotifyCb(int32_t msg_type, int32_t ext1, int32_t ext2, void
void CameraDevice::sDataCb(int32_t msg_type, const camera_memory_t *data, unsigned int index,
camera_frame_metadata_t *metadata, void *user) {
ALOGV("%s", __FUNCTION__);
- CameraDevice* object = static_cast<CameraDevice*>(user);
+ CameraDevice* object = sCameraDevice;
+ (void)(user);
sp<CameraHeapMemory> mem(static_cast<CameraHeapMemory*>(data->handle));
if (index >= mem->mNumBufs) {
ALOGE("%s: invalid buffer index %d, max allowed is %d", __FUNCTION__,
@@ -484,7 +489,8 @@ void CameraDevice::handleCallbackTimestamp(
void CameraDevice::sDataCbTimestamp(nsecs_t timestamp, int32_t msg_type,
const camera_memory_t *data, unsigned index, void *user) {
ALOGV("%s", __FUNCTION__);
- CameraDevice* object = static_cast<CameraDevice*>(user);
+ CameraDevice* object = sCameraDevice;
+ (void)(user);
// Start refcounting the heap object from here on. When the clients
// drop all references, it will be destroyed (as well as the enclosed
// MemoryHeapBase.
@@ -661,6 +667,8 @@ Return<Status> CameraDevice::open(const sp<ICameraDeviceCallback>& callback) {
initHalPreviewWindow();
mDeviceCallback = callback;
+ sCameraDevice = this;
+
if (mDevice->ops->set_callbacks) {
mDevice->ops->set_callbacks(mDevice,
sNotifyCb, sDataCb, sDataCbTimestamp, sGetMemory, this);