summaryrefslogtreecommitdiffstats
path: root/camera/inc/CameraHal.h
diff options
context:
space:
mode:
Diffstat (limited to 'camera/inc/CameraHal.h')
-rw-r--r--camera/inc/CameraHal.h687
1 files changed, 446 insertions, 241 deletions
diff --git a/camera/inc/CameraHal.h b/camera/inc/CameraHal.h
index 2506b7b..d20db1e 100644
--- a/camera/inc/CameraHal.h
+++ b/camera/inc/CameraHal.h
@@ -29,22 +29,37 @@
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/stat.h>
+
+#include <hardware/camera.h>
#include <utils/Log.h>
#include <utils/threads.h>
-#include <linux/videodev2.h>
-#include "binder/MemoryBase.h"
-#include "binder/MemoryHeapBase.h"
#include <utils/threads.h>
+#include <binder/MemoryBase.h>
+#include <binder/MemoryHeapBase.h>
#include <camera/CameraParameters.h>
-#include <hardware/camera.h>
+#ifdef OMAP_ENHANCEMENT_CPCAM
+#include <camera/CameraMetadata.h>
+#include <camera/ShotParameters.h>
+#endif
+#include <ui/GraphicBufferAllocator.h>
+#include <ui/GraphicBuffer.h>
+
+/* For IMG_native_handle_t */
+#include <ui/GraphicBufferMapper.h>
+#include <hal_public.h>
+
+#include <ion_ti/ion.h>
+
+#include "Common.h"
#include "MessageQueue.h"
#include "Semaphore.h"
#include "CameraProperties.h"
-#include "DebugUtils.h"
#include "SensorListener.h"
-#include <ui/GraphicBufferAllocator.h>
-#include <ui/GraphicBuffer.h>
+//temporarily define format here
+#define HAL_PIXEL_FORMAT_TI_NV12 0x100
+#define HAL_PIXEL_FORMAT_TI_Y8 0x103
+#define HAL_PIXEL_FORMAT_TI_Y16 0x104
#define MIN_WIDTH 640
#define MIN_HEIGHT 480
@@ -66,6 +81,8 @@
#define SHARPNESS_OFFSET 100
#define CONTRAST_OFFSET 100
+#define FRAME_RATE_HIGH_HD 60
+
#define CAMHAL_GRALLOC_USAGE GRALLOC_USAGE_HW_TEXTURE | \
GRALLOC_USAGE_HW_RENDER | \
GRALLOC_USAGE_SW_READ_RARELY | \
@@ -77,75 +94,111 @@
#define LOCK_BUFFER_TRIES 5
#define HAL_PIXEL_FORMAT_NV12 0x100
-#define CAMHAL_LOGI ALOGI
+#define NONNEG_ASSIGN(x,y) \
+ if(x > -1) \
+ y = x
-//Uncomment to enable more verbose/debug logs
-#define DEBUG_LOG
+#define CAMHAL_SIZE_OF_ARRAY(x) static_cast<int>(sizeof(x)/sizeof(x[0]))
-///Camera HAL Logging Functions
-#ifndef DEBUG_LOG
+namespace Ti {
+namespace Camera {
-#define CAMHAL_LOGDA(str)
-#define CAMHAL_LOGDB(str, ...)
-#define CAMHAL_LOGVA(str)
-#define CAMHAL_LOGVB(str, ...)
+#ifdef CAMERAHAL_USE_RAW_IMAGE_SAVING
+extern const char * const kRawImagesOutputDirPath;
+extern const char * const kYuvImagesOutputDirPath;
+#endif
+#define V4L_CAMERA_NAME_USB "USBCAMERA"
+#define OMX_CAMERA_NAME_OV "OV5640"
+#define OMX_CAMERA_NAME_SONY "IMX060"
-#define CAMHAL_LOGEA ALOGE
-#define CAMHAL_LOGEB ALOGE
-#undef LOG_FUNCTION_NAME
-#undef LOG_FUNCTION_NAME_EXIT
-#define LOG_FUNCTION_NAME
-#define LOG_FUNCTION_NAME_EXIT
+///Forward declarations
+class CameraHal;
+class CameraFrame;
+class CameraHalEvent;
+class DisplayFrame;
-#else
+class FpsRange {
+public:
+ static int compare(const FpsRange * left, const FpsRange * right);
-#define CAMHAL_LOGDA DBGUTILS_LOGDA
-#define CAMHAL_LOGDB DBGUTILS_LOGDB
-#define CAMHAL_LOGVA DBGUTILS_LOGVA
-#define CAMHAL_LOGVB DBGUTILS_LOGVB
+ FpsRange(int min, int max);
+ FpsRange();
-#define CAMHAL_LOGEA DBGUTILS_LOGEA
-#define CAMHAL_LOGEB DBGUTILS_LOGEB
+ bool operator==(const FpsRange & fpsRange) const;
-#endif
+ bool isNull() const;
+ bool isFixed() const;
+ int min() const;
+ int max() const;
+private:
+ int mMin;
+ int mMax;
+};
-#define NONNEG_ASSIGN(x,y) \
- if(x > -1) \
- y = x
-namespace android {
+inline int FpsRange::compare(const FpsRange * const left, const FpsRange * const right) {
+ if ( left->max() < right->max() ) {
+ return -1;
+ }
-#define PARAM_BUFFER 6000
+ if ( left->max() > right->max() ) {
+ return 1;
+ }
-///Forward declarations
-class CameraHal;
-class CameraFrame;
-class CameraHalEvent;
-class DisplayFrame;
+ if ( left->min() < right->min() ) {
+ return -1;
+ }
+
+ if ( left->min() > right->min() ) {
+ return 1;
+ }
+
+ return 0;
+}
+
+inline FpsRange::FpsRange(const int min, const int max) : mMin(min), mMax(max) {}
+
+inline FpsRange::FpsRange() : mMin(-1), mMax(-1) {}
+
+inline bool FpsRange::operator==(const FpsRange & fpsRange) const {
+ return mMin == fpsRange.mMin && mMax == fpsRange.mMax;
+}
+
+inline bool FpsRange::isNull() const {
+ return mMin == -1 || mMax == -1;
+}
+
+inline bool FpsRange::isFixed() const {
+ return mMin == mMax;
+}
+
+inline int FpsRange::min() const { return mMin; }
+
+inline int FpsRange::max() const { return mMax; }
-class CameraArea : public RefBase
+class CameraArea : public android::RefBase
{
public:
- CameraArea(int32_t top,
- int32_t left,
- int32_t bottom,
- int32_t right,
- uint32_t weight) : mTop(top),
+ CameraArea(ssize_t top,
+ ssize_t left,
+ ssize_t bottom,
+ ssize_t right,
+ size_t weight) : mTop(top),
mLeft(left),
mBottom(bottom),
mRight(right),
mWeight(weight) {}
- status_t transfrom(uint32_t width,
- uint32_t height,
- int32_t &top,
- int32_t &left,
- uint32_t &areaWidth,
- uint32_t &areaHeight);
+ status_t transfrom(size_t width,
+ size_t height,
+ size_t &top,
+ size_t &left,
+ size_t &areaWidth,
+ size_t &areaHeight);
bool isValid()
{
@@ -158,62 +211,84 @@ public:
&& ( 0 == mRight ) && ( 0 == mWeight ));
}
- uint32_t getWeight()
+ size_t getWeight()
{
return mWeight;
}
- bool compare(const sp<CameraArea> &area);
+ bool compare(const android::sp<CameraArea> &area);
static status_t parseAreas(const char *area,
- uint32_t areaLength,
- Vector< sp<CameraArea> > &areas);
+ size_t areaLength,
+ android::Vector< android::sp<CameraArea> > &areas);
- static status_t checkArea(int32_t top,
- int32_t left,
- int32_t bottom,
- int32_t right,
- int32_t weight);
+ static status_t checkArea(ssize_t top,
+ ssize_t left,
+ ssize_t bottom,
+ ssize_t right,
+ ssize_t weight);
- static bool areAreasDifferent(Vector< sp<CameraArea> > &, Vector< sp<CameraArea> > &);
+ static bool areAreasDifferent(android::Vector< android::sp<CameraArea> > &, android::Vector< android::sp<CameraArea> > &);
protected:
- static const int32_t TOP = -1000;
- static const int32_t LEFT = -1000;
- static const int32_t BOTTOM = 1000;
- static const int32_t RIGHT = 1000;
- static const int32_t WEIGHT_MIN = 1;
- static const int32_t WEIGHT_MAX = 1000;
-
- int32_t mTop;
- int32_t mLeft;
- int32_t mBottom;
- int32_t mRight;
- uint32_t mWeight;
+ static const ssize_t TOP = -1000;
+ static const ssize_t LEFT = -1000;
+ static const ssize_t BOTTOM = 1000;
+ static const ssize_t RIGHT = 1000;
+ static const ssize_t WEIGHT_MIN = 1;
+ static const ssize_t WEIGHT_MAX = 1000;
+
+ ssize_t mTop;
+ ssize_t mLeft;
+ ssize_t mBottom;
+ ssize_t mRight;
+ size_t mWeight;
};
-class CameraFDResult : public RefBase
+class CameraMetadataResult : public android::RefBase
{
public:
- CameraFDResult() : mFaceData(NULL) {};
- CameraFDResult(camera_frame_metadata_t *faces) : mFaceData(faces) {};
+#ifdef OMAP_ENHANCEMENT_CPCAM
+ CameraMetadataResult(camera_memory_t * extMeta) : mExtendedMetadata(extMeta) {
+ mMetadata.faces = NULL;
+ mMetadata.number_of_faces = 0;
+#ifdef OMAP_ENHANCEMENT
+ mMetadata.analog_gain = 0;
+ mMetadata.exposure_time = 0;
+#endif
+ };
+#endif
- virtual ~CameraFDResult() {
- if ( ( NULL != mFaceData ) && ( NULL != mFaceData->faces ) ) {
- free(mFaceData->faces);
- free(mFaceData);
- mFaceData=NULL;
- }
+ CameraMetadataResult() {
+ mMetadata.faces = NULL;
+ mMetadata.number_of_faces = 0;
+#ifdef OMAP_ENHANCEMENT_CPCAM
+ mMetadata.analog_gain = 0;
+ mMetadata.exposure_time = 0;
+#endif
+
+#ifdef OMAP_ENHANCEMENT_CPCAM
+ mExtendedMetadata = NULL;
+#endif
+ }
- if(( NULL != mFaceData ))
- {
- free(mFaceData);
- mFaceData = NULL;
- }
+ virtual ~CameraMetadataResult() {
+ if ( NULL != mMetadata.faces ) {
+ free(mMetadata.faces);
+ }
+#ifdef OMAP_ENHANCEMENT_CPCAM
+ if ( NULL != mExtendedMetadata ) {
+ mExtendedMetadata->release(mExtendedMetadata);
+ }
+#endif
}
- camera_frame_metadata_t *getFaceResult() { return mFaceData; };
+ camera_frame_metadata_t *getMetadataResult() { return &mMetadata; };
+
+#ifdef OMAP_ENHANCEMENT_CPCAM
+ camera_memory_t *getExtendedMetadata() { return mExtendedMetadata; };
+#endif
static const ssize_t TOP = -1000;
static const ssize_t LEFT = -1000;
@@ -223,9 +298,58 @@ public:
private:
- camera_frame_metadata_t *mFaceData;
+ camera_frame_metadata_t mMetadata;
+#ifdef OMAP_ENHANCEMENT_CPCAM
+ camera_memory_t *mExtendedMetadata;
+#endif
};
+typedef enum {
+ CAMERA_BUFFER_NONE = 0,
+ CAMERA_BUFFER_GRALLOC,
+ CAMERA_BUFFER_ANW,
+ CAMERA_BUFFER_MEMORY,
+ CAMERA_BUFFER_ION
+} CameraBufferType;
+
+typedef struct _CameraBuffer {
+ CameraBufferType type;
+ /* opaque is the generic drop-in replacement for the pointers
+ * that were used previously */
+ void *opaque;
+
+ /* opaque has different meanings depending on the buffer type:
+ * GRALLOC - gralloc_handle_t
+ * ANW - a pointer to the buffer_handle_t (which corresponds to
+ * the ANativeWindowBuffer *)
+ * MEMORY - address of allocated memory
+ * ION - address of mapped ion allocation
+ *
+ * FIXME opaque should be split into several fields:
+ * - handle/pointer we got from the allocator
+ * - handle/value we pass to OMX
+ * - pointer to mapped memory (if the buffer is mapped)
+ */
+
+ /* mapped holds ptr to mapped memory in userspace */
+ void *mapped;
+
+ /* These are specific to ION buffers */
+ struct ion_handle * ion_handle;
+ int ion_fd;
+ int fd;
+ size_t size;
+ int index;
+
+ /* These describe the camera buffer */
+ int width;
+ int stride;
+ int height;
+ const char *format;
+} CameraBuffer;
+
+void * camera_buffer_get_omx_ptr (CameraBuffer *buffer);
+
class CameraFrame
{
public:
@@ -242,6 +366,7 @@ class CameraFrame
FRAME_DATA= 0x80,
RAW_FRAME = 0x100,
SNAPSHOT_FRAME = 0x200,
+ REPROCESS_INPUT_FRAME = 0x400,
ALL_FRAMES = 0xFFFF ///Maximum of 16 frame types supported
};
@@ -249,6 +374,8 @@ class CameraFrame
{
ENCODE_RAW_YUV422I_TO_JPEG = 0x1 << 0,
HAS_EXIF_DATA = 0x1 << 1,
+ FORMAT_YUV422I_YUYV = 0x1 << 2,
+ FORMAT_YUV422I_UYVY = 0x1 << 3,
};
//default contrustor
@@ -265,45 +392,32 @@ class CameraFrame
mFd(0),
mLength(0),
mFrameMask(0),
- mQuirks(0) {
-
+ mQuirks(0)
+ {
mYuv[0] = 0; //NULL;
mYuv[1] = 0; //NULL;
- }
- //copy constructor
- CameraFrame(const CameraFrame &frame) :
- mCookie(frame.mCookie),
- mCookie2(frame.mCookie2),
- mBuffer(frame.mBuffer),
- mFrameType(frame.mFrameType),
- mTimestamp(frame.mTimestamp),
- mWidth(frame.mWidth),
- mHeight(frame.mHeight),
- mOffset(frame.mOffset),
- mAlignment(frame.mAlignment),
- mFd(frame.mFd),
- mLength(frame.mLength),
- mFrameMask(frame.mFrameMask),
- mQuirks(frame.mQuirks) {
-
- mYuv[0] = frame.mYuv[0];
- mYuv[1] = frame.mYuv[1];
+#ifdef OMAP_ENHANCEMENT_CPCAM
+ mMetaData = 0;
+#endif
}
void *mCookie;
void *mCookie2;
- void *mBuffer;
+ CameraBuffer *mBuffer;
int mFrameType;
nsecs_t mTimestamp;
unsigned int mWidth, mHeight;
uint32_t mOffset;
unsigned int mAlignment;
int mFd;
- uint32_t mLength;
+ size_t mLength;
unsigned mFrameMask;
unsigned int mQuirks;
unsigned int mYuv[2];
+#ifdef OMAP_ENHANCEMENT_CPCAM
+ android::sp<CameraMetadataResult> mMetaData;
+#endif
///@todo add other member vars like stride etc
};
@@ -326,7 +440,7 @@ public:
EVENT_FOCUS_ERROR = 0x2,
EVENT_ZOOM_INDEX_REACHED = 0x4,
EVENT_SHUTTER = 0x8,
- EVENT_FACE = 0x10,
+ EVENT_METADATA = 0x10,
///@remarks Future enum related to display, like frame displayed event, could be added here
ALL_EVENTS = 0xFFFF ///Maximum of 16 event types supported
};
@@ -359,23 +473,23 @@ public:
} ZoomEventData;
typedef struct FaceData_t {
- int32_t top;
- int32_t left;
- int32_t bottom;
- int32_t right;
- uint32_t score;
+ ssize_t top;
+ ssize_t left;
+ ssize_t bottom;
+ ssize_t right;
+ size_t score;
} FaceData;
- typedef sp<CameraFDResult> FaceEventData;
+ typedef android::sp<CameraMetadataResult> MetaEventData;
- class CameraHalEventData : public RefBase{
+ class CameraHalEventData : public android::RefBase{
public:
CameraHalEvent::FocusEventData focusEvent;
CameraHalEvent::ZoomEventData zoomEvent;
CameraHalEvent::ShutterEventData shutterEvent;
- CameraHalEvent::FaceEventData faceEvent;
+ CameraHalEvent::MetaEventData metadataEvent;
};
//default contrustor
@@ -391,7 +505,7 @@ public:
void* mCookie;
CameraHalEventType mEventType;
- sp<CameraHalEventData> mEventData;
+ android::sp<CameraHalEventData> mEventData;
};
@@ -423,7 +537,7 @@ public:
virtual ~MessageNotifier() {};
};
-class ErrorNotifier : public virtual RefBase
+class ErrorNotifier : public virtual android::RefBase
{
public:
virtual void errorNotify(int error) = 0;
@@ -439,8 +553,8 @@ public:
class FrameNotifier : public MessageNotifier
{
public:
- virtual void returnFrame(void* frameBuf, CameraFrame::FrameType frameType) = 0;
- virtual void addFramePointers(void *frameBuf, void *buf) = 0;
+ virtual void returnFrame(CameraBuffer* frameBuf, CameraFrame::FrameType frameType) = 0;
+ virtual void addFramePointers(CameraBuffer *frameBuf, void *buf) = 0;
virtual void removeFramePointers() = 0;
virtual ~FrameNotifier() {};
@@ -460,8 +574,8 @@ public:
int enableFrameNotification(int32_t frameTypes);
int disableFrameNotification(int32_t frameTypes);
- int returnFrame(void *frameBuf, CameraFrame::FrameType frameType);
- void addFramePointers(void *frameBuf, void *buf);
+ int returnFrame(CameraBuffer *frameBuf, CameraFrame::FrameType frameType);
+ void addFramePointers(CameraBuffer *frameBuf, void *buf);
void removeFramePointers();
};
@@ -489,13 +603,18 @@ public:
class BufferProvider
{
public:
- virtual void* allocateBuffer(int width, int height, const char* format, int &bytes, int numBufs) = 0;
+ virtual CameraBuffer * allocateBufferList(int width, int height, const char* format, int &bytes, int numBufs) = 0;
+
+ // gets a buffer list from BufferProvider when buffers are sent from external source and already pre-allocated
+ // only call this function for an input source into CameraHal. If buffers are not from a pre-allocated source
+ // this function will return NULL and numBufs of -1
+ virtual CameraBuffer *getBufferList(int *numBufs) = 0;
//additional methods used for memory mapping
virtual uint32_t * getOffsets() = 0;
virtual int getFd() = 0;
- virtual int freeBuffer(void* buf) = 0;
+ virtual int freeBufferList(CameraBuffer * buf) = 0;
virtual ~BufferProvider() {}
};
@@ -503,7 +622,7 @@ public:
/**
* Class for handling data and notify callbacks to application
*/
-class AppCallbackNotifier: public ErrorNotifier , public virtual RefBase
+class AppCallbackNotifier: public ErrorNotifier , public virtual android::RefBase
{
public:
@@ -545,7 +664,7 @@ public:
//All sub-components of Camera HAL call this whenever any error happens
virtual void errorNotify(int error);
- status_t startPreviewCallbacks(CameraParameters &params, void *buffers, uint32_t *offsets, int fd, uint32_t length, uint32_t count);
+ status_t startPreviewCallbacks(android::CameraParameters &params, CameraBuffer *buffers, uint32_t *offsets, int fd, size_t length, size_t count);
status_t stopPreviewCallbacks();
status_t enableMsgType(int32_t msgType);
@@ -577,12 +696,12 @@ public:
//Notifications from CameraHal for video recording case
status_t startRecording();
status_t stopRecording();
- status_t initSharedVideoBuffers(void *buffers, uint32_t *offsets, int fd, uint32_t length, uint32_t count, void *vidBufs);
+ status_t initSharedVideoBuffers(CameraBuffer *buffers, uint32_t *offsets, int fd, size_t length, size_t count, CameraBuffer *vidBufs);
status_t releaseRecordingFrame(const void *opaque);
- status_t useMetaDataBufferMode(bool enable);
+ status_t useMetaDataBufferMode(bool enable);
- void EncoderDoneCb(void*, void*, CameraFrame::FrameType type, void* cookie1, void* cookie2);
+ void EncoderDoneCb(void*, void*, CameraFrame::FrameType type, void* cookie1, void* cookie2, void *cookie3);
void useVideoBuffers(bool useVideoBuffers);
@@ -592,9 +711,9 @@ public:
void flushEventQueue();
//Internal class definitions
- class NotificationThread : public Thread {
+ class NotificationThread : public android::Thread {
AppCallbackNotifier* mAppCallbackNotifier;
- TIUTILS::MessageQueue mNotificationThreadQ;
+ Utils::MessageQueue mNotificationThreadQ;
public:
enum NotificationThreadCommands
{
@@ -609,7 +728,7 @@ public:
return mAppCallbackNotifier->notificationThread();
}
- TIUTILS::MessageQueue &msgQ() { return mNotificationThreadQ;}
+ Utils::MessageQueue &msgQ() { return mNotificationThreadQ;}
};
//Friend declarations
@@ -623,10 +742,12 @@ private:
status_t dummyRaw();
void copyAndSendPictureFrame(CameraFrame* frame, int32_t msgType);
void copyAndSendPreviewFrame(CameraFrame* frame, int32_t msgType);
+ size_t calculateBufferSize(size_t width, size_t height, const char *pixelFormat);
+ const char* getContstantForPixelFormat(const char *pixelFormat);
private:
- mutable Mutex mLock;
- mutable Mutex mBurstLock;
+ mutable android::Mutex mLock;
+ mutable android::Mutex mBurstLock;
CameraHal* mCameraHal;
camera_notify_callback mNotifyCb;
camera_data_callback mDataCb;
@@ -636,34 +757,37 @@ private:
//Keeps Video MemoryHeaps and Buffers within
//these objects
- KeyedVector<unsigned int, unsigned int> mVideoHeaps;
- KeyedVector<unsigned int, unsigned int> mVideoBuffers;
- KeyedVector<unsigned int, unsigned int> mVideoMap;
+ android::KeyedVector<unsigned int, unsigned int> mVideoHeaps;
+ android::KeyedVector<unsigned int, unsigned int> mVideoBuffers;
+ android::KeyedVector<void *, CameraBuffer *> mVideoMap;
//Keeps list of Gralloc handles and associated Video Metadata Buffers
- KeyedVector<uint32_t, uint32_t> mVideoMetadataBufferMemoryMap;
- KeyedVector<uint32_t, uint32_t> mVideoMetadataBufferReverseMap;
+ android::KeyedVector<void *, camera_memory_t *> mVideoMetadataBufferMemoryMap;
+ android::KeyedVector<void *, CameraBuffer *> mVideoMetadataBufferReverseMap;
bool mBufferReleased;
- sp< NotificationThread> mNotificationThread;
+ android::sp< NotificationThread> mNotificationThread;
EventProvider *mEventProvider;
FrameProvider *mFrameProvider;
- TIUTILS::MessageQueue mEventQ;
- TIUTILS::MessageQueue mFrameQ;
+ Utils::MessageQueue mEventQ;
+ Utils::MessageQueue mFrameQ;
NotifierState mNotifierState;
bool mPreviewing;
camera_memory_t* mPreviewMemory;
- unsigned char* mPreviewBufs[MAX_BUFFERS];
+ CameraBuffer mPreviewBuffers[MAX_BUFFERS];
int mPreviewBufCount;
+ int mPreviewWidth;
+ int mPreviewHeight;
+ int mPreviewStride;
const char *mPreviewPixelFormat;
- KeyedVector<unsigned int, sp<MemoryHeapBase> > mSharedPreviewHeaps;
- KeyedVector<unsigned int, sp<MemoryBase> > mSharedPreviewBuffers;
+ android::KeyedVector<unsigned int, android::sp<android::MemoryHeapBase> > mSharedPreviewHeaps;
+ android::KeyedVector<unsigned int, android::sp<android::MemoryBase> > mSharedPreviewBuffers;
//Burst mode active
bool mBurst;
- mutable Mutex mRecordingLock;
+ mutable android::Mutex mRecordingLock;
bool mRecording;
bool mMeasurementEnabled;
@@ -681,27 +805,24 @@ private:
/**
* Class used for allocating memory for JPEG bit stream buffers, output buffers of camera in no overlay case
*/
-class MemoryManager : public BufferProvider, public virtual RefBase
+class MemoryManager : public BufferProvider, public virtual android::RefBase
{
public:
- MemoryManager():mIonFd(-1){ }
+ MemoryManager();
+ ~MemoryManager();
- ///Initializes the memory manager creates any resources required
- status_t initialize() { return NO_ERROR; }
+ status_t initialize();
int setErrorHandler(ErrorNotifier *errorNotifier);
- virtual void* allocateBuffer(int width, int height, const char* format, int &bytes, int numBufs);
+ virtual CameraBuffer * allocateBufferList(int width, int height, const char* format, int &bytes, int numBufs);
+ virtual CameraBuffer *getBufferList(int *numBufs);
virtual uint32_t * getOffsets();
virtual int getFd() ;
- virtual int freeBuffer(void* buf);
+ virtual int freeBufferList(CameraBuffer * buflist);
private:
-
- sp<ErrorNotifier> mErrorNotifier;
+ android::sp<ErrorNotifier> mErrorNotifier;
int mIonFd;
- KeyedVector<unsigned int, unsigned int> mIonHandleMap;
- KeyedVector<unsigned int, unsigned int> mIonFdMap;
- KeyedVector<unsigned int, unsigned int> mIonBufLength;
};
@@ -712,29 +833,31 @@ private:
* Concrete classes derive from this class and provide implementations based on the specific camera h/w interface
*/
-class CameraAdapter: public FrameNotifier, public virtual RefBase
+class CameraAdapter: public FrameNotifier, public virtual android::RefBase
{
protected:
enum AdapterActiveStates {
- INTIALIZED_ACTIVE = 1 << 0,
- LOADED_PREVIEW_ACTIVE = 1 << 1,
- PREVIEW_ACTIVE = 1 << 2,
- LOADED_CAPTURE_ACTIVE = 1 << 3,
- CAPTURE_ACTIVE = 1 << 4,
- BRACKETING_ACTIVE = 1 << 5,
- AF_ACTIVE = 1 << 6,
- ZOOM_ACTIVE = 1 << 7,
- VIDEO_ACTIVE = 1 << 8,
+ INTIALIZED_ACTIVE = 1 << 0,
+ LOADED_PREVIEW_ACTIVE = 1 << 1,
+ PREVIEW_ACTIVE = 1 << 2,
+ LOADED_CAPTURE_ACTIVE = 1 << 3,
+ CAPTURE_ACTIVE = 1 << 4,
+ BRACKETING_ACTIVE = 1 << 5,
+ AF_ACTIVE = 1 << 6,
+ ZOOM_ACTIVE = 1 << 7,
+ VIDEO_ACTIVE = 1 << 8,
+ LOADED_REPROCESS_ACTIVE = 1 << 9,
+ REPROCESS_ACTIVE = 1 << 10,
};
public:
typedef struct
{
- void *mBuffers;
+ CameraBuffer *mBuffers;
uint32_t *mOffsets;
int mFd;
- uint32_t mLength;
- uint32_t mCount;
- uint32_t mMaxQueueable;
+ size_t mLength;
+ size_t mCount;
+ size_t mMaxQueueable;
} BuffersDescriptor;
enum CameraCommands
@@ -764,6 +887,16 @@ public:
CAMERA_START_FD = 22,
CAMERA_STOP_FD = 23,
CAMERA_SWITCH_TO_EXECUTING = 24,
+ CAMERA_USE_BUFFERS_VIDEO_CAPTURE = 25,
+#ifdef OMAP_ENHANCEMENT_CPCAM
+ CAMERA_USE_BUFFERS_REPROCESS = 26,
+ CAMERA_START_REPROCESS = 27,
+#endif
+#ifdef OMAP_ENHANCEMENT_VTC
+ CAMERA_SETUP_TUNNEL = 28,
+ CAMERA_DESTROY_TUNNEL = 29,
+#endif
+ CAMERA_PREVIEW_INITIALIZATION = 30,
};
enum CameraMode
@@ -771,27 +904,32 @@ public:
CAMERA_PREVIEW,
CAMERA_IMAGE_CAPTURE,
CAMERA_VIDEO,
- CAMERA_MEASUREMENT
+ CAMERA_MEASUREMENT,
+ CAMERA_REPROCESS,
};
enum AdapterState {
- INTIALIZED_STATE = INTIALIZED_ACTIVE,
- LOADED_PREVIEW_STATE = LOADED_PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
- PREVIEW_STATE = PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
- LOADED_CAPTURE_STATE = LOADED_CAPTURE_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
- CAPTURE_STATE = CAPTURE_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
- BRACKETING_STATE = BRACKETING_ACTIVE | CAPTURE_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE ,
- AF_STATE = AF_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
- ZOOM_STATE = ZOOM_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
- VIDEO_STATE = VIDEO_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
- VIDEO_AF_STATE = VIDEO_ACTIVE | AF_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
- VIDEO_ZOOM_STATE = VIDEO_ACTIVE | ZOOM_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
- VIDEO_LOADED_CAPTURE_STATE = VIDEO_ACTIVE | LOADED_CAPTURE_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
- VIDEO_CAPTURE_STATE = VIDEO_ACTIVE | CAPTURE_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
- AF_ZOOM_STATE = AF_ACTIVE | ZOOM_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
- BRACKETING_ZOOM_STATE = BRACKETING_ACTIVE | ZOOM_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
+ INTIALIZED_STATE = INTIALIZED_ACTIVE,
+ LOADED_PREVIEW_STATE = LOADED_PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
+ PREVIEW_STATE = PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
+ LOADED_CAPTURE_STATE = LOADED_CAPTURE_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
+ CAPTURE_STATE = CAPTURE_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
+ BRACKETING_STATE = BRACKETING_ACTIVE | CAPTURE_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE ,
+ AF_STATE = AF_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
+ ZOOM_STATE = ZOOM_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
+ VIDEO_STATE = VIDEO_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
+ VIDEO_AF_STATE = VIDEO_ACTIVE | AF_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
+ VIDEO_ZOOM_STATE = VIDEO_ACTIVE | ZOOM_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
+ VIDEO_LOADED_CAPTURE_STATE = VIDEO_ACTIVE | LOADED_CAPTURE_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
+ VIDEO_CAPTURE_STATE = VIDEO_ACTIVE | CAPTURE_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
+ AF_ZOOM_STATE = AF_ACTIVE | ZOOM_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
+ BRACKETING_ZOOM_STATE = BRACKETING_ACTIVE | ZOOM_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
+ LOADED_REPROCESS_STATE = LOADED_REPROCESS_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
+ LOADED_REPROCESS_CAPTURE_STATE = LOADED_REPROCESS_ACTIVE | LOADED_CAPTURE_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
+ REPROCESS_STATE = REPROCESS_ACTIVE | CAPTURE_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE,
};
+
public:
///Initialzes the camera adapter creates any resources required
@@ -805,19 +943,13 @@ public:
event_callback eventCb = NULL,
void *cookie = NULL) = 0;
virtual void disableMsgType(int32_t msgs, void* cookie) = 0;
- virtual void returnFrame(void* frameBuf, CameraFrame::FrameType frameType) = 0;
- virtual void addFramePointers(void *frameBuf, void *buf) = 0;
+ virtual void returnFrame(CameraBuffer* frameBuf, CameraFrame::FrameType frameType) = 0;
+ virtual void addFramePointers(CameraBuffer *frameBuf, void *buf) = 0;
virtual void removeFramePointers() = 0;
//APIs to configure Camera adapter and get the current parameter set
- virtual int setParameters(const CameraParameters& params) = 0;
- virtual void getParameters(CameraParameters& params) = 0;
-
- //API to flush the buffers from Camera
- status_t flushBuffers()
- {
- return sendCommand(CameraAdapter::CAMERA_PREVIEW_FLUSH_BUFFERS);
- }
+ virtual int setParameters(const android::CameraParameters& params) = 0;
+ virtual void getParameters(android::CameraParameters& params) = 0;
//Registers callback for returning image buffers back to CameraHAL
virtual int registerImageReleaseCallback(release_image_buffers_callback callback, void *user_data) = 0;
@@ -826,7 +958,7 @@ public:
virtual int registerEndCaptureCallback(end_image_capture_callback callback, void *user_data) = 0;
//API to send a command to the camera
- virtual status_t sendCommand(CameraCommands operation, int value1=0, int value2=0, int value3=0) = 0;
+ virtual status_t sendCommand(CameraCommands operation, int value1=0, int value2=0, int value3=0, int value4=0) = 0;
virtual ~CameraAdapter() {};
@@ -847,6 +979,8 @@ public:
// Retrieves the next Adapter state - for internal use (not locked)
virtual status_t getNextState(AdapterState &state) = 0;
+ virtual status_t setSharedAllocator(camera_request_memory shmem_alloc) = 0;
+
protected:
//The first two methods will try to switch the adapter state.
//Every call to setState() should be followed by a corresponding
@@ -857,16 +991,18 @@ protected:
virtual status_t rollbackState() = 0;
};
-class DisplayAdapter : public BufferProvider, public virtual RefBase
+class DisplayAdapter : public BufferProvider, public virtual android::RefBase
{
public:
- typedef struct S3DParameters_t
- {
- int mode;
- int framePacking;
- int order;
- int subSampling;
- } S3DParameters;
+ DisplayAdapter();
+
+#ifdef OMAP_ENHANCEMENT
+ preview_stream_extended_ops_t * extendedOps() const {
+ return mExtendedOps;
+ }
+
+ void setExtendedOps(preview_stream_extended_ops_t * extendedOps);
+#endif
///Initializes the display adapter creates any resources required
virtual int initialize() = 0;
@@ -874,7 +1010,7 @@ public:
virtual int setPreviewWindow(struct preview_stream_ops *window) = 0;
virtual int setFrameProvider(FrameNotifier *frameProvider) = 0;
virtual int setErrorHandler(ErrorNotifier *errorNotifier) = 0;
- virtual int enableDisplay(int width, int height, struct timeval *refTime = NULL, S3DParameters *s3dParams = NULL) = 0;
+ virtual int enableDisplay(int width, int height, struct timeval *refTime = NULL) = 0;
virtual int disableDisplay(bool cancel_buffer = true) = 0;
//Used for Snapshot review temp. pause
virtual int pauseDisplay(bool pause) = 0;
@@ -884,13 +1020,23 @@ public:
virtual int setSnapshotTimeRef(struct timeval *refTime = NULL) = 0;
#endif
- virtual int useBuffers(void *bufArr, int num) = 0;
virtual bool supportsExternalBuffering() = 0;
// Get max queueable buffers display supports
// This function should only be called after
- // allocateBuffer
- virtual int maxQueueableBuffers(unsigned int& queueable) = 0;
+ // allocateBufferList
+ virtual status_t maxQueueableBuffers(unsigned int& queueable) = 0;
+
+ // Get min buffers display needs at any given time
+ virtual status_t minUndequeueableBuffers(int& unqueueable) = 0;
+protected:
+ virtual const char* getPixFormatConstant(const char* parameters_format) const;
+ virtual size_t getBufSize(const char* parameters_format, int width, int height) const;
+
+private:
+#ifdef OMAP_ENHANCEMENT
+ preview_stream_extended_ops_t * mExtendedOps;
+#endif
};
static void releaseImageBuffers(void *userData);
@@ -912,6 +1058,7 @@ public:
///Constants
static const int NO_BUFFERS_PREVIEW;
static const int NO_BUFFERS_IMAGE_CAPTURE;
+ static const int NO_BUFFERS_IMAGE_CAPTURE_SYSTEM_HEAP;
static const uint32_t VFR_SCALE = 1000;
@@ -959,10 +1106,25 @@ public:
int startPreview();
/**
+ * Set preview mode related initialization.
+ * Only used when slice based processing is enabled.
+ */
+ int cameraPreviewInitialization();
+
+ /**
* Only used if overlays are used for camera preview.
*/
int setPreviewWindow(struct preview_stream_ops *window);
+#ifdef OMAP_ENHANCEMENT_CPCAM
+ void setExtendedPreviewStreamOps(preview_stream_extended_ops_t *ops);
+
+ /**
+ * Set a tap-in or tap-out point.
+ */
+ int setBufferSource(struct preview_stream_ops *tapin, struct preview_stream_ops *tapout);
+#endif
+
/**
* Stop a previously started preview.
*/
@@ -1013,7 +1175,7 @@ public:
/**
* Take a picture.
*/
- int takePicture();
+ int takePicture(const char* params);
/**
* Cancel a picture that was started with takePicture. Calling this
@@ -1023,7 +1185,7 @@ public:
/** Set the camera parameters. */
int setParameters(const char* params);
- int setParameters(const CameraParameters& params);
+ int setParameters(const android::CameraParameters& params);
/** Return the camera parameters. */
char* getParameters();
@@ -1045,8 +1207,19 @@ public:
*/
int dump(int fd) const;
+#ifdef OMAP_ENHANCEMENT_CPCAM
+ /**
+ * start a reprocessing operation.
+ */
+ int reprocess(const char* params);
+
+ /**
+ * cancels current reprocessing operation
+ */
+ int cancel_reprocess();
+#endif
- status_t storeMetaDataInBuffers(bool enable);
+ status_t storeMetaDataInBuffers(bool enable);
//@}
@@ -1097,7 +1270,7 @@ private:
//@{
/** Set the camera parameters specific to Video Recording. */
- bool setVideoModeParameters(const CameraParameters&);
+ bool setVideoModeParameters(const android::CameraParameters&);
/** Reset the camera parameters specific to Video Recording. */
bool resetVideoModeParameters();
@@ -1110,7 +1283,7 @@ private:
void insertSupportedParams();
/** Allocate preview data buffers */
- status_t allocPreviewDataBufs(uint32_t size, uint32_t bufferCount);
+ status_t allocPreviewDataBufs(size_t size, size_t bufferCount);
/** Free preview data buffers */
status_t freePreviewDataBufs();
@@ -1122,18 +1295,30 @@ private:
status_t allocVideoBufs(uint32_t width, uint32_t height, uint32_t bufferCount);
/** Allocate image capture buffers */
- status_t allocImageBufs(unsigned int width, unsigned int height, uint32_t length, const char* previewFormat, unsigned int bufferCount);
+ status_t allocImageBufs(unsigned int width, unsigned int height, size_t length,
+ const char* previewFormat, unsigned int bufferCount,
+ unsigned int *max_queueable);
+
+ /** Allocate Raw buffers */
+ status_t allocRawBufs(int width, int height, const char* previewFormat, int bufferCount);
/** Free preview buffers */
status_t freePreviewBufs();
/** Free video bufs */
- status_t freeVideoBufs(void *bufs);
+ status_t freeVideoBufs(CameraBuffer *bufs);
+
+ /** Free RAW bufs */
+ status_t freeRawBufs();
//Check if a given resolution is supported by the current camera
//instance
bool isResolutionValid(unsigned int width, unsigned int height, const char *supportedResolutions);
+ //Check if a given variable frame rate range is supported by the current camera
+ //instance
+ bool isFpsRangeValid(int fpsMin, int fpsMax, const char *supportedFpsRanges);
+
//Check if a given parameter is supported by the current camera
// instance
bool isParameterValid(const char *param, const char *supportedParams);
@@ -1153,11 +1338,11 @@ private:
void forceStopPreview();
- void selectFPSRange(int framerate, int *min_fps, int *max_fps);
-
- void setPreferredPreviewRes(int width, int height);
- void resetPreviewRes(CameraParameters *mParams, int width, int height);
+ void getPreferredPreviewRes(int *width, int *height);
+ void resetPreviewRes(android::CameraParameters *params);
+ // Internal __takePicture function - used in public takePicture() and reprocess()
+ int __takePicture(const char* params);
//@}
@@ -1178,21 +1363,33 @@ public:
static const char PARAMS_DELIMITER[];
CameraAdapter *mCameraAdapter;
- sp<AppCallbackNotifier> mAppCallbackNotifier;
- sp<DisplayAdapter> mDisplayAdapter;
- sp<MemoryManager> mMemoryManager;
+ android::sp<AppCallbackNotifier> mAppCallbackNotifier;
+ android::sp<DisplayAdapter> mDisplayAdapter;
+ android::sp<MemoryManager> mMemoryManager;
+ // TODO(XXX): May need to keep this as a vector in the future
+ // when we can have multiple tap-in/tap-out points
+ android::sp<DisplayAdapter> mBufferSourceAdapter_In;
+ android::sp<DisplayAdapter> mBufferSourceAdapter_Out;
+
+#ifdef OMAP_ENHANCEMENT
+ preview_stream_extended_ops_t * mExtendedPreviewStreamOps;
+#endif
- sp<IMemoryHeap> mPictureHeap;
+ android::sp<android::IMemoryHeap> mPictureHeap;
int* mGrallocHandles;
bool mFpsRangeChangedByApp;
-
+ int mRawWidth;
+ int mRawHeight;
+ bool mRawCapture;
///static member vars
+ static const int SW_SCALING_FPS_LIMIT;
+
#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS
//Timestamp from the CameraHal constructor
@@ -1211,34 +1408,40 @@ private:
bool mDynamicPreviewSwitch;
//keeps paused state of display
bool mDisplayPaused;
+
+#ifdef OMAP_ENHANCEMENT_VTC
+ bool mTunnelSetup;
+ bool mVTCUseCase;
+#endif
+
//Index of current camera adapter
int mCameraIndex;
- mutable Mutex mLock;
+ mutable android::Mutex mLock;
- sp<SensorListener> mSensorListener;
+ android::sp<SensorListener> mSensorListener;
void* mCameraAdapterHandle;
- CameraParameters mParameters;
+ android::CameraParameters mParameters;
bool mPreviewRunning;
bool mPreviewStateOld;
bool mRecordingEnabled;
EventProvider *mEventProvider;
- int32_t *mPreviewDataBufs;
+ CameraBuffer *mPreviewDataBuffers;
uint32_t *mPreviewDataOffsets;
int mPreviewDataFd;
int mPreviewDataLength;
- int32_t *mImageBufs;
+ CameraBuffer *mImageBuffers;
uint32_t *mImageOffsets;
int mImageFd;
int mImageLength;
- int32_t *mPreviewBufs;
+ CameraBuffer *mPreviewBuffers;
uint32_t *mPreviewOffsets;
int mPreviewLength;
int mPreviewFd;
- int32_t *mVideoBufs;
+ CameraBuffer *mVideoBuffers;
uint32_t *mVideoOffsets;
int mVideoFd;
int mVideoLength;
@@ -1254,6 +1457,7 @@ private:
CameraProperties::Properties* mCameraProperties;
bool mPreviewStartInProgress;
+ bool mPreviewInitializationDone;
bool mSetPreviewWindowCalled;
@@ -1264,9 +1468,10 @@ private:
int mVideoWidth;
int mVideoHeight;
+ android::String8 mCapModeBackup;
};
-
-}; // namespace android
+} // namespace Camera
+} // namespace Ti
#endif