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