diff options
author | Kyle Repinski <repinski23@gmail.com> | 2015-01-07 08:39:28 -0600 |
---|---|---|
committer | Ziyan <jaraidaniel@gmail.com> | 2015-04-11 20:24:52 +0200 |
commit | c5f4358c48d6e50b2affb3ad6c2c0f59546f5b04 (patch) | |
tree | 74070cb6d50ec822d3ef7acdaa390cf2f94c4097 /camera/inc/BufferSourceAdapter.h | |
parent | c52c76fa1593f374173a818b4de5bd7c51903fbc (diff) | |
download | device_samsung_tuna-c5f4358c48d6e50b2affb3ad6c2c0f59546f5b04.zip device_samsung_tuna-c5f4358c48d6e50b2affb3ad6c2c0f59546f5b04.tar.gz device_samsung_tuna-c5f4358c48d6e50b2affb3ad6c2c0f59546f5b04.tar.bz2 |
camera: Update camera HAL.
OmapZoom p-jb-release branch with 'CameraHal: Camera Capabilities query update' reverted,
as well as a bunch of stuff ifdef'd out.
Needs a lot of work still. At this point it's a regression, but it has to be done.
Diffstat (limited to 'camera/inc/BufferSourceAdapter.h')
-rw-r--r-- | camera/inc/BufferSourceAdapter.h | 190 |
1 files changed, 190 insertions, 0 deletions
diff --git a/camera/inc/BufferSourceAdapter.h b/camera/inc/BufferSourceAdapter.h new file mode 100644 index 0000000..436d2e5 --- /dev/null +++ b/camera/inc/BufferSourceAdapter.h @@ -0,0 +1,190 @@ +/* + * Copyright (C) Texas Instruments - http://www.ti.com/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef BUFFER_SOURCE_ADAPTER_H +#define BUFFER_SOURCE_ADAPTER_H + +#ifdef OMAP_ENHANCEMENT_CPCAM + +#include "CameraHal.h" +#include <ui/GraphicBufferMapper.h> +#include <hal_public.h> + +namespace Ti { +namespace Camera { + +/** + * Handles enqueueing/dequeing buffers to tap-in/tap-out points + * TODO(XXX): this class implements DisplayAdapter for now + * but this will most likely change once tap-in/tap-out points + * are better defined + */ + +class BufferSourceAdapter : public DisplayAdapter +{ +// private types +private: + // helper class to return frame in different thread context + class ReturnFrame : public android::Thread { + public: + ReturnFrame(BufferSourceAdapter* __this) : mBufferSourceAdapter(__this) { + mWaitForSignal.Create(0); + mDestroying = false; + } + + ~ReturnFrame() { + mDestroying = true; + mWaitForSignal.Release(); + } + + void signal() { + mWaitForSignal.Signal(); + } + + virtual bool threadLoop() { + mWaitForSignal.Wait(); + if (!mDestroying) mBufferSourceAdapter->handleFrameReturn(); + return true; + } + + private: + BufferSourceAdapter* mBufferSourceAdapter; + Utils::Semaphore mWaitForSignal; + bool mDestroying; + }; + + // helper class to queue frame in different thread context + class QueueFrame : public android::Thread { + public: + QueueFrame(BufferSourceAdapter* __this) : mBufferSourceAdapter(__this) { + mDestroying = false; + } + + ~QueueFrame() { + mDestroying = true; + + android::AutoMutex lock(mFramesMutex); + while (!mFrames.empty()) { + CameraFrame *frame = mFrames.itemAt(0); + mFrames.removeAt(0); + frame->mMetaData.clear(); + delete frame; + } + mFramesCondition.signal(); + } + + void addFrame(CameraFrame *frame) { + android::AutoMutex lock(mFramesMutex); + mFrames.add(new CameraFrame(*frame)); + mFramesCondition.signal(); + } + + virtual bool threadLoop() { + CameraFrame *frame = NULL; + { + android::AutoMutex lock(mFramesMutex); + while (mFrames.empty() && !mDestroying) mFramesCondition.wait(mFramesMutex); + if (!mDestroying) { + frame = mFrames.itemAt(0); + mFrames.removeAt(0); + } + } + + if (frame) { + mBufferSourceAdapter->handleFrameCallback(frame); + frame->mMetaData.clear(); + delete frame; + } + + return true; + } + + private: + BufferSourceAdapter* mBufferSourceAdapter; + android::Vector<CameraFrame *> mFrames; + android::Condition mFramesCondition; + android::Mutex mFramesMutex; + bool mDestroying; + }; + + enum { + BUFFER_SOURCE_TAP_IN, + BUFFER_SOURCE_TAP_OUT + }; + +// public member functions +public: + BufferSourceAdapter(); + virtual ~BufferSourceAdapter(); + + virtual status_t initialize(); + virtual int setPreviewWindow(struct preview_stream_ops *source); + virtual int setFrameProvider(FrameNotifier *frameProvider); + virtual int setErrorHandler(ErrorNotifier *errorNotifier); + virtual int enableDisplay(int width, int height, struct timeval *refTime = NULL); + virtual int disableDisplay(bool cancel_buffer = true); + virtual status_t pauseDisplay(bool pause); +#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS + // Not implemented in this class + virtual status_t setSnapshotTimeRef(struct timeval *refTime = NULL) { return NO_ERROR; } +#endif + virtual bool supportsExternalBuffering(); + virtual CameraBuffer * allocateBufferList(int width, int dummyHeight, const char* format, int &bytes, int numBufs); + virtual CameraBuffer *getBufferList(int *numBufs); + virtual uint32_t * getOffsets() ; + virtual int getFd() ; + virtual int freeBufferList(CameraBuffer * buflist); + virtual int maxQueueableBuffers(unsigned int& queueable); + virtual int minUndequeueableBuffers(int& unqueueable); + + static void frameCallback(CameraFrame* caFrame); + void addFrame(CameraFrame* caFrame); + void handleFrameCallback(CameraFrame* caFrame); + bool handleFrameReturn(); + +private: + void destroy(); + status_t returnBuffersToWindow(); + +private: + preview_stream_ops_t* mBufferSource; + FrameProvider *mFrameProvider; // Pointer to the frame provider interface + + mutable android::Mutex mLock; + int mBufferCount; + CameraBuffer *mBuffers; + + android::KeyedVector<buffer_handle_t *, int> mFramesWithCameraAdapterMap; + android::sp<ErrorNotifier> mErrorNotifier; + android::sp<ReturnFrame> mReturnFrame; + android::sp<QueueFrame> mQueueFrame; + + uint32_t mFrameWidth; + uint32_t mFrameHeight; + uint32_t mPreviewWidth; + uint32_t mPreviewHeight; + + int mBufferSourceDirection; + + const char *mPixelFormat; +}; + +} // namespace Camera +} // namespace Ti + +#endif + +#endif |