Iliyan Malchev | 6d01645 | 2013-03-27 16:27:56 -0700 | [diff] [blame] | 1 | /* |
| 2 | ** Copyright 2008, Google Inc. |
| 3 | ** Copyright (c) 2009-2011, The Linux Foundation. All rights reserved. |
| 4 | ** |
| 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | ** you may not use this file except in compliance with the License. |
| 7 | ** You may obtain a copy of the License at |
| 8 | ** |
| 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | ** |
| 11 | ** Unless required by applicable law or agreed to in writing, software |
| 12 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | ** See the License for the specific language governing permissions and |
| 15 | ** limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #ifndef ANDROID_HARDWARE_QUALCOMM_CAMERA_HARDWARE_H |
| 19 | #define ANDROID_HARDWARE_QUALCOMM_CAMERA_HARDWARE_H |
| 20 | |
| 21 | #define ICS |
| 22 | |
| 23 | //#include <camera/CameraHardwareInterface.h> |
| 24 | #include <utils/threads.h> |
| 25 | #include <binder/MemoryBase.h> |
| 26 | #include <binder/MemoryHeapBase.h> |
| 27 | #include <stdint.h> |
| 28 | #include <ui/egl/android_natives.h> |
| 29 | #ifdef ICS |
| 30 | #include <hardware/camera.h> |
| 31 | #endif |
| 32 | #include <camera/Camera.h> |
| 33 | #include "QCameraParameters.h" |
| 34 | #include <system/window.h> |
| 35 | #include <system/camera.h> |
| 36 | #include <hardware/camera.h> |
| 37 | #include <gralloc_priv.h> |
| 38 | #include <QComOMXMetadata.h> |
| 39 | #include "QCamera_Intf.h" |
| 40 | |
| 41 | extern "C" { |
| 42 | #include <linux/android_pmem.h> |
| 43 | #include <linux/ion.h> |
| 44 | #include <mm_camera_interface.h> |
| 45 | } |
| 46 | |
| 47 | struct str_map { |
| 48 | const char *const desc; |
| 49 | int val; |
| 50 | }; |
| 51 | |
| 52 | struct buffer_map { |
| 53 | msm_frame *frame; |
| 54 | buffer_handle_t * buffer; |
| 55 | int size; |
| 56 | int lockState; |
| 57 | }; |
| 58 | |
| 59 | typedef enum { |
| 60 | TARGET_MSM7625, |
| 61 | TARGET_MSM7625A, |
| 62 | TARGET_MSM7627, |
| 63 | TARGET_MSM7627A, |
| 64 | TARGET_QSD8250, |
| 65 | TARGET_MSM7630, |
| 66 | TARGET_MSM8660, |
| 67 | TARGET_MAX |
| 68 | }targetType; |
| 69 | |
| 70 | typedef enum { |
| 71 | LIVESHOT_DONE, |
| 72 | LIVESHOT_IN_PROGRESS, |
| 73 | LIVESHOT_STOPPED |
| 74 | }liveshotState; |
| 75 | #define MIN_UNDEQUEUD_BUFFER_COUNT 2 |
| 76 | struct target_map { |
| 77 | const char *targetStr; |
| 78 | targetType targetEnum; |
| 79 | }; |
| 80 | |
| 81 | enum { |
| 82 | BUFFER_UNLOCKED, |
| 83 | BUFFER_LOCKED |
| 84 | }; |
| 85 | |
| 86 | struct board_property{ |
| 87 | targetType target; |
| 88 | unsigned int previewSizeMask; |
| 89 | bool hasSceneDetect; |
| 90 | bool hasSelectableZoneAf; |
| 91 | bool hasFaceDetect; |
| 92 | }; |
| 93 | |
| 94 | namespace android { |
| 95 | |
| 96 | class QualcommCameraHardware : public RefBase{ |
| 97 | public: |
| 98 | |
| 99 | //virtual sp<IMemoryHeap> getPreviewHeap() const; |
| 100 | //virtual sp<IMemoryHeap> getRawHeap() const; |
| 101 | |
| 102 | void setCallbacks(camera_notify_callback notify_cb, |
| 103 | camera_data_callback data_cb, |
| 104 | camera_data_timestamp_callback data_cb_timestamp, |
| 105 | camera_request_memory get_memory, |
| 106 | void *user); |
| 107 | |
| 108 | virtual void enableMsgType(int32_t msgType); |
| 109 | virtual void disableMsgType(int32_t msgType); |
| 110 | virtual bool msgTypeEnabled(int32_t msgType); |
| 111 | |
| 112 | virtual status_t dump(int fd, const Vector<String16>& args) const; |
| 113 | virtual status_t startPreview(); |
| 114 | virtual void stopPreview(); |
| 115 | virtual bool previewEnabled(); |
| 116 | virtual status_t startRecording(); |
| 117 | virtual void stopRecording(); |
| 118 | virtual bool recordingEnabled(); |
| 119 | virtual void releaseRecordingFrame(const void *opaque); |
| 120 | virtual status_t autoFocus(); |
| 121 | virtual status_t cancelAutoFocus(); |
| 122 | virtual status_t takePicture(); |
| 123 | virtual status_t takeLiveSnapshot(); |
| 124 | virtual status_t takeLiveSnapshotInternal(); |
| 125 | void set_liveshot_exifinfo(); |
| 126 | virtual status_t cancelPicture(); |
| 127 | virtual status_t setParameters(const QCameraParameters& params); |
| 128 | virtual QCameraParameters getParameters() const; |
| 129 | virtual status_t sendCommand(int32_t command, int32_t arg1, int32_t arg2); |
| 130 | virtual int32_t getNumberOfVideoBuffers(); |
| 131 | virtual sp<IMemory> getVideoBuffer(int32_t index); |
| 132 | virtual status_t getBufferInfo( sp<IMemory>& Frame, size_t *alignedSize); |
| 133 | virtual void encodeData( ); |
| 134 | #ifdef ICS |
| 135 | virtual status_t set_PreviewWindow(void* param); |
| 136 | virtual status_t setPreviewWindow(preview_stream_ops_t* window); |
| 137 | #endif |
| 138 | virtual status_t setPreviewWindow(const sp<ANativeWindow>& buf) {return NO_ERROR;}; |
| 139 | virtual void release(); |
| 140 | |
| 141 | static QualcommCameraHardware* createInstance(); |
| 142 | static QualcommCameraHardware* getInstance(); |
| 143 | |
| 144 | void receivePreviewFrame(struct msm_frame *frame); |
| 145 | void receiveLiveSnapshot(uint32_t jpeg_size); |
| 146 | void receiveCameraStats(camstats_type stype, camera_preview_histogram_info* histinfo); |
| 147 | void receiveRecordingFrame(struct msm_frame *frame); |
| 148 | void receiveJpegPicture(status_t status, mm_camera_buffer_t *encoded_buffer); |
| 149 | void jpeg_set_location(); |
| 150 | void receiveJpegPictureFragment(uint8_t *buf, uint32_t size); |
| 151 | void notifyShutter(bool mPlayShutterSoundOnly); |
| 152 | void receive_camframe_error_timeout(); |
| 153 | static void getCameraInfo(); |
| 154 | void receiveRawPicture(status_t status,struct msm_frame *postviewframe, struct msm_frame *mainframe); |
| 155 | int allocate_ion_memory(int *main_ion_fd, struct ion_allocation_data* alloc, |
| 156 | struct ion_fd_data* ion_info_fd, int ion_type, int size, int *memfd); |
| 157 | int deallocate_ion_memory(int *main_ion_fd, struct ion_fd_data* ion_info_fd); |
| 158 | virtual ~QualcommCameraHardware(); |
| 159 | int storeMetaDataInBuffers(int enable); |
| 160 | |
| 161 | private: |
| 162 | QualcommCameraHardware(); |
| 163 | status_t startPreviewInternal(); |
| 164 | status_t startRecordingInternal(); |
| 165 | status_t setHistogramOn(); |
| 166 | status_t setHistogramOff(); |
| 167 | status_t runFaceDetection(); |
| 168 | status_t setFaceDetection(const char *str); |
| 169 | |
| 170 | void stopPreviewInternal(); |
| 171 | friend void *auto_focus_thread(void *user); |
| 172 | void runAutoFocus(); |
| 173 | status_t cancelAutoFocusInternal(); |
| 174 | bool native_set_dimension (int camfd); |
| 175 | bool native_jpeg_encode (void); |
| 176 | bool updatePictureDimension(const QCameraParameters& params, int& width, int& height); |
| 177 | bool native_set_parms(camera_parm_type_t type, uint16_t length, void *value); |
| 178 | bool native_set_parms(camera_parm_type_t type, uint16_t length, void *value, int *result); |
| 179 | bool native_zoom_image(int fd, int srcOffset, int dstOffset, common_crop_t *crop); |
| 180 | |
| 181 | status_t startInitialPreview(); |
| 182 | void stopInitialPreview(); |
| 183 | status_t getBuffersAndStartPreview(); |
| 184 | void relinquishBuffers(); |
| 185 | |
| 186 | QualcommCameraHardware * singleton; |
| 187 | |
| 188 | /* These constants reflect the number of buffers that libmmcamera requires |
| 189 | for preview and raw, and need to be updated when libmmcamera |
| 190 | changes. |
| 191 | */ |
| 192 | static const int kPreviewBufferCount = NUM_PREVIEW_BUFFERS; |
| 193 | static const int kRawBufferCount = 1; |
| 194 | static const int kJpegBufferCount = 1; |
| 195 | static const int kTotalPreviewBufferCount = kPreviewBufferCount + MIN_UNDEQUEUD_BUFFER_COUNT; |
| 196 | int numCapture; |
| 197 | int numJpegReceived; |
| 198 | int jpegPadding; |
| 199 | |
| 200 | QCameraParameters mParameters; |
| 201 | unsigned int frame_size; |
| 202 | bool mCameraRunning; |
| 203 | Mutex mCameraRunningLock; |
| 204 | bool mPreviewInitialized; |
| 205 | |
| 206 | |
| 207 | class MMCameraDL : public RefBase{ |
| 208 | private: |
| 209 | static wp<MMCameraDL> instance; |
| 210 | MMCameraDL(); |
| 211 | virtual ~MMCameraDL(); |
| 212 | void *libmmcamera; |
| 213 | static Mutex singletonLock; |
| 214 | public: |
| 215 | static sp<MMCameraDL> getInstance(); |
| 216 | void * pointer(); |
| 217 | }; |
| 218 | |
| 219 | // This class represents a heap which maintains several contiguous |
| 220 | // buffers. The heap may be backed by pmem (when pmem_pool contains |
| 221 | // the name of a /dev/pmem* file), or by ashmem (when pmem_pool == NULL). |
| 222 | struct MemPool : public RefBase { |
| 223 | MemPool(int buffer_size, int num_buffers, |
| 224 | int frame_size, |
| 225 | const char *name); |
| 226 | |
| 227 | virtual ~MemPool() ;// = 0; |
| 228 | |
| 229 | void completeInitialization(); |
| 230 | bool initialized() const { |
| 231 | return mHeap != NULL && mHeap->base() != MAP_FAILED; |
| 232 | } |
| 233 | |
| 234 | virtual status_t dump(int fd, const Vector<String16>& args) const; |
| 235 | |
| 236 | int mBufferSize; |
| 237 | int mAlignedBufferSize; |
| 238 | int mNumBuffers; |
| 239 | int mFrameSize; |
| 240 | sp<MemoryHeapBase> mHeap; |
| 241 | sp<MemoryBase> *mBuffers; |
| 242 | |
| 243 | const char *mName; |
| 244 | }; |
| 245 | struct DispMemPool : public MemPool { |
| 246 | DispMemPool(int fd, int buffer_size, |
| 247 | int num_buffers, int frame_size, |
| 248 | const char *name); |
| 249 | virtual ~DispMemPool(); |
| 250 | int mFD; |
| 251 | }; |
| 252 | sp<DispMemPool> mPreviewHeap[kPreviewBufferCount + MIN_UNDEQUEUD_BUFFER_COUNT]; |
| 253 | |
| 254 | struct AshmemPool : public MemPool { |
| 255 | AshmemPool(int buffer_size, int num_buffers, |
| 256 | int frame_size, |
| 257 | const char *name); |
| 258 | }; |
| 259 | |
| 260 | struct PmemPool : public MemPool { |
| 261 | PmemPool(const char *pmem_pool, |
| 262 | int flags, int pmem_type, |
| 263 | int buffer_size, int num_buffers, |
| 264 | int frame_size, int cbcr_offset, |
| 265 | int yoffset, const char *name); |
| 266 | virtual ~PmemPool(); |
| 267 | int mFd; |
| 268 | int mPmemType; |
| 269 | int mCbCrOffset; |
| 270 | int myOffset; |
| 271 | int mCameraControlFd; |
| 272 | uint32_t mAlignedSize; |
| 273 | struct pmem_region mSize; |
| 274 | sp<QualcommCameraHardware::MMCameraDL> mMMCameraDLRef; |
| 275 | }; |
| 276 | //TODO |
| 277 | struct IonPool : public MemPool { |
| 278 | IonPool( int ion_heap_id, int flags, int ion_type, |
| 279 | int buffer_size, int num_buffers, |
| 280 | int frame_size, int cbcr_offset, |
| 281 | int yoffset, const char *name); |
| 282 | virtual ~IonPool(); |
| 283 | int mFd; |
| 284 | int mIonType; |
| 285 | int mCbCrOffset; |
| 286 | int myOffset; |
| 287 | int mCameraControlFd; |
| 288 | uint32_t mAlignedSize; |
| 289 | sp<QualcommCameraHardware::MMCameraDL> mMMCameraDLRef; |
| 290 | static const char mIonDevName[]; |
| 291 | }; |
| 292 | #ifdef USE_ION |
| 293 | // sp<IonPool> mPreviewHeap; |
| 294 | sp<IonPool> mYV12Heap; |
| 295 | sp<IonPool> mRecordHeap; |
| 296 | sp<IonPool> mThumbnailHeap; |
| 297 | sp<IonPool> mRawHeap; |
| 298 | sp<IonPool> mDisplayHeap; |
| 299 | sp<AshmemPool> mJpegHeap; |
| 300 | sp<AshmemPool> mStatHeap; |
| 301 | sp<AshmemPool> mMetaDataHeap; |
| 302 | sp<IonPool> mRawSnapShotPmemHeap; |
| 303 | sp<IonPool> mLastPreviewFrameHeap; |
| 304 | sp<IonPool> mPostviewHeap; |
| 305 | #else |
| 306 | // sp<PmemPool> mPreviewHeap; |
| 307 | sp<PmemPool> mYV12Heap; |
| 308 | sp<PmemPool> mRecordHeap; |
| 309 | sp<PmemPool> mThumbnailHeap; |
| 310 | sp<PmemPool> mRawHeap; |
| 311 | sp<PmemPool> mDisplayHeap; |
| 312 | sp<AshmemPool> mJpegHeap; |
| 313 | sp<AshmemPool> mStatHeap; |
| 314 | sp<AshmemPool> mMetaDataHeap; |
| 315 | sp<PmemPool> mRawSnapShotPmemHeap; |
| 316 | sp<PmemPool> mLastPreviewFrameHeap; |
| 317 | sp<PmemPool> mPostviewHeap; |
| 318 | sp<PmemPool> mPostViewHeap; |
| 319 | sp<PmemPool> mInitialPreviewHeap; |
| 320 | #endif |
| 321 | |
| 322 | sp<MMCameraDL> mMMCameraDLRef; |
| 323 | |
| 324 | bool startCamera(); |
| 325 | bool initPreview(); |
| 326 | bool initRecord(); |
| 327 | void deinitPreview(); |
| 328 | bool initRaw(bool initJpegHeap); |
| 329 | bool initZslBuffers(bool initJpegHeap); |
| 330 | bool deinitZslBuffers(); |
| 331 | bool initLiveSnapshot(int videowidth, int videoheight); |
| 332 | bool initRawSnapshot(); |
| 333 | void deinitRaw(); |
| 334 | void deinitRawSnapshot(); |
| 335 | bool mPreviewThreadRunning; |
| 336 | bool createSnapshotMemory (int numberOfRawBuffers, int numberOfJpegBuffers, |
| 337 | bool initJpegHeap, int snapshotFormat = 1 /*PICTURE_FORMAT_JPEG*/); |
| 338 | Mutex mPreviewThreadWaitLock; |
| 339 | Condition mPreviewThreadWait; |
| 340 | friend void *preview_thread(void *user); |
| 341 | friend void *openCamera(void *data); |
| 342 | void runPreviewThread(void *data); |
| 343 | friend void *hfr_thread(void *user); |
| 344 | void runHFRThread(void *data); |
| 345 | bool mHFRThreadRunning; |
| 346 | int mapBuffer(msm_frame *frame); |
| 347 | int mapRawBuffer(msm_frame *frame); |
| 348 | int mapThumbnailBuffer(msm_frame *frame); |
| 349 | int mapJpegBuffer(mm_camera_buffer_t* buffer); |
| 350 | int mapvideoBuffer( msm_frame *frame); |
| 351 | int mapFrame(buffer_handle_t *buffer); |
| 352 | Mutex mHFRThreadWaitLock; |
| 353 | |
| 354 | class FrameQueue : public RefBase{ |
| 355 | private: |
| 356 | Mutex mQueueLock; |
| 357 | Condition mQueueWait; |
| 358 | bool mInitialized; |
| 359 | |
| 360 | Vector<struct msm_frame *> mContainer; |
| 361 | public: |
| 362 | FrameQueue(); |
| 363 | virtual ~FrameQueue(); |
| 364 | bool add(struct msm_frame *element); |
| 365 | void flush(); |
| 366 | struct msm_frame* get(); |
| 367 | void init(); |
| 368 | void deinit(); |
| 369 | bool isInitialized(); |
| 370 | }; |
| 371 | |
| 372 | FrameQueue mPreviewBusyQueue; |
| 373 | |
| 374 | bool mFrameThreadRunning; |
| 375 | Mutex mFrameThreadWaitLock; |
| 376 | Condition mFrameThreadWait; |
| 377 | friend void *frame_thread(void *user); |
| 378 | void runFrameThread(void *data); |
| 379 | |
| 380 | //720p recording video thread |
| 381 | bool mVideoThreadExit; |
| 382 | bool mVideoThreadRunning; |
| 383 | Mutex mVideoThreadWaitLock; |
| 384 | Condition mVideoThreadWait; |
| 385 | friend void *video_thread(void *user); |
| 386 | void runVideoThread(void *data); |
| 387 | |
| 388 | // smooth zoom |
| 389 | int mTargetSmoothZoom; |
| 390 | bool mSmoothzoomThreadExit; |
| 391 | bool mSmoothzoomThreadRunning; |
| 392 | Mutex mSmoothzoomThreadWaitLock; |
| 393 | Mutex mSmoothzoomThreadLock; |
| 394 | Condition mSmoothzoomThreadWait; |
| 395 | friend void *smoothzoom_thread(void *user); |
| 396 | void runSmoothzoomThread(void* data); |
| 397 | |
| 398 | // For Histogram |
| 399 | int mStatsOn; |
| 400 | int mCurrent; |
| 401 | bool mSendData; |
| 402 | Mutex mStatsWaitLock; |
| 403 | Condition mStatsWait; |
| 404 | |
| 405 | //For Face Detection |
| 406 | int mFaceDetectOn; |
| 407 | bool mSendMetaData; |
| 408 | Mutex mMetaDataWaitLock; |
| 409 | |
| 410 | bool mShutterPending; |
| 411 | Mutex mShutterLock; |
| 412 | |
| 413 | bool mSnapshotThreadRunning; |
| 414 | Mutex mSnapshotThreadWaitLock; |
| 415 | Condition mSnapshotThreadWait; |
| 416 | friend void *snapshot_thread(void *user); |
| 417 | void runSnapshotThread(void *data); |
| 418 | Mutex mRawPictureHeapLock; |
| 419 | bool mJpegThreadRunning; |
| 420 | Mutex mJpegThreadWaitLock; |
| 421 | Condition mJpegThreadWait; |
| 422 | bool mInSnapshotMode; |
| 423 | Mutex mInSnapshotModeWaitLock; |
| 424 | Condition mInSnapshotModeWait; |
| 425 | bool mEncodePending; |
| 426 | Mutex mEncodePendingWaitLock; |
| 427 | Condition mEncodePendingWait; |
| 428 | bool mBuffersInitialized; |
| 429 | |
| 430 | void debugShowPreviewFPS() const; |
| 431 | void debugShowVideoFPS() const; |
| 432 | |
| 433 | int mSnapshotFormat; |
| 434 | bool mFirstFrame; |
| 435 | void hasAutoFocusSupport(); |
| 436 | void filterPictureSizes(); |
| 437 | void filterPreviewSizes(); |
| 438 | static void storeTargetType(); |
| 439 | bool supportsSceneDetection(); |
| 440 | bool supportsSelectableZoneAf(); |
| 441 | bool supportsFaceDetection(); |
| 442 | |
| 443 | void initDefaultParameters(); |
| 444 | bool initImageEncodeParameters(int size); |
| 445 | bool initZslParameter(void); |
| 446 | status_t setCameraMode(const QCameraParameters& params); |
| 447 | status_t setPreviewSize(const QCameraParameters& params); |
| 448 | status_t setJpegThumbnailSize(const QCameraParameters& params); |
| 449 | status_t setPreviewFpsRange(const QCameraParameters& params); |
| 450 | status_t setPreviewFrameRate(const QCameraParameters& params); |
| 451 | status_t setPreviewFrameRateMode(const QCameraParameters& params); |
| 452 | status_t setRecordSize(const QCameraParameters& params); |
| 453 | status_t setPictureSize(const QCameraParameters& params); |
| 454 | status_t setJpegQuality(const QCameraParameters& params); |
| 455 | status_t setAntibanding(const QCameraParameters& params); |
| 456 | status_t setEffect(const QCameraParameters& params); |
| 457 | status_t setRecordingHint(const QCameraParameters& params); |
| 458 | status_t setExposureCompensation(const QCameraParameters ¶ms); |
| 459 | status_t setAutoExposure(const QCameraParameters& params); |
| 460 | status_t setWhiteBalance(const QCameraParameters& params); |
| 461 | status_t setFlash(const QCameraParameters& params); |
| 462 | status_t setGpsLocation(const QCameraParameters& params); |
| 463 | status_t setRotation(const QCameraParameters& params); |
| 464 | status_t setZoom(const QCameraParameters& params); |
| 465 | status_t setFocusMode(const QCameraParameters& params); |
| 466 | status_t setFocusAreas(const QCameraParameters& params); |
| 467 | status_t setMeteringAreas(const QCameraParameters& params); |
| 468 | status_t setBrightness(const QCameraParameters& params); |
| 469 | status_t setSkinToneEnhancement(const QCameraParameters& params); |
| 470 | status_t setOrientation(const QCameraParameters& params); |
| 471 | status_t setLensshadeValue(const QCameraParameters& params); |
| 472 | status_t setMCEValue(const QCameraParameters& params); |
| 473 | status_t setHDRImaging(const QCameraParameters& params); |
| 474 | status_t setExpBracketing(const QCameraParameters& params); |
| 475 | status_t setISOValue(const QCameraParameters& params); |
| 476 | status_t setPictureFormat(const QCameraParameters& params); |
| 477 | status_t setSharpness(const QCameraParameters& params); |
| 478 | status_t setContrast(const QCameraParameters& params); |
| 479 | status_t setSaturation(const QCameraParameters& params); |
| 480 | status_t setSceneMode(const QCameraParameters& params); |
| 481 | status_t setContinuousAf(const QCameraParameters& params); |
| 482 | status_t setTouchAfAec(const QCameraParameters& params); |
| 483 | status_t setSceneDetect(const QCameraParameters& params); |
| 484 | status_t setStrTextures(const QCameraParameters& params); |
| 485 | status_t setPreviewFormat(const QCameraParameters& params); |
| 486 | status_t setSelectableZoneAf(const QCameraParameters& params); |
| 487 | status_t setHighFrameRate(const QCameraParameters& params); |
| 488 | bool register_record_buffers(bool register_buffer); |
| 489 | status_t setRedeyeReduction(const QCameraParameters& params); |
| 490 | status_t setDenoise(const QCameraParameters& params); |
| 491 | status_t setZslParam(const QCameraParameters& params); |
| 492 | status_t setSnapshotCount(const QCameraParameters& params); |
| 493 | void setGpsParameters(); |
| 494 | bool storePreviewFrameForPostview(); |
| 495 | bool isValidDimension(int w, int h); |
| 496 | status_t updateFocusDistances(const char *focusmode); |
| 497 | int mStoreMetaDataInFrame; |
| 498 | |
| 499 | Mutex mLock; |
| 500 | Mutex mDisplayLock; |
| 501 | Mutex mCamframeTimeoutLock; |
| 502 | bool camframe_timeout_flag; |
| 503 | bool mReleasedRecordingFrame; |
| 504 | |
| 505 | Mutex mParametersLock; |
| 506 | |
| 507 | |
| 508 | Mutex mCallbackLock; |
| 509 | Mutex mOverlayLock; |
| 510 | Mutex mRecordLock; |
| 511 | Mutex mRecordFrameLock; |
| 512 | Condition mRecordWait; |
| 513 | Condition mStateWait; |
| 514 | |
| 515 | /* mJpegSize keeps track of the size of the accumulated JPEG. We clear it |
| 516 | when we are about to take a picture, so at any time it contains either |
| 517 | zero, or the size of the last JPEG picture taken. |
| 518 | */ |
| 519 | uint32_t mJpegSize; |
| 520 | unsigned int mPreviewFrameSize; |
| 521 | unsigned int mRecordFrameSize; |
| 522 | int mRawSize; |
| 523 | int mCbCrOffsetRaw; |
| 524 | int mYOffset; |
| 525 | int mJpegMaxSize; |
| 526 | int32_t mStatSize; |
| 527 | |
| 528 | |
| 529 | cam_ctrl_dimension_t mDimension; |
| 530 | bool mAutoFocusThreadRunning; |
| 531 | Mutex mAutoFocusThreadLock; |
| 532 | |
| 533 | Mutex mAfLock; |
| 534 | |
| 535 | pthread_t mFrameThread; |
| 536 | pthread_t mVideoThread; |
| 537 | pthread_t mPreviewThread; |
| 538 | pthread_t mSnapshotThread; |
| 539 | pthread_t mDeviceOpenThread; |
| 540 | pthread_t mSmoothzoomThread; |
| 541 | pthread_t mHFRThread; |
| 542 | |
| 543 | common_crop_t mCrop; |
| 544 | |
| 545 | bool mInitialized; |
| 546 | |
| 547 | int mBrightness; |
| 548 | int mSkinToneEnhancement; |
| 549 | int mHJR; |
| 550 | unsigned int mThumbnailMapped[MAX_SNAPSHOT_BUFFERS]; |
| 551 | unsigned int mThumbnailLockState[MAX_SNAPSHOT_BUFFERS]; |
| 552 | int mRawfd[MAX_SNAPSHOT_BUFFERS]; |
| 553 | int mRawSnapshotfd; |
| 554 | int mJpegfd[MAX_SNAPSHOT_BUFFERS]; |
| 555 | int mRecordfd[9]; |
| 556 | camera_memory_t *mPreviewMapped[kPreviewBufferCount + MIN_UNDEQUEUD_BUFFER_COUNT]; |
| 557 | camera_memory_t *mRawMapped[MAX_SNAPSHOT_BUFFERS]; |
| 558 | camera_memory_t *mJpegMapped[MAX_SNAPSHOT_BUFFERS]; |
| 559 | camera_memory_t *mRawSnapshotMapped; |
| 560 | camera_memory_t *mStatsMapped[3]; |
| 561 | camera_memory_t *mRecordMapped[9]; |
| 562 | camera_memory_t *mJpegCopyMapped; |
| 563 | camera_memory_t* metadata_memory[9]; |
| 564 | camera_memory_t *mJpegLiveSnapMapped; |
| 565 | int raw_main_ion_fd[MAX_SNAPSHOT_BUFFERS]; |
| 566 | int raw_snapshot_main_ion_fd; |
| 567 | int Jpeg_main_ion_fd[MAX_SNAPSHOT_BUFFERS]; |
| 568 | int record_main_ion_fd[9]; |
| 569 | struct ion_allocation_data raw_alloc[MAX_SNAPSHOT_BUFFERS]; |
| 570 | struct ion_allocation_data raw_snapshot_alloc; |
| 571 | struct ion_allocation_data Jpeg_alloc[MAX_SNAPSHOT_BUFFERS]; |
| 572 | struct ion_allocation_data record_alloc[9]; |
| 573 | struct ion_fd_data raw_ion_info_fd[MAX_SNAPSHOT_BUFFERS]; |
| 574 | struct ion_fd_data raw_snapshot_ion_info_fd; |
| 575 | struct ion_fd_data Jpeg_ion_info_fd[MAX_SNAPSHOT_BUFFERS]; |
| 576 | struct ion_fd_data record_ion_info_fd[9]; |
| 577 | |
| 578 | struct msm_frame frames[kPreviewBufferCount + MIN_UNDEQUEUD_BUFFER_COUNT]; |
| 579 | struct buffer_map frame_buffer[kPreviewBufferCount + MIN_UNDEQUEUD_BUFFER_COUNT]; |
| 580 | struct msm_frame *recordframes; |
| 581 | struct msm_frame *rawframes; |
| 582 | bool *record_buffers_tracking_flag; |
| 583 | bool mInPreviewCallback; |
| 584 | preview_stream_ops_t* mPreviewWindow; |
| 585 | android_native_buffer_t *mPostViewBuffer; |
| 586 | buffer_handle_t *mThumbnailBuffer[MAX_SNAPSHOT_BUFFERS]; |
| 587 | bool mIs3DModeOn; |
| 588 | |
| 589 | int32_t mMsgEnabled; // camera msg to be handled |
| 590 | camera_notify_callback mNotifyCallback; |
| 591 | camera_data_callback mDataCallback; |
| 592 | camera_data_timestamp_callback mDataCallbackTimestamp; |
| 593 | camera_request_memory mGetMemory; |
| 594 | void *mCallbackCookie; // same for all callbacks |
| 595 | int mDebugFps; |
| 596 | int kPreviewBufferCountActual; |
| 597 | int previewWidth, previewHeight; |
| 598 | int yv12framesize; |
| 599 | bool mSnapshotDone; |
| 600 | int maxSnapshotWidth; |
| 601 | int maxSnapshotHeight; |
| 602 | bool mHasAutoFocusSupport; |
| 603 | int videoWidth, videoHeight; |
| 604 | |
| 605 | bool mDisEnabled; |
| 606 | int mRotation; |
| 607 | bool mResetWindowCrop; |
| 608 | int mThumbnailWidth, mThumbnailHeight; |
| 609 | status_t setVpeParameters(); |
| 610 | status_t setDIS(); |
| 611 | bool strTexturesOn; |
| 612 | int mPictureWidth; |
| 613 | int mPictureHeight; |
| 614 | int mPostviewWidth; |
| 615 | int mPostviewHeight; |
| 616 | int mTotalPreviewBufferCount; |
| 617 | int mDenoiseValue; |
| 618 | int mZslEnable; |
| 619 | int mZslPanorama; |
| 620 | bool mZslFlashEnable; |
| 621 | cam_3d_frame_format_t mSnapshot3DFormat; |
| 622 | bool mSnapshotCancel; |
| 623 | bool mHFRMode; |
| 624 | Mutex mSnapshotCancelLock; |
| 625 | int mActualPictWidth; |
| 626 | int mActualPictHeight; |
| 627 | bool mUseJpegDownScaling; |
| 628 | bool mPreviewStopping; |
| 629 | bool mInHFRThread; |
| 630 | Mutex mPmemWaitLock; |
| 631 | Condition mPmemWait; |
| 632 | bool mPrevHeapDeallocRunning; |
| 633 | bool mHdrMode; |
| 634 | bool mExpBracketMode; |
| 635 | |
| 636 | bool mMultiTouch; |
| 637 | |
| 638 | int mRecordingState; |
| 639 | |
| 640 | int mNumFDRcvd; |
| 641 | int mFacesDetected; |
| 642 | int mFaceArray[MAX_ROI * 4 + 1]; |
| 643 | |
| 644 | }; |
| 645 | |
| 646 | extern "C" int HAL_getNumberOfCameras(); |
| 647 | extern "C" void HAL_getCameraInfo(int cameraId, struct CameraInfo* cameraInfo); |
| 648 | extern "C" QualcommCameraHardware* HAL_openCameraHardware(int cameraId); |
| 649 | }; // namespace android |
| 650 | |
| 651 | #endif |