QCameraHWI.h revision 3c4c5845829c7ec1e4bd29bbc140ede5de6e5a08
1/*
2** Copyright (c) 2011-2012 Code Aurora Forum. All rights reserved.
3**
4** Licensed under the Apache License, Version 2.0 (the "License");
5** you may not use this file except in compliance with the License.
6** You may obtain a copy of the License at
7**
8**     http://www.apache.org/licenses/LICENSE-2.0
9**
10** Unless required by applicable law or agreed to in writing, software
11** distributed under the License is distributed on an "AS IS" BASIS,
12** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13** See the License for the specific language governing permissions and
14** limitations under the License.
15*/
16
17#ifndef ANDROID_HARDWARE_QCAMERA_HARDWARE_INTERFACE_H
18#define ANDROID_HARDWARE_QCAMERA_HARDWARE_INTERFACE_H
19
20
21#include <utils/threads.h>
22//#include <camera/CameraHardwareInterface.h>
23#include <hardware/camera.h>
24#include <binder/MemoryBase.h>
25#include <binder/MemoryHeapBase.h>
26//#include <binder/MemoryHeapPmem.h>
27#include <utils/threads.h>
28#include <cutils/properties.h>
29#include <camera/Camera.h>
30#include "QCameraParameters.h"
31#include <system/window.h>
32#include <system/camera.h>
33#include <hardware/camera.h>
34#include <gralloc_priv.h>
35#include <QComOMXMetadata.h>
36
37extern "C" {
38#include <linux/android_pmem.h>
39#include <linux/ion.h>
40#include <mm_camera_interface2.h>
41#include "mm_omx_jpeg_encoder.h"
42} //extern C
43
44#include "QCameraHWI_Mem.h"
45#include "QCameraStream.h"
46#include "QCamera_Intf.h"
47
48//Error codes
49#define  NOT_FOUND -1
50#define MAX_ZOOM_RATIOS 62
51
52#ifdef Q12
53#undef Q12
54#endif
55
56#define Q12 4096
57#define QCAMERA_PARM_ENABLE   1
58#define QCAMERA_PARM_DISABLE  0
59#define PREVIEW_TBL_MAX_SIZE  14
60#define VIDEO_TBL_MAX_SIZE    14
61#define THUMB_TBL_MAX_SIZE    16
62#define HFR_TBL_MAX_SIZE      2
63
64struct str_map {
65    const char *const desc;
66    int val;
67};
68
69struct preview_format_info_t {
70   int Hal_format;
71   cam_format_t mm_cam_format;
72   cam_pad_format_t padding;
73   int num_planar;
74};
75
76typedef enum {
77  CAMERA_STATE_UNINITED,
78  CAMERA_STATE_READY,
79  CAMERA_STATE_PREVIEW_START_CMD_SENT,
80  CAMERA_STATE_PREVIEW_STOP_CMD_SENT,
81  CAMERA_STATE_PREVIEW,
82  CAMERA_STATE_RECORD_START_CMD_SENT,  /*5*/
83  CAMERA_STATE_RECORD_STOP_CMD_SENT,
84  CAMERA_STATE_RECORD,
85  CAMERA_STATE_SNAP_START_CMD_SENT,
86  CAMERA_STATE_SNAP_STOP_CMD_SENT,
87  CAMERA_STATE_SNAP_CMD_ACKED,  /*10 - snapshot comd acked, snapshot not done yet*/
88  CAMERA_STATE_ZSL_START_CMD_SENT,
89  CAMERA_STATE_ZSL,
90  CAMERA_STATE_AF_START_CMD_SENT,
91  CAMERA_STATE_AF_STOP_CMD_SENT,
92  CAMERA_STATE_ERROR, /*15*/
93
94  /*Add any new state above*/
95  CAMERA_STATE_MAX
96} HAL_camera_state_type_t;
97
98enum {
99  BUFFER_NOT_OWNED,
100  BUFFER_UNLOCKED,
101  BUFFER_LOCKED,
102};
103
104typedef enum {
105  HAL_DUMP_FRM_PREVIEW = 1,
106  HAL_DUMP_FRM_VIDEO = 1<<1,
107  HAL_DUMP_FRM_MAIN = 1<<2,
108  HAL_DUMP_FRM_THUMBNAIL = 1<<3,
109
110  /*8 bits mask*/
111  HAL_DUMP_FRM_MAX = 1 << 8
112} HAL_cam_dump_frm_type_t;
113
114
115typedef enum {
116  HAL_CAM_MODE_ZSL = 1,
117
118  /*add new entry before and update the max entry*/
119  HAL_CAM_MODE_MAX = HAL_CAM_MODE_ZSL << 1,
120} qQamera_mode_t;
121
122#define HAL_DUMP_FRM_MASK_ALL ( HAL_DUMP_FRM_PREVIEW + HAL_DUMP_FRM_VIDEO + \
123    HAL_DUMP_FRM_MAIN + HAL_DUMP_FRM_THUMBNAIL)
124#define QCAMERA_HAL_PREVIEW_STOPPED    0
125#define QCAMERA_HAL_PREVIEW_START      1
126#define QCAMERA_HAL_PREVIEW_STARTED    2
127#define QCAMERA_HAL_RECORDING_STARTED  3
128#define QCAMERA_HAL_TAKE_PICTURE       4
129
130
131typedef struct {
132     int                     buffer_count;
133	 buffer_handle_t        *buffer_handle[MM_CAMERA_MAX_NUM_FRAMES];
134	 struct private_handle_t *private_buffer_handle[MM_CAMERA_MAX_NUM_FRAMES];
135	 int                     stride[MM_CAMERA_MAX_NUM_FRAMES];
136	 uint32_t                addr_offset[MM_CAMERA_MAX_NUM_FRAMES];
137	 uint8_t                 local_flag[MM_CAMERA_MAX_NUM_FRAMES];
138	 camera_memory_t        *camera_memory[MM_CAMERA_MAX_NUM_FRAMES];
139     int                     main_ion_fd[MM_CAMERA_MAX_NUM_FRAMES];
140     struct ion_fd_data      ion_info_fd[MM_CAMERA_MAX_NUM_FRAMES];
141} QCameraHalMemory_t;
142
143
144typedef struct {
145     int                     buffer_count;
146     uint32_t                size;
147     uint32_t                y_offset;
148     uint32_t                cbcr_offset;
149	 int                     fd[MM_CAMERA_MAX_NUM_FRAMES];
150	 int                     local_flag[MM_CAMERA_MAX_NUM_FRAMES];
151	 camera_memory_t*        camera_memory[MM_CAMERA_MAX_NUM_FRAMES];
152     camera_memory_t*        metadata_memory[MM_CAMERA_MAX_NUM_FRAMES];
153     int main_ion_fd[MM_CAMERA_MAX_NUM_FRAMES];
154     struct ion_allocation_data alloc[MM_CAMERA_MAX_NUM_FRAMES];
155     struct ion_fd_data ion_info_fd[MM_CAMERA_MAX_NUM_FRAMES];
156} QCameraHalHeap_t;
157
158typedef struct {
159     camera_memory_t*  camera_memory[3];
160     int main_ion_fd[3];
161     struct ion_allocation_data alloc[3];
162     struct ion_fd_data ion_info_fd[3];
163     int fd[3];
164     int size;
165} QCameraStatHeap_t;
166
167typedef struct {
168  int32_t msg_type;
169  int32_t ext1;
170  int32_t ext2;
171  void    *cookie;
172} argm_notify_t;
173
174typedef struct {
175  int32_t                  msg_type;
176  camera_memory_t         *data;
177  unsigned int             index;
178  camera_frame_metadata_t *metadata;
179  void                    *cookie;
180} argm_data_cb_t;
181
182typedef struct {
183  camera_notify_callback notifyCb;
184  camera_data_callback   dataCb;
185  argm_notify_t argm_notify;
186  argm_data_cb_t        argm_data_cb;
187} app_notify_cb_t;
188
189/* camera_area_t
190 * rectangle with weight to store the focus and metering areas.
191 * x1, y1, x2, y2: from -1000 to 1000
192 * weight: 0 to 1000
193 */
194typedef struct {
195    int x1, y1, x2, y2;
196    int weight;
197} camera_area_t;
198
199//EXIF globals
200static const char ExifAsciiPrefix[] = { 0x41, 0x53, 0x43, 0x49, 0x49, 0x0, 0x0, 0x0 };          // "ASCII\0\0\0"
201static const char ExifUndefinedPrefix[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };   // "\0\0\0\0\0\0\0\0"
202
203//EXIF detfines
204#define MAX_EXIF_TABLE_ENTRIES           14
205#define GPS_PROCESSING_METHOD_SIZE       101
206#define FOCAL_LENGTH_DECIMAL_PRECISION   100
207#define EXIF_ASCII_PREFIX_SIZE           8   //(sizeof(ExifAsciiPrefix))
208
209typedef struct{
210    //GPS tags
211    rat_t       latitude[3];
212    rat_t       longitude[3];
213    char        lonRef[2];
214    char        latRef[2];
215    rat_t       altitude;
216    rat_t       gpsTimeStamp[3];
217    char        gpsDateStamp[20];
218    char        gpsProcessingMethod[EXIF_ASCII_PREFIX_SIZE+GPS_PROCESSING_METHOD_SIZE];
219    //Other tags
220    char        dateTime[20];
221    rat_t       focalLength;
222    uint16_t    flashMode;
223    uint16_t    isoSpeed;
224
225    bool        mAltitude;
226    bool        mLongitude;
227    bool        mLatitude;
228    bool        mTimeStamp;
229    bool        mGpsProcess;
230
231    int         mAltitude_ref;
232    long        mGPSTimestamp;
233
234} exif_values_t;
235
236namespace android {
237
238class QCameraStream;
239
240class QCameraHardwareInterface : public virtual RefBase {
241public:
242
243    QCameraHardwareInterface(int  cameraId, int mode);
244
245    /** Set the ANativeWindow to which preview frames are sent */
246    int setPreviewWindow(preview_stream_ops_t* window);
247
248    /** Set the notification and data callbacks */
249    void setCallbacks(camera_notify_callback notify_cb,
250            camera_data_callback data_cb,
251            camera_data_timestamp_callback data_cb_timestamp,
252            camera_request_memory get_memory,
253            void *user);
254
255    /**
256     * The following three functions all take a msg_type, which is a bitmask of
257     * the messages defined in include/ui/Camera.h
258     */
259
260    /**
261     * Enable a message, or set of messages.
262     */
263    void enableMsgType(int32_t msg_type);
264
265    /**
266     * Disable a message, or a set of messages.
267     *
268     * Once received a call to disableMsgType(CAMERA_MSG_VIDEO_FRAME), camera
269     * HAL should not rely on its client to call releaseRecordingFrame() to
270     * release video recording frames sent out by the cameral HAL before and
271     * after the disableMsgType(CAMERA_MSG_VIDEO_FRAME) call. Camera HAL
272     * clients must not modify/access any video recording frame after calling
273     * disableMsgType(CAMERA_MSG_VIDEO_FRAME).
274     */
275    void disableMsgType(int32_t msg_type);
276
277    /**
278     * Query whether a message, or a set of messages, is enabled.  Note that
279     * this is operates as an AND, if any of the messages queried are off, this
280     * will return false.
281     */
282    int msgTypeEnabled(int32_t msg_type);
283
284    /**
285     * Start preview mode.
286     */
287    int startPreview();
288    int startPreview2();
289
290    /**
291     * Stop a previously started preview.
292     */
293    void stopPreview();
294
295    /**
296     * Returns true if preview is enabled.
297     */
298    int previewEnabled();
299
300
301    /**
302     * Request the camera HAL to store meta data or real YUV data in the video
303     * buffers sent out via CAMERA_MSG_VIDEO_FRAME for a recording session. If
304     * it is not called, the default camera HAL behavior is to store real YUV
305     * data in the video buffers.
306     *
307     * This method should be called before startRecording() in order to be
308     * effective.
309     *
310     * If meta data is stored in the video buffers, it is up to the receiver of
311     * the video buffers to interpret the contents and to find the actual frame
312     * data with the help of the meta data in the buffer. How this is done is
313     * outside of the scope of this method.
314     *
315     * Some camera HALs may not support storing meta data in the video buffers,
316     * but all camera HALs should support storing real YUV data in the video
317     * buffers. If the camera HAL does not support storing the meta data in the
318     * video buffers when it is requested to do do, INVALID_OPERATION must be
319     * returned. It is very useful for the camera HAL to pass meta data rather
320     * than the actual frame data directly to the video encoder, since the
321     * amount of the uncompressed frame data can be very large if video size is
322     * large.
323     *
324     * @param enable if true to instruct the camera HAL to store
325     *        meta data in the video buffers; false to instruct
326     *        the camera HAL to store real YUV data in the video
327     *        buffers.
328     *
329     * @return OK on success.
330     */
331    int storeMetaDataInBuffers(int enable);
332
333    /**
334     * Start record mode. When a record image is available, a
335     * CAMERA_MSG_VIDEO_FRAME message is sent with the corresponding
336     * frame. Every record frame must be released by a camera HAL client via
337     * releaseRecordingFrame() before the client calls
338     * disableMsgType(CAMERA_MSG_VIDEO_FRAME). After the client calls
339     * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's
340     * responsibility to manage the life-cycle of the video recording frames,
341     * and the client must not modify/access any video recording frames.
342     */
343    int startRecording();
344
345    /**
346     * Stop a previously started recording.
347     */
348    void stopRecording();
349
350    /**
351     * Returns true if recording is enabled.
352     */
353    int recordingEnabled();
354
355    /**
356     * Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME.
357     *
358     * It is camera HAL client's responsibility to release video recording
359     * frames sent out by the camera HAL before the camera HAL receives a call
360     * to disableMsgType(CAMERA_MSG_VIDEO_FRAME). After it receives the call to
361     * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's
362     * responsibility to manage the life-cycle of the video recording frames.
363     */
364    void releaseRecordingFrame(const void *opaque);
365
366    /**
367     * Start auto focus, the notification callback routine is called with
368     * CAMERA_MSG_FOCUS once when focusing is complete. autoFocus() will be
369     * called again if another auto focus is needed.
370     */
371    int autoFocus();
372
373    /**
374     * Cancels auto-focus function. If the auto-focus is still in progress,
375     * this function will cancel it. Whether the auto-focus is in progress or
376     * not, this function will return the focus position to the default.  If
377     * the camera does not support auto-focus, this is a no-op.
378     */
379    int cancelAutoFocus();
380
381    /**
382     * Take a picture.
383     */
384    int takePicture();
385
386    /**
387     * Cancel a picture that was started with takePicture. Calling this method
388     * when no picture is being taken is a no-op.
389     */
390    int cancelPicture();
391
392    /**
393     * Set the camera parameters. This returns BAD_VALUE if any parameter is
394     * invalid or not supported.
395     */
396    int setParameters(const char *parms);
397
398    //status_t setParameters(const QCameraParameters& params);
399    /** Retrieve the camera parameters.  The buffer returned by the camera HAL
400        must be returned back to it with put_parameters, if put_parameters
401        is not NULL.
402     */
403    int getParameters(char **parms);
404
405    /** The camera HAL uses its own memory to pass us the parameters when we
406        call get_parameters.  Use this function to return the memory back to
407        the camera HAL, if put_parameters is not NULL.  If put_parameters
408        is NULL, then you have to use free() to release the memory.
409    */
410    void putParameters(char *);
411
412    /**
413     * Send command to camera driver.
414     */
415    int sendCommand(int32_t cmd, int32_t arg1, int32_t arg2);
416
417    /**
418     * Release the hardware resources owned by this object.  Note that this is
419     * *not* done in the destructor.
420     */
421    void release();
422
423    /**
424     * Dump state of the camera hardware
425     */
426    int dump(int fd);
427
428    //virtual sp<IMemoryHeap> getPreviewHeap() const;
429    //virtual sp<IMemoryHeap> getRawHeap() const;
430
431
432    status_t    takeLiveSnapshot();
433    status_t    takeFullSizeLiveshot();
434    bool        canTakeFullSizeLiveshot();
435
436    //virtual status_t          getBufferInfo( sp<IMemory>& Frame,
437    //size_t *alignedSize);
438    void         getPictureSize(int *picture_width, int *picture_height) const;
439    void         getPreviewSize(int *preview_width, int *preview_height) const;
440    cam_format_t getPreviewFormat() const;
441
442    cam_pad_format_t getPreviewPadding() const;
443
444    //bool     useOverlay(void);
445    //virtual status_t setOverlay(const sp<Overlay> &overlay);
446    void processEvent(mm_camera_event_t *);
447    int  getJpegQuality() const;
448    int  getNumOfSnapshots(void) const;
449    int  getNumOfSnapshots(const QCameraParameters& params);
450    int  getThumbSizesFromAspectRatio(uint32_t aspect_ratio,
451                                     int *picture_width,
452                                     int *picture_height);
453    bool isRawSnapshot();
454    bool mShutterSoundPlayed;
455    void dumpFrameToFile(struct msm_frame*, HAL_cam_dump_frm_type_t);
456
457    static QCameraHardwareInterface *createInstance(int, int);
458    status_t setZSLBurstLookBack(const QCameraParameters& params);
459    status_t setZSLBurstInterval(const QCameraParameters& params);
460    int getZSLBurstInterval(void);
461    int getZSLQueueDepth(void) const;
462    int getZSLBackLookCount(void) const;
463
464    ~QCameraHardwareInterface();
465    int initHeapMem(QCameraHalHeap_t *heap, int num_of_buf, int pmem_type,
466      int frame_len, int cbcr_off, int y_off, mm_cameara_stream_buf_t *StreamBuf,
467      mm_camera_buf_def_t *buf_def, uint8_t num_planes, uint32_t *planes);
468
469    int releaseHeapMem( QCameraHalHeap_t *heap);
470    status_t sendMappingBuf(int ext_mode, int idx, int fd, uint32_t size,
471      int cameraid, mm_camera_socket_msg_type msg_type);
472    status_t sendUnMappingBuf(int ext_mode, int idx, int cameraid,
473      mm_camera_socket_msg_type msg_type);
474
475    int allocate_ion_memory(QCameraHalHeap_t *p_camera_memory, int cnt,
476      int ion_type);
477    int deallocate_ion_memory(QCameraHalHeap_t *p_camera_memory, int cnt);
478
479    int allocate_ion_memory(QCameraStatHeap_t *p_camera_memory, int cnt,
480      int ion_type);
481    int deallocate_ion_memory(QCameraStatHeap_t *p_camera_memory, int cnt);
482
483    int cache_ops(int ion_fd, struct ion_flush_data *cache_inv_data, int type);
484
485    void dumpFrameToFile(const void * data, uint32_t size, char* name,
486      char* ext, int index);
487    preview_format_info_t getPreviewFormatInfo( );
488    bool isCameraReady();
489    bool isNoDisplayMode();
490
491private:
492    int16_t  zoomRatios[MAX_ZOOM_RATIOS];
493    struct camera_size_type default_preview_sizes[PREVIEW_TBL_MAX_SIZE];
494    struct camera_size_type default_video_sizes[VIDEO_TBL_MAX_SIZE];
495    struct camera_size_type default_hfr_sizes[HFR_TBL_MAX_SIZE];
496    struct camera_size_type default_thumbnail_sizes[THUMB_TBL_MAX_SIZE];
497    unsigned int preview_sizes_count;
498    unsigned int video_sizes_count;
499    unsigned int thumbnail_sizes_count;
500    unsigned int hfr_sizes_count;
501
502
503    bool mUseOverlay;
504
505    void loadTables();
506    void initDefaultParameters();
507    bool getMaxPictureDimension(mm_camera_dimension_t *dim);
508
509    status_t updateFocusDistances();
510
511    bool native_set_parms(mm_camera_parm_type_t type, uint16_t length, void *value);
512    bool native_set_parms( mm_camera_parm_type_t type, uint16_t length, void *value, int *result);
513
514    void hasAutoFocusSupport();
515    void debugShowPreviewFPS() const;
516    //void prepareSnapshotAndWait();
517
518    bool isPreviewRunning();
519    bool isRecordingRunning();
520    bool isSnapshotRunning();
521
522    void processChannelEvent(mm_camera_ch_event_t *, app_notify_cb_t *);
523    void processPreviewChannelEvent(mm_camera_ch_event_type_t channelEvent, app_notify_cb_t *);
524    void processRecordChannelEvent(mm_camera_ch_event_type_t channelEvent, app_notify_cb_t *);
525    void processSnapshotChannelEvent(mm_camera_ch_event_type_t channelEvent, app_notify_cb_t *);
526    void processCtrlEvent(mm_camera_ctrl_event_t *, app_notify_cb_t *);
527    void processStatsEvent(mm_camera_stats_event_t *, app_notify_cb_t *);
528    void processInfoEvent(mm_camera_info_event_t *event, app_notify_cb_t *);
529    void processprepareSnapshotEvent(cam_ctrl_status_t *);
530    void roiEvent(fd_roi_t roi, app_notify_cb_t *);
531    void zslFlashEvent(struct zsl_flash_t evt, app_notify_cb_t *);
532    void zoomEvent(cam_ctrl_status_t *status, app_notify_cb_t *);
533    void autofocusevent(cam_ctrl_status_t *status, app_notify_cb_t *);
534    void handleZoomEventForPreview(app_notify_cb_t *);
535    void handleZoomEventForSnapshot(void);
536    status_t autoFocusEvent(cam_ctrl_status_t *, app_notify_cb_t *);
537    status_t autoFocusMoveEvent(cam_ctrl_status_t *, app_notify_cb_t *);
538
539    void filterPictureSizes();
540    bool supportsSceneDetection();
541    bool supportsSelectableZoneAf();
542    bool supportsFaceDetection();
543    bool supportsRedEyeReduction();
544    bool preview_parm_config (cam_ctrl_dimension_t* dim,QCameraParameters& parm);
545
546    void stopPreviewInternal();
547    void stopRecordingInternal();
548    //void stopPreviewZSL();
549    status_t cancelPictureInternal();
550    //status_t startPreviewZSL();
551    void pausePreviewForSnapshot();
552    void pausePreviewForZSL();
553    void pausePreviewForVideo();
554    status_t resumePreviewAfterSnapshot();
555
556    status_t runFaceDetection();
557
558    status_t           setParameters(const QCameraParameters& params);
559    QCameraParameters&  getParameters() ;
560
561    status_t setCameraMode(const QCameraParameters& params);
562    status_t setPictureSizeTable(void);
563    status_t setPreviewSizeTable(void);
564    status_t setVideoSizeTable(void);
565    status_t setPreviewSize(const QCameraParameters& params);
566    status_t setJpegThumbnailSize(const QCameraParameters& params);
567    status_t setPreviewFpsRange(const QCameraParameters& params);
568    status_t setPreviewFrameRate(const QCameraParameters& params);
569    status_t setPreviewFrameRateMode(const QCameraParameters& params);
570    status_t setVideoSize(const QCameraParameters& params);
571    status_t setPictureSize(const QCameraParameters& params);
572    status_t setJpegQuality(const QCameraParameters& params);
573    status_t setNumOfSnapshot(const QCameraParameters& params);
574    status_t setJpegRotation(int isZSL);
575    int getJpegRotation(void);
576    int getISOSpeedValue();
577    int getFlashMode();
578    status_t setAntibanding(const QCameraParameters& params);
579    status_t setEffect(const QCameraParameters& params);
580    status_t setExposureCompensation(const QCameraParameters &params);
581    status_t setAutoExposure(const QCameraParameters& params);
582    status_t setWhiteBalance(const QCameraParameters& params);
583    status_t setFlash(const QCameraParameters& params);
584    status_t setGpsLocation(const QCameraParameters& params);
585    status_t setRotation(const QCameraParameters& params);
586    status_t setZoom(const QCameraParameters& params);
587    status_t setFocusMode(const QCameraParameters& params);
588    status_t setBrightness(const QCameraParameters& params);
589    status_t setSkinToneEnhancement(const QCameraParameters& params);
590    status_t setOrientation(const QCameraParameters& params);
591    status_t setLensshadeValue(const QCameraParameters& params);
592    status_t setMCEValue(const QCameraParameters& params);
593    status_t setISOValue(const QCameraParameters& params);
594    status_t setPictureFormat(const QCameraParameters& params);
595    status_t setSharpness(const QCameraParameters& params);
596    status_t setContrast(const QCameraParameters& params);
597    status_t setSaturation(const QCameraParameters& params);
598    status_t setWaveletDenoise(const QCameraParameters& params);
599    status_t setSceneMode(const QCameraParameters& params);
600    status_t setContinuousAf(const QCameraParameters& params);
601    status_t setFaceDetection(const char *str);
602    status_t setSceneDetect(const QCameraParameters& params);
603    status_t setStrTextures(const QCameraParameters& params);
604    status_t setPreviewFormat(const QCameraParameters& params);
605    status_t setSelectableZoneAf(const QCameraParameters& params);
606    status_t setOverlayFormats(const QCameraParameters& params);
607    status_t setHighFrameRate(const QCameraParameters& params);
608    status_t setRedeyeReduction(const QCameraParameters& params);
609    status_t setAEBracket(const QCameraParameters& params);
610    status_t setFaceDetect(const QCameraParameters& params);
611    status_t setDenoise(const QCameraParameters& params);
612    status_t setAecAwbLock(const QCameraParameters & params);
613    status_t setHistogram(int histogram_en);
614    status_t setRecordingHint(const QCameraParameters& params);
615    status_t setRecordingHintValue(const int32_t value);
616    status_t setFocusAreas(const QCameraParameters& params);
617    status_t setMeteringAreas(const QCameraParameters& params);
618    status_t setFullLiveshot(void);
619    status_t setDISMode(void);
620    status_t setCaptureBurstExp(void);
621    status_t setPowerMode(const QCameraParameters& params);
622    void takePicturePrepareHardware( );
623    status_t setNoDisplayMode(const QCameraParameters& params);
624    status_t setCAFLockCancel(void);
625
626    isp3a_af_mode_t getAutoFocusMode(const QCameraParameters& params);
627    bool isValidDimension(int w, int h);
628
629    String8 create_values_str(const str_map *values, int len);
630
631    void setMyMode(int mode);
632    bool isZSLMode();
633    bool isWDenoiseEnabled();
634    void wdenoiseEvent(cam_ctrl_status_t status, void *cookie);
635    bool isLowPowerCamcorder();
636    void freePictureTable(void);
637    void freeVideoSizeTable(void);
638
639    int32_t createPreview();
640    int32_t createRecord();
641    int32_t createSnapshot();
642
643    int getHDRMode();
644    //EXIF
645    void addExifTag(exif_tag_id_t tagid, exif_tag_type_t type,
646                        uint32_t count, uint8_t copy, void *data);
647    void setExifTags();
648    void initExifData();
649    void deinitExifData();
650    void setExifTagsGPS();
651    exif_tags_info_t* getExifData(){ return mExifData; }
652    int getExifTableNumEntries() { return mExifTableNumEntries; }
653    void parseGPSCoordinate(const char *latlonString, rat_t* coord);
654    bool getHdrInfoAndSetExp( int max_num_frm, int *num_frame, int *exp);
655    void hdrEvent(cam_ctrl_status_t status, void *cookie);
656
657    int           mCameraId;
658    camera_mode_t myMode;
659
660    QCameraParameters    mParameters;
661    //sp<Overlay>         mOverlay;
662    int32_t             mMsgEnabled;
663
664    camera_notify_callback         mNotifyCb;
665    camera_data_callback           mDataCb;
666    camera_data_timestamp_callback mDataCbTimestamp;
667    camera_request_memory          mGetMemory;
668    void                           *mCallbackCookie;
669
670    sp<AshmemPool>      mMetaDataHeap;
671
672    mutable Mutex       mLock;
673    //mutable Mutex       eventLock;
674    Mutex         mCallbackLock;
675    Mutex         mPreviewMemoryLock;
676    Mutex         mRecordingMemoryLock;
677    Mutex         mAutofocusLock;
678    Mutex         mMetaDataWaitLock;
679    Mutex         mRecordFrameLock;
680    Mutex         mRecordLock;
681    Condition     mRecordWait;
682    pthread_mutex_t     mAsyncCmdMutex;
683    pthread_cond_t      mAsyncCmdWait;
684
685    QCameraStream       *mStreamDisplay;
686    QCameraStream       *mStreamRecord;
687    QCameraStream       *mStreamSnap;
688    QCameraStream       *mStreamLiveSnap;
689
690    cam_ctrl_dimension_t mDimension;
691    int  mPreviewWidth, mPreviewHeight;
692    int  mVideoWidth, mVideoHeight;
693    int  thumbnailWidth, thumbnailHeight;
694    int  maxSnapshotWidth, maxSnapshotHeight;
695    int  mPreviewFormat;
696    int  mFps;
697    int  mDebugFps;
698    int  mBrightness;
699    int  mContrast;
700    int  mBestShotMode;
701    int  mEffects;
702    int  mSkinToneEnhancement;
703    int  mDenoiseValue;
704    int  mHJR;
705    int  mRotation;
706    int  mJpegQuality;
707    int  mThumbnailQuality;
708    int  mTargetSmoothZoom;
709    int  mSmoothZoomStep;
710    int  mMaxZoom;
711    int  mCurrentZoom;
712    int  mSupportedPictureSizesCount;
713    int  mFaceDetectOn;
714    int  mDumpFrmCnt;
715    int  mDumpSkipCnt;
716    int  mFocusMode;
717
718    unsigned int mPictureSizeCount;
719    unsigned int mPreviewSizeCount;
720    int mPowerMode;
721    unsigned int mVideoSizeCount;
722
723    bool mAutoFocusRunning;
724    bool mMultiTouch;
725    bool mHasAutoFocusSupport;
726    bool mInitialized;
727    bool mDisEnabled;
728    bool strTexturesOn;
729    bool mIs3DModeOn;
730    bool mSmoothZoomRunning;
731    bool mPreparingSnapshot;
732    bool mParamStringInitialized;
733    bool mZoomSupported;
734    bool mSendMetaData;
735    bool mFullLiveshotEnabled;
736    bool mRecordingHint;
737    bool mAppRecordingHint;
738    bool mStartRecording;
739    bool mReleasedRecordingFrame;
740    int mHdrMode;
741    int mSnapshotFormat;
742    int mZslInterval;
743    bool mRestartPreview;
744
745/*for histogram*/
746    int            mStatsOn;
747    int            mCurrentHisto;
748    bool           mSendData;
749    sp<AshmemPool> mStatHeap;
750    camera_memory_t *mStatsMapped[3];
751    QCameraStatHeap_t mHistServer;
752    int32_t        mStatSize;
753
754    bool mZslLookBackMode;
755    int mZslLookBackValue;
756	int mHFRLevel;
757    bool mZslEmptyQueueFlag;
758    String8 mEffectValues;
759    String8 mIsoValues;
760    String8 mSceneModeValues;
761    String8 mSceneDetectValues;
762    String8 mFocusModeValues;
763    String8 mSelectableZoneAfValues;
764    String8 mAutoExposureValues;
765    String8 mWhitebalanceValues;
766    String8 mAntibandingValues;
767    String8 mFrameRateModeValues;
768    String8 mTouchAfAecValues;
769    String8 mPreviewSizeValues;
770    String8 mPictureSizeValues;
771    String8 mVideoSizeValues;
772    String8 mFlashValues;
773    String8 mLensShadeValues;
774    String8 mMceValues;
775    String8 mHistogramValues;
776    String8 mSkinToneEnhancementValues;
777    String8 mPictureFormatValues;
778    String8 mDenoiseValues;
779    String8 mZoomRatioValues;
780    String8 mPreviewFrameRateValues;
781    String8 mPreviewFormatValues;
782    String8 mFaceDetectionValues;
783    String8 mHfrValues;
784    String8 mHfrSizeValues;
785    String8 mRedeyeReductionValues;
786    String8 denoise_value;
787    String8 mFpsRangesSupportedValues;
788    String8 mZslValues;
789    String8 mFocusDistance;
790
791    friend class QCameraStream;
792    friend class QCameraStream_record;
793    friend class QCameraStream_preview;
794    friend class QCameraStream_Snapshot;
795
796    camera_size_type* mPictureSizes;
797    camera_size_type* mPreviewSizes;
798    camera_size_type* mVideoSizes;
799    const camera_size_type * mPictureSizesPtr;
800    HAL_camera_state_type_t mCameraState;
801
802     /* Temporary - can be removed after Honeycomb*/
803#ifdef USE_ION
804    sp<IonPool>  mPostPreviewHeap;
805#else
806    sp<PmemPool> mPostPreviewHeap;
807#endif
808     mm_cameara_stream_buf_t mPrevForPostviewBuf;
809     int mStoreMetaDataInFrame;
810     preview_stream_ops_t *mPreviewWindow;
811     Mutex                mStateLock;
812     int                  mPreviewState;
813     /*preview memory with display case: memory is allocated and freed via
814     gralloc */
815     QCameraHalMemory_t   mPreviewMemory;
816
817     /*preview memory without display case: memory is allocated
818      directly by camera */
819     QCameraHalHeap_t     mNoDispPreviewMemory;
820
821     QCameraHalHeap_t     mSnapshotMemory;
822     QCameraHalHeap_t     mThumbnailMemory;
823     QCameraHalHeap_t     mRecordingMemory;
824     QCameraHalHeap_t     mJpegMemory;
825     QCameraHalHeap_t     mRawMemory;
826     camera_frame_metadata_t mMetadata;
827     camera_face_t           mFace[MAX_ROI];
828     preview_format_info_t  mPreviewFormatInfo;
829     friend void liveshot_callback(mm_camera_ch_data_buf_t *frame,void *user_data);
830
831     //EXIF
832     exif_tags_info_t       mExifData[MAX_EXIF_TABLE_ENTRIES];  //Exif tags for JPEG encoder
833     exif_values_t          mExifValues;                        //Exif values in usable format
834     int                    mExifTableNumEntries;            //NUmber of entries in mExifData
835     int                 mNoDisplayMode;
836     int                 mIsoValue;
837};
838
839}; // namespace android
840
841#endif
842