summaryrefslogtreecommitdiff
path: root/camera/QCameraHWI.h
blob: 1a1604c6223da506813691a65e7b82a542a44093 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
/*
** Copyright (c) 2011-2012, 2015, The Linux Foundation. All rights reserved.
**
** 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 ANDROID_HARDWARE_QCAMERA_HARDWARE_INTERFACE_H
#define ANDROID_HARDWARE_QCAMERA_HARDWARE_INTERFACE_H


#include <utils/threads.h>
//#include <camera/CameraHardwareInterface.h>
#include <hardware/camera.h>
#include <binder/MemoryBase.h>
#include <binder/MemoryHeapBase.h>
//#include <binder/MemoryHeapPmem.h>
#include <utils/threads.h>
#include <cutils/properties.h>
#include <camera/Camera.h>
#include "QCameraParameters.h"
#include <system/window.h>
#include <system/camera.h>
#include <hardware/camera.h>
#include <gralloc_priv.h>
#include <QComOMXMetadata.h>

extern "C" {
#include <linux/msm_ion.h>
#include <mm_camera_interface2.h>
#include "mm_omx_jpeg_encoder.h"
} //extern C

#include "QCameraHWI_Mem.h"
#include "QCameraStream.h"
#include "QCamera_Intf.h"

#include "hdr/include/morpho_noise_reduction_ext.h"
//Error codes
#define  NOT_FOUND -1
#define MAX_ZOOM_RATIOS 62

#ifdef Q12
#undef Q12
#endif

#define Q12 4096
#define QCAMERA_PARM_ENABLE   1
#define QCAMERA_PARM_DISABLE  0
#define PREVIEW_TBL_MAX_SIZE  14
#define VIDEO_TBL_MAX_SIZE    14
#define THUMB_TBL_MAX_SIZE    16
#define HFR_TBL_MAX_SIZE      2

struct str_map {
    const char *const desc;
    int val;
};

struct preview_format_info_t {
   int Hal_format;
   cam_format_t mm_cam_format;
   cam_pad_format_t padding;
   int num_planar;
};

typedef enum {
  CAMERA_STATE_UNINITED,
  CAMERA_STATE_READY,
  CAMERA_STATE_PREVIEW_START_CMD_SENT,
  CAMERA_STATE_PREVIEW_STOP_CMD_SENT,
  CAMERA_STATE_PREVIEW,
  CAMERA_STATE_RECORD_START_CMD_SENT,  /*5*/
  CAMERA_STATE_RECORD_STOP_CMD_SENT,
  CAMERA_STATE_RECORD,
  CAMERA_STATE_SNAP_START_CMD_SENT,
  CAMERA_STATE_SNAP_STOP_CMD_SENT,
  CAMERA_STATE_SNAP_CMD_ACKED,  /*10 - snapshot comd acked, snapshot not done yet*/
  CAMERA_STATE_ZSL_START_CMD_SENT,
  CAMERA_STATE_ZSL,
  CAMERA_STATE_AF_START_CMD_SENT,
  CAMERA_STATE_AF_STOP_CMD_SENT,
  CAMERA_STATE_ERROR, /*15*/

  /*Add any new state above*/
  CAMERA_STATE_MAX
} HAL_camera_state_type_t;

enum {
  BUFFER_NOT_OWNED,
  BUFFER_UNLOCKED,
  BUFFER_LOCKED,
};

typedef enum {
  HAL_DUMP_FRM_PREVIEW = 1,
  HAL_DUMP_FRM_VIDEO = 1<<1,
  HAL_DUMP_FRM_MAIN = 1<<2,
  HAL_DUMP_FRM_THUMBNAIL = 1<<3,

  /*8 bits mask*/
  HAL_DUMP_FRM_MAX = 1 << 8
} HAL_cam_dump_frm_type_t;


typedef enum {
  HAL_CAM_MODE_ZSL = 1,

  /*add new entry before and update the max entry*/
  HAL_CAM_MODE_MAX = HAL_CAM_MODE_ZSL << 1,
} qQamera_mode_t;

#define HAL_DUMP_FRM_MASK_ALL ( HAL_DUMP_FRM_PREVIEW + HAL_DUMP_FRM_VIDEO + \
    HAL_DUMP_FRM_MAIN + HAL_DUMP_FRM_THUMBNAIL)
#define QCAMERA_HAL_PREVIEW_STOPPED    0
#define QCAMERA_HAL_PREVIEW_START      1
#define QCAMERA_HAL_PREVIEW_STARTED    2
#define QCAMERA_HAL_RECORDING_STARTED  3
#define QCAMERA_HAL_TAKE_PICTURE       4


typedef struct {
     int                     buffer_count;
	 buffer_handle_t        *buffer_handle[MM_CAMERA_MAX_NUM_FRAMES];
	 struct private_handle_t *private_buffer_handle[MM_CAMERA_MAX_NUM_FRAMES];
	 int                     stride[MM_CAMERA_MAX_NUM_FRAMES];
	 uint32_t                addr_offset[MM_CAMERA_MAX_NUM_FRAMES];
	 uint8_t                 local_flag[MM_CAMERA_MAX_NUM_FRAMES];
	 camera_memory_t        *camera_memory[MM_CAMERA_MAX_NUM_FRAMES];
     int                     main_ion_fd[MM_CAMERA_MAX_NUM_FRAMES];
     struct ion_fd_data      ion_info_fd[MM_CAMERA_MAX_NUM_FRAMES];
} QCameraHalMemory_t;


typedef struct {
     int                     buffer_count;
     uint32_t                size;
     uint32_t                y_offset;
     uint32_t                cbcr_offset;
	 int                     fd[MM_CAMERA_MAX_NUM_FRAMES];
	 int                     local_flag[MM_CAMERA_MAX_NUM_FRAMES];
	 camera_memory_t*        camera_memory[MM_CAMERA_MAX_NUM_FRAMES];
     camera_memory_t*        metadata_memory[MM_CAMERA_MAX_NUM_FRAMES];
     int main_ion_fd[MM_CAMERA_MAX_NUM_FRAMES];
     struct ion_allocation_data alloc[MM_CAMERA_MAX_NUM_FRAMES];
     struct ion_fd_data ion_info_fd[MM_CAMERA_MAX_NUM_FRAMES];
} QCameraHalHeap_t;

typedef struct {
     camera_memory_t*  camera_memory[3];
     int main_ion_fd[3];
     struct ion_allocation_data alloc[3];
     struct ion_fd_data ion_info_fd[3];
     int fd[3];
     int size;
} QCameraStatHeap_t;

typedef struct {
  int32_t msg_type;
  int32_t ext1;
  int32_t ext2;
  void    *cookie;
} argm_notify_t;

typedef struct {
  int32_t                  msg_type;
  camera_memory_t         *data;
  unsigned int             index;
  camera_frame_metadata_t *metadata;
  void                    *cookie;
} argm_data_cb_t;

typedef struct {
  camera_notify_callback notifyCb;
  camera_data_callback   dataCb;
  argm_notify_t argm_notify;
  argm_data_cb_t        argm_data_cb;
} app_notify_cb_t;

/* camera_area_t
 * rectangle with weight to store the focus and metering areas.
 * x1, y1, x2, y2: from -1000 to 1000
 * weight: 0 to 1000
 */
typedef struct {
    int x1, y1, x2, y2;
    int weight;
} camera_area_t;

//EXIF globals
static const char ExifAsciiPrefix[] = { 0x41, 0x53, 0x43, 0x49, 0x49, 0x0, 0x0, 0x0 };          // "ASCII\0\0\0"
static const char ExifUndefinedPrefix[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };   // "\0\0\0\0\0\0\0\0"

//EXIF detfines
#define MAX_EXIF_TABLE_ENTRIES           23
#define GPS_PROCESSING_METHOD_SIZE       101
#define FOCAL_LENGTH_DECIMAL_PRECISION   100
#define EXIF_ASCII_PREFIX_SIZE           8   //(sizeof(ExifAsciiPrefix))
#define F_NUMBER_DECIMAL_PRECISION       100

typedef struct{
    //GPS tags
    rat_t       latitude[3];
    rat_t       longitude[3];
    char        lonRef[2];
    char        latRef[2];
    rat_t       altitude;
    rat_t       gpsTimeStamp[3];
    char        gpsDateStamp[20];
    char        gpsProcessingMethod[EXIF_ASCII_PREFIX_SIZE+GPS_PROCESSING_METHOD_SIZE];
    //Other tags
    char        dateTime[20];
    char subsecTime[7];
    rat_t       focalLength;
    rat_t       f_number;
    uint16_t    flashMode;
    uint16_t    isoSpeed;
    rat_t       exposure_time;

    bool        mAltitude;
    bool        mLongitude;
    bool        mLatitude;
    bool        mTimeStamp;
    bool        mGpsProcess;

    int         mAltitude_ref;
    long        mGPSTimestamp;
    int         mWbMode;
    char        make[20];
    char        model[20];

} exif_values_t;

namespace android {

class QCameraStream;

class QCameraHardwareInterface : public virtual RefBase {
public:

    QCameraHardwareInterface(int  cameraId, int mode);

    /** Set the ANativeWindow to which preview frames are sent */
    int setPreviewWindow(preview_stream_ops_t* window);

    /** Set the notification and data callbacks */
    void setCallbacks(camera_notify_callback notify_cb,
            camera_data_callback data_cb,
            camera_data_timestamp_callback data_cb_timestamp,
            camera_request_memory get_memory,
            void *user);

    /**
     * The following three functions all take a msg_type, which is a bitmask of
     * the messages defined in include/ui/Camera.h
     */

    /**
     * Enable a message, or set of messages.
     */
    void enableMsgType(int32_t msg_type);

    /**
     * Disable a message, or a set of messages.
     *
     * Once received a call to disableMsgType(CAMERA_MSG_VIDEO_FRAME), camera
     * HAL should not rely on its client to call releaseRecordingFrame() to
     * release video recording frames sent out by the cameral HAL before and
     * after the disableMsgType(CAMERA_MSG_VIDEO_FRAME) call. Camera HAL
     * clients must not modify/access any video recording frame after calling
     * disableMsgType(CAMERA_MSG_VIDEO_FRAME).
     */
    void disableMsgType(int32_t msg_type);

    /**
     * Query whether a message, or a set of messages, is enabled.  Note that
     * this is operates as an AND, if any of the messages queried are off, this
     * will return false.
     */
    int msgTypeEnabled(int32_t msg_type);

    /**
     * Start preview mode.
     */
    int startPreview();
    int startPreview2();

    /**
     * Stop a previously started preview.
     */
    void stopPreview();

    /**
     * Returns true if preview is enabled.
     */
    int previewEnabled();


    /**
     * Request the camera HAL to store meta data or real YUV data in the video
     * buffers sent out via CAMERA_MSG_VIDEO_FRAME for a recording session. If
     * it is not called, the default camera HAL behavior is to store real YUV
     * data in the video buffers.
     *
     * This method should be called before startRecording() in order to be
     * effective.
     *
     * If meta data is stored in the video buffers, it is up to the receiver of
     * the video buffers to interpret the contents and to find the actual frame
     * data with the help of the meta data in the buffer. How this is done is
     * outside of the scope of this method.
     *
     * Some camera HALs may not support storing meta data in the video buffers,
     * but all camera HALs should support storing real YUV data in the video
     * buffers. If the camera HAL does not support storing the meta data in the
     * video buffers when it is requested to do do, INVALID_OPERATION must be
     * returned. It is very useful for the camera HAL to pass meta data rather
     * than the actual frame data directly to the video encoder, since the
     * amount of the uncompressed frame data can be very large if video size is
     * large.
     *
     * @param enable if true to instruct the camera HAL to store
     *        meta data in the video buffers; false to instruct
     *        the camera HAL to store real YUV data in the video
     *        buffers.
     *
     * @return OK on success.
     */
    int storeMetaDataInBuffers(int enable);

    /**
     * Start record mode. When a record image is available, a
     * CAMERA_MSG_VIDEO_FRAME message is sent with the corresponding
     * frame. Every record frame must be released by a camera HAL client via
     * releaseRecordingFrame() before the client calls
     * disableMsgType(CAMERA_MSG_VIDEO_FRAME). After the client calls
     * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's
     * responsibility to manage the life-cycle of the video recording frames,
     * and the client must not modify/access any video recording frames.
     */
    int startRecording();

    /**
     * Stop a previously started recording.
     */
    void stopRecording();

    /**
     * Returns true if recording is enabled.
     */
    int recordingEnabled();

    /**
     * Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME.
     *
     * It is camera HAL client's responsibility to release video recording
     * frames sent out by the camera HAL before the camera HAL receives a call
     * to disableMsgType(CAMERA_MSG_VIDEO_FRAME). After it receives the call to
     * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's
     * responsibility to manage the life-cycle of the video recording frames.
     */
    void releaseRecordingFrame(const void *opaque);

    /**
     * Start auto focus, the notification callback routine is called with
     * CAMERA_MSG_FOCUS once when focusing is complete. autoFocus() will be
     * called again if another auto focus is needed.
     */
    int autoFocus();

    /**
     * Cancels auto-focus function. If the auto-focus is still in progress,
     * this function will cancel it. Whether the auto-focus is in progress or
     * not, this function will return the focus position to the default.  If
     * the camera does not support auto-focus, this is a no-op.
     */
    int cancelAutoFocus();

    /**
     * Take a picture.
     */
    int takePicture();

    /**
     * Cancel a picture that was started with takePicture. Calling this method
     * when no picture is being taken is a no-op.
     */
    int cancelPicture();

    /**
     * Set the camera parameters. This returns BAD_VALUE if any parameter is
     * invalid or not supported.
     */
    int setParameters(const char *parms);

    //status_t setParameters(const QCameraParameters& params);
    /** Retrieve the camera parameters.  The buffer returned by the camera HAL
        must be returned back to it with put_parameters, if put_parameters
        is not NULL.
     */
    int getParameters(char **parms);

    /** The camera HAL uses its own memory to pass us the parameters when we
        call get_parameters.  Use this function to return the memory back to
        the camera HAL, if put_parameters is not NULL.  If put_parameters
        is NULL, then you have to use free() to release the memory.
    */
    void putParameters(char *);

    /**
     * Send command to camera driver.
     */
    int sendCommand(int32_t cmd, int32_t arg1, int32_t arg2);

    /**
     * Release the hardware resources owned by this object.  Note that this is
     * *not* done in the destructor.
     */
    void release();

    /**
     * Dump state of the camera hardware
     */
    int dump(int fd);

    //virtual sp<IMemoryHeap> getPreviewHeap() const;
    //virtual sp<IMemoryHeap> getRawHeap() const;


    status_t    takeLiveSnapshot();
    status_t    takeFullSizeLiveshot();
    bool        canTakeFullSizeLiveshot();

    //virtual status_t          getBufferInfo( sp<IMemory>& Frame,
    //size_t *alignedSize);
    void         getPictureSize(int *picture_width, int *picture_height) const;
    void         getPreviewSize(int *preview_width, int *preview_height) const;
    cam_format_t getPreviewFormat() const;

    cam_pad_format_t getPreviewPadding() const;

    //bool     useOverlay(void);
    //virtual status_t setOverlay(const sp<Overlay> &overlay);
    void processEvent(mm_camera_event_t *);
    int  getJpegQuality() const;
    int  getNumOfSnapshots(void) const;
    int  getThumbSizesFromAspectRatio(uint32_t aspect_ratio,
                                     int *picture_width,
                                     int *picture_height);
    bool isRawSnapshot();
    bool mShutterSoundPlayed;
    void dumpFrameToFile(struct msm_frame*, HAL_cam_dump_frm_type_t);

    static QCameraHardwareInterface *createInstance(int, int);
    status_t setZSLBurstLookBack(const QCameraParameters& params);
    status_t setZSLBurstInterval(const QCameraParameters& params);
    int getZSLBurstInterval(void);
    int getZSLQueueDepth(void) const;
    int getZSLBackLookCount(void) const;

    ~QCameraHardwareInterface();
    int initHeapMem(QCameraHalHeap_t *heap, int num_of_buf, int pmem_type,
      int frame_len, int cbcr_off, int y_off, mm_cameara_stream_buf_t *StreamBuf,
      mm_camera_buf_def_t *buf_def, uint8_t num_planes, uint32_t *planes);

    int releaseHeapMem( QCameraHalHeap_t *heap);
    status_t sendMappingBuf(int ext_mode, int idx, int fd, uint32_t size,
      int cameraid, mm_camera_socket_msg_type msg_type);
    status_t sendUnMappingBuf(int ext_mode, int idx, int cameraid,
      mm_camera_socket_msg_type msg_type);

    int allocate_ion_memory(QCameraHalHeap_t *p_camera_memory, int cnt,
      int ion_type);
    int deallocate_ion_memory(QCameraHalHeap_t *p_camera_memory, int cnt);

    int allocate_ion_memory(QCameraStatHeap_t *p_camera_memory, int cnt,
      int ion_type);
    int deallocate_ion_memory(QCameraStatHeap_t *p_camera_memory, int cnt);

    int cache_ops(int ion_fd, struct ion_flush_data *cache_inv_data, int type);

    void dumpFrameToFile(const void * data, uint32_t size, char* name,
      char* ext, int index);
    preview_format_info_t getPreviewFormatInfo( );
    bool isCameraReady();

private:
    int16_t  zoomRatios[MAX_ZOOM_RATIOS];
    struct camera_size_type default_preview_sizes[PREVIEW_TBL_MAX_SIZE];
    struct camera_size_type default_video_sizes[VIDEO_TBL_MAX_SIZE];
    struct camera_size_type default_hfr_sizes[HFR_TBL_MAX_SIZE];
    struct camera_size_type default_thumbnail_sizes[THUMB_TBL_MAX_SIZE];
    unsigned int preview_sizes_count;
    unsigned int video_sizes_count;
    unsigned int thumbnail_sizes_count;
    unsigned int hfr_sizes_count;


    bool mUseOverlay;

    void loadTables();
    void initDefaultParameters();
    bool getMaxPictureDimension(mm_camera_dimension_t *dim);

    status_t updateFocusDistances();

    bool native_set_parms(mm_camera_parm_type_t type, uint16_t length, void *value);
    bool native_set_parms( mm_camera_parm_type_t type, uint16_t length, void *value, int *result);

    void hasAutoFocusSupport();
    void debugShowPreviewFPS() const;
    //void prepareSnapshotAndWait();

    bool isPreviewRunning();
    bool isRecordingRunning();
    bool isSnapshotRunning();

    void processChannelEvent(mm_camera_ch_event_t *, app_notify_cb_t *);
    void processPreviewChannelEvent(mm_camera_ch_event_type_t channelEvent, app_notify_cb_t *);
    void processRecordChannelEvent(mm_camera_ch_event_type_t channelEvent, app_notify_cb_t *);
    void processSnapshotChannelEvent(mm_camera_ch_event_type_t channelEvent, app_notify_cb_t *);
    void processCtrlEvent(mm_camera_ctrl_event_t *, app_notify_cb_t *);
    void processStatsEvent(mm_camera_stats_event_t *, app_notify_cb_t *);
    void processInfoEvent(mm_camera_info_event_t *event, app_notify_cb_t *);
    void processprepareSnapshotEvent(cam_ctrl_status_t *);
    void roiEvent(fd_roi_t roi, app_notify_cb_t *);
    void zoomEvent(cam_ctrl_status_t *status, app_notify_cb_t *);
    void autofocusevent(cam_ctrl_status_t *status, app_notify_cb_t *);
    void handleZoomEventForPreview(app_notify_cb_t *);
    void handleZoomEventForSnapshot(void);
    status_t autoFocusEvent(cam_ctrl_status_t *, app_notify_cb_t *);
    status_t autoFocusMoveEvent(cam_ctrl_status_t *, app_notify_cb_t *);

    void filterPictureSizes();
    bool supportsSceneDetection();
    bool supportsSelectableZoneAf();
    bool supportsFaceDetection();
    bool supportsRedEyeReduction();
    bool preview_parm_config (cam_ctrl_dimension_t* dim,QCameraParameters& parm);

    void stopPreviewInternal();
    void stopRecordingInternal();
    //void stopPreviewZSL();
    status_t cancelPictureInternal();
    //status_t startPreviewZSL();
    void pausePreviewForSnapshot();
    void pausePreviewForZSL();
    void pausePreviewForVideo();
    void prepareVideoPicture(bool disable);
    status_t resumePreviewAfterSnapshot();

    status_t runFaceDetection();

    status_t           setParameters(const QCameraParameters& params);
    QCameraParameters&  getParameters() ;

    bool getFlashCondition(void);

    status_t setCameraMode(const QCameraParameters& params);
    status_t setPictureSizeTable(void);
    status_t setPreviewSizeTable(void);
    status_t setVideoSizeTable(void);
    status_t setPreviewSize(const QCameraParameters& params);
    status_t setJpegThumbnailSize(const QCameraParameters& params);
    status_t setPreviewFpsRange(const QCameraParameters& params);
    status_t setPreviewFrameRate(const QCameraParameters& params);
    status_t setPreviewFrameRateMode(const QCameraParameters& params);
    status_t setVideoSize(const QCameraParameters& params);
    status_t setPictureSize(const QCameraParameters& params);
    status_t setJpegQuality(const QCameraParameters& params);
    status_t setNumOfSnapshot();
    status_t setJpegRotation(int isZSL);
    int getJpegRotation(void);
    int getISOSpeedValue();
    status_t setAntibanding(const QCameraParameters& params);
    status_t setEffect(const QCameraParameters& params);
    status_t setExposureCompensation(const QCameraParameters &params);
    status_t setAutoExposure(const QCameraParameters& params);
    status_t setWhiteBalance(const QCameraParameters& params);
    status_t setFlash(const QCameraParameters& params);
    status_t setGpsLocation(const QCameraParameters& params);
    status_t setRotation(const QCameraParameters& params);
    status_t setZoom(const QCameraParameters& params);
    status_t setFocusMode(const QCameraParameters& params);
    status_t setBrightness(const QCameraParameters& params);
    status_t setSkinToneEnhancement(const QCameraParameters& params);
    status_t setOrientation(const QCameraParameters& params);
    status_t setLensshadeValue(const QCameraParameters& params);
    status_t setMCEValue(const QCameraParameters& params);
    status_t setISOValue(const QCameraParameters& params);
    status_t setPictureFormat(const QCameraParameters& params);
    status_t setSharpness(const QCameraParameters& params);
    status_t setContrast(const QCameraParameters& params);
    status_t setSaturation(const QCameraParameters& params);
    status_t setWaveletDenoise(const QCameraParameters& params);
    status_t setSceneMode(const QCameraParameters& params);
    status_t setContinuousAf(const QCameraParameters& params);
    status_t setFaceDetection(const char *str);
    status_t setSceneDetect(const QCameraParameters& params);
    status_t setStrTextures(const QCameraParameters& params);
    status_t setPreviewFormat(const QCameraParameters& params);
    status_t setSelectableZoneAf(const QCameraParameters& params);
    status_t setOverlayFormats(const QCameraParameters& params);
    status_t setHighFrameRate(const QCameraParameters& params);
    status_t setRedeyeReduction(const QCameraParameters& params);
    status_t setAEBracket(const QCameraParameters& params);
    status_t setFaceDetect(const QCameraParameters& params);
    status_t setDenoise(const QCameraParameters& params);
    status_t setAecAwbLock(const QCameraParameters & params);
    status_t setHistogram(int histogram_en);
    status_t setRecordingHint(const QCameraParameters& params);
    status_t setRecordingHintValue(const int32_t value);
    status_t setFocusAreas(const QCameraParameters& params);
    status_t setMeteringAreas(const QCameraParameters& params);
    status_t setFullLiveshot(void);
    status_t setDISMode(void);
    status_t setCaptureBurstExp(void);
    status_t setPowerMode(const QCameraParameters& params);
    void takePicturePrepareHardware( );
    status_t setNoDisplayMode(const QCameraParameters& params);
    status_t setCAFLockCancel(void);

    isp3a_af_mode_t getAutoFocusMode(const QCameraParameters& params);
    bool isValidDimension(int w, int h);

    String8 create_values_str(const str_map *values, int len);

    void setMyMode(int mode);
    bool isZSLMode();
    bool isWDenoiseEnabled();
    void wdenoiseEvent(cam_ctrl_status_t status, void *cookie);
    bool isLowPowerCamcorder();
    void freePictureTable(void);
    void freeVideoSizeTable(void);

    int32_t createPreview();
    int32_t createRecord();
    int32_t createSnapshot();

    int getHDRMode();
    //EXIF
    void addExifTag(exif_tag_id_t tagid, exif_tag_type_t type,
                        uint32_t count, uint8_t copy, void *data);
    void setExifTags();
    void initExifData();
    void deinitExifData();
    void setExifTagsGPS();
    exif_tags_info_t* getExifData(){ return mExifData; }
    int getExifTableNumEntries() { return mExifTableNumEntries; }
    void parseGPSCoordinate(const char *latlonString, rat_t* coord);
    bool getHdrInfoAndSetExp( int max_num_frm, int *num_frame, int *exp);
    void hdrEvent(cam_ctrl_status_t status, void *cookie);

    int           mCameraId;
    camera_mode_t myMode;
    bool mPauseFramedispatch;

    QCameraParameters    mParameters;
    //sp<Overlay>         mOverlay;
    int32_t             mMsgEnabled;

    camera_notify_callback         mNotifyCb;
    camera_data_callback           mDataCb;
    camera_data_timestamp_callback mDataCbTimestamp;
    camera_request_memory          mGetMemory;
    void                           *mCallbackCookie;

    sp<AshmemPool>      mMetaDataHeap;

    mutable Mutex       mLock;
    //mutable Mutex       eventLock;
    Mutex         mCallbackLock;
    Mutex         mPreviewMemoryLock;
    Mutex         mRecordingMemoryLock;
    Mutex         mAutofocusLock;
    Mutex         mMetaDataWaitLock;
    Mutex         mRecordFrameLock;
    Mutex         mRecordLock;
    Condition     mRecordWait;
    pthread_mutex_t     mAsyncCmdMutex;
    pthread_cond_t      mAsyncCmdWait;

    QCameraStream       *mStreamDisplay;
    QCameraStream       *mStreamRecord;
    QCameraStream       *mStreamSnap;
    QCameraStream       *mStreamLiveSnap;

    cam_ctrl_dimension_t mDimension;
    int  mPreviewWidth, mPreviewHeight;
    int  mVideoWidth, mVideoHeight;
    int  thumbnailWidth, thumbnailHeight;
    int  maxSnapshotWidth, maxSnapshotHeight;
    int  mPreviewFormat;
    int  mFps;
    int  mDebugFps;
    int  mBrightness;
    int  mContrast;
    int  mBestShotMode;
    int  mEffects;
    int  mSkinToneEnhancement;
    int  mDenoiseValue;
    int  mHJR;
    int  mRotation;
    int  mJpegQuality;
    int  mThumbnailQuality;
    int  mTargetSmoothZoom;
    int  mSmoothZoomStep;
    int  mMaxZoom;
    int  mCurrentZoom;
    int  mSupportedPictureSizesCount;
    int  mFaceDetectOn;
    int  mDumpFrmCnt;
    int  mDumpSkipCnt;
    int  mFocusMode;

    unsigned int mPictureSizeCount;
    unsigned int mPreviewSizeCount;
    int mPowerMode;
    unsigned int mVideoSizeCount;

    bool mAutoFocusRunning;
    bool mNeedToUnlockCaf;
    bool mMultiTouch;
    bool mHasAutoFocusSupport;
    bool mInitialized;
    bool mDisEnabled;
    bool strTexturesOn;
    bool mIs3DModeOn;
    bool mSmoothZoomRunning;
    bool mPreparingSnapshot;
    bool mParamStringInitialized;
    bool mZoomSupported;
    bool mSendMetaData;
    bool mFullLiveshotEnabled;
    bool mRecordingHint;
    bool mAppRecordingHint;
    bool mStartRecording;
    bool mReleasedRecordingFrame;
    bool mStateLiveshot;
    int mHdrMode;
    int mSnapshotFormat;
    int mZslInterval;
    bool mRestartPreview;
    bool isCameraOpen;

    led_mode_t mLedStatusForZsl;
    bool mFlashCond;

/*for histogram*/
    int            mStatsOn;
    int            mCurrentHisto;
    bool           mSendData;
    sp<AshmemPool> mStatHeap;
    camera_memory_t *mStatsMapped[3];
    QCameraStatHeap_t mHistServer;
    int32_t        mStatSize;

    bool mZslLookBackMode;
    int mZslLookBackValue;
	int mHFRLevel;
    bool mZslEmptyQueueFlag;
    String8 mEffectValues;
    String8 mIsoValues;
    String8 mSceneModeValues;
    String8 mSceneDetectValues;
    String8 mFocusModeValues;
    String8 mSelectableZoneAfValues;
    String8 mAutoExposureValues;
    String8 mWhitebalanceValues;
    String8 mAntibandingValues;
    String8 mFrameRateModeValues;
    String8 mTouchAfAecValues;
    String8 mPreviewSizeValues;
    String8 mPictureSizeValues;
    String8 mVideoSizeValues;
    String8 mFlashValues;
    String8 mLensShadeValues;
    String8 mMceValues;
    String8 mHistogramValues;
    String8 mSkinToneEnhancementValues;
    String8 mPictureFormatValues;
    String8 mDenoiseValues;
    String8 mZoomRatioValues;
    String8 mPreviewFrameRateValues;
    String8 mPreviewFormatValues;
    String8 mFaceDetectionValues;
    String8 mHfrValues;
    String8 mHfrSizeValues;
    String8 mRedeyeReductionValues;
    String8 denoise_value;
    String8 mFpsRangesSupportedValues;
    String8 mZslValues;
    String8 mFocusDistance;

    friend class QCameraStream;
    friend class QCameraStream_record;
    friend class QCameraStream_preview;
    friend class QCameraStream_Snapshot;

    camera_size_type* mPictureSizes;
    camera_size_type* mPreviewSizes;
    camera_size_type* mVideoSizes;
    const camera_size_type * mPictureSizesPtr;
    HAL_camera_state_type_t mCameraState;
    void *libdnr;
    int (*LINK_morpho_DNR_ProcessFrame)(unsigned char* yuvImage, int width, int height, int y_level, int c_level);

     /* Temporary - can be removed after Honeycomb*/
#ifdef USE_ION
    sp<IonPool>  mPostPreviewHeap;
#else
    sp<PmemPool> mPostPreviewHeap;
#endif
     mm_cameara_stream_buf_t mPrevForPostviewBuf;
     int mStoreMetaDataInFrame;
     preview_stream_ops_t *mPreviewWindow;
     Mutex                mStateLock;
     int                  mPreviewState;
     /*preview memory with display case: memory is allocated and freed via
     gralloc */
     QCameraHalMemory_t   mPreviewMemory;

     /*preview memory without display case: memory is allocated
      directly by camera */
     QCameraHalHeap_t     mNoDispPreviewMemory;

     QCameraHalHeap_t     mSnapshotMemory;
     QCameraHalHeap_t     mThumbnailMemory;
     QCameraHalHeap_t     mRecordingMemory;
     QCameraHalHeap_t     mJpegMemory;
     QCameraHalHeap_t     mRawMemory;
     camera_frame_metadata_t mMetadata;
     camera_face_t           mFace[MAX_ROI];
     preview_format_info_t  mPreviewFormatInfo;
     friend void liveshot_callback(mm_camera_ch_data_buf_t *frame,void *user_data);

     //EXIF
     exif_tags_info_t       mExifData[MAX_EXIF_TABLE_ENTRIES];  //Exif tags for JPEG encoder
     exif_values_t          mExifValues;                        //Exif values in usable format
     int                    mExifTableNumEntries;            //NUmber of entries in mExifData
     int                 mNoDisplayMode;
     int                 mIsoValue;

     /* Used to show the process state of snapshot_jpeg_cb*/
     Mutex                  mSnapJpegCbLock;
     Condition              mSnapJpegCbWait;
     bool                   mSnapJpegCbRunning;
     bool                   mSnapCbDisabled;
};

}; // namespace android

#endif