16f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev/* Copyright (c) 2012-2013, The Linux Foundataion. All rights reserved.
26f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev *
36f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev * Redistribution and use in source and binary forms, with or without
46f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev * modification, are permitted provided that the following conditions are
56f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev * met:
66f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev *     * Redistributions of source code must retain the above copyright
76f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev *       notice, this list of conditions and the following disclaimer.
86f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev *     * Redistributions in binary form must reproduce the above
96f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev *       copyright notice, this list of conditions and the following
106f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev *       disclaimer in the documentation and/or other materials provided
116f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev *       with the distribution.
126f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev *     * Neither the name of The Linux Foundation nor the names of its
136f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev *       contributors may be used to endorse or promote products derived
146f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev *       from this software without specific prior written permission.
156f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev *
166f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
176f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
186f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
196f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
206f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
216f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
226f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
236f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
246f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
256f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
266f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev *
286f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev */
296f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
306f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#ifndef __QCAMERA2HARDWAREINTERFACE_H__
316f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#define __QCAMERA2HARDWAREINTERFACE_H__
326f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
336f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#include <hardware/camera.h>
346f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#include <hardware/power.h>
356f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#include <utils/Log.h>
366f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#include <QCameraParameters.h>
376f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
386f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#include "QCameraQueue.h"
396f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#include "QCameraCmdThread.h"
406f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#include "QCameraChannel.h"
416f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#include "QCameraStream.h"
426f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#include "QCameraStateMachine.h"
436f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#include "QCameraAllocator.h"
446f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#include "QCameraPostProc.h"
456f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#include "QCameraThermalAdapter.h"
466f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
476f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchevextern "C" {
486f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#include <mm_camera_interface.h>
496f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#include <mm_jpeg_interface.h>
506f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev}
516f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
526f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#if DISABLE_DEBUG_LOG
536f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
546f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchevinline void __null_log(int, const char *, const char *, ...) {}
556f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
566f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#ifdef ALOGD
576f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#undef ALOGD
586f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#define ALOGD(...) do { __null_log(0, LOG_TAG,__VA_ARGS__); } while (0)
596f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#endif
606f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
616f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#ifdef ALOGI
626f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#undef ALOGI
636f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#define ALOGI(...) do { __null_log(0, LOG_TAG,__VA_ARGS__); } while (0)
646f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#endif
656f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
666f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#endif
676f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
686f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchevnamespace qcamera {
696f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
706f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#ifndef TRUE
716f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#define TRUE 1
726f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#endif
736f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
746f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#ifndef FALSE
756f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#define FALSE 0
766f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#endif
776f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
786f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchevtypedef enum {
796f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCAMERA_CH_TYPE_ZSL,
806f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCAMERA_CH_TYPE_CAPTURE,
816f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCAMERA_CH_TYPE_PREVIEW,
826f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCAMERA_CH_TYPE_VIDEO,
836f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCAMERA_CH_TYPE_SNAPSHOT,
846f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCAMERA_CH_TYPE_RAW,
856f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCAMERA_CH_TYPE_METADATA,
866f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCAMERA_CH_TYPE_MAX
876f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev} qcamera_ch_type_enum_t;
886f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
896f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchevtypedef struct {
906f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t msg_type;
916f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t ext1;
926f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t ext2;
936f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev} qcamera_evt_argm_t;
946f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
956f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#define QCAMERA_DUMP_FRM_PREVIEW    1
966f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#define QCAMERA_DUMP_FRM_VIDEO      (1<<1)
976f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#define QCAMERA_DUMP_FRM_SNAPSHOT   (1<<2)
986f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#define QCAMERA_DUMP_FRM_THUMBNAIL  (1<<3)
996f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#define QCAMERA_DUMP_FRM_RAW        (1<<4)
1006f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#define QCAMERA_DUMP_FRM_JPEG       (1<<5)
1016f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
1026f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#define QCAMERA_DUMP_FRM_MASK_ALL    0x000000ff
1036f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
104744f5403bebb0e27140d16a5df7a341713c24a13Nagesh Subba Reddy#define QCAMERA_ION_USE_CACHE   true
105744f5403bebb0e27140d16a5df7a341713c24a13Nagesh Subba Reddy#define QCAMERA_ION_USE_NOCACHE false
106744f5403bebb0e27140d16a5df7a341713c24a13Nagesh Subba Reddy
1076f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchevtypedef enum {
1086f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCAMERA_NOTIFY_CALLBACK,
1096f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCAMERA_DATA_CALLBACK,
1106f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCAMERA_DATA_TIMESTAMP_CALLBACK,
1116f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCAMERA_DATA_SNAPSHOT_CALLBACK
1126f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev} qcamera_callback_type_m;
1136f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
1146f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchevtypedef void (*camera_release_callback)(void *user_data, void *cookie);
1156f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
1166f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchevtypedef struct {
1176f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    qcamera_callback_type_m  cb_type;    // event type
1186f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t                  msg_type;   // msg type
1196f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t                  ext1;       // extended parameter
1206f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t                  ext2;       // extended parameter
1216f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    camera_memory_t *        data;       // ptr to data memory struct
1226f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    unsigned int             index;      // index of the buf in the whole buffer
1236f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int64_t                  timestamp;  // buffer timestamp
1246f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    camera_frame_metadata_t *metadata;   // meta data
1256f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    void                    *user_data;  // any data needs to be released after callback
1266f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    void                    *cookie;     // release callback cookie
1276f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    camera_release_callback  release_cb; // release callback
1286f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev} qcamera_callback_argm_t;
1296f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
1306f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchevclass QCameraCbNotifier {
1316f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchevpublic:
1326f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCameraCbNotifier(QCamera2HardwareInterface *parent) :
1336f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                          mNotifyCb (NULL),
1346f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                          mDataCb (NULL),
1356f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                          mDataCbTimestamp (NULL),
1366f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                          mCallbackCookie (NULL),
1376f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                          mParent (parent),
1386f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                          mDataQ(releaseNotifications, this) {}
1396f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
1406f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    virtual ~QCameraCbNotifier();
1416f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
1426f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    virtual int32_t notifyCallback(qcamera_callback_argm_t &cbArgs);
1436f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    virtual void setCallbacks(camera_notify_callback notifyCb,
1446f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                              camera_data_callback dataCb,
1456f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                              camera_data_timestamp_callback dataCbTimestamp,
1466f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                              void *callbackCookie);
1476f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    virtual int32_t startSnapshots();
1486f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    virtual void stopSnapshots();
1496f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void * cbNotifyRoutine(void * data);
1506f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void releaseNotifications(void *data, void *user_data);
1516f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static bool matchSnapshotNotifications(void *data, void *user_data);
1526f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchevprivate:
1536f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
1546f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    camera_notify_callback         mNotifyCb;
1556f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    camera_data_callback           mDataCb;
1566f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    camera_data_timestamp_callback mDataCbTimestamp;
1576f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    void                          *mCallbackCookie;
1586f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCamera2HardwareInterface     *mParent;
1596f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
1606f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCameraQueue     mDataQ;
1616f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCameraCmdThread mProcTh;
1626f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev};
1636f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchevclass QCamera2HardwareInterface : public QCameraAllocator,
1646f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                    public QCameraThermalCallback
1656f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev{
1666f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchevpublic:
1676f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    /* static variable and functions accessed by camera service */
1686f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static camera_device_ops_t mCameraOps;
1696f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
1706f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static int set_preview_window(struct camera_device *,
1716f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev        struct preview_stream_ops *window);
1726f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void set_CallBacks(struct camera_device *,
1736f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev        camera_notify_callback notify_cb,
1746f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev        camera_data_callback data_cb,
1756f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev        camera_data_timestamp_callback data_cb_timestamp,
1766f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev        camera_request_memory get_memory,
1776f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev        void *user);
1786f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void enable_msg_type(struct camera_device *, int32_t msg_type);
1796f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void disable_msg_type(struct camera_device *, int32_t msg_type);
1806f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static int msg_type_enabled(struct camera_device *, int32_t msg_type);
1816f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static int start_preview(struct camera_device *);
1826f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void stop_preview(struct camera_device *);
1836f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static int preview_enabled(struct camera_device *);
1846f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static int store_meta_data_in_buffers(struct camera_device *, int enable);
1856f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static int start_recording(struct camera_device *);
1866f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void stop_recording(struct camera_device *);
1876f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static int recording_enabled(struct camera_device *);
1886f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void release_recording_frame(struct camera_device *, const void *opaque);
1896f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static int auto_focus(struct camera_device *);
1906f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static int cancel_auto_focus(struct camera_device *);
1916f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static int take_picture(struct camera_device *);
1926f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static int cancel_picture(struct camera_device *);
1936f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static int set_parameters(struct camera_device *, const char *parms);
1946f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static char* get_parameters(struct camera_device *);
1956f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void put_parameters(struct camera_device *, char *);
1966f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static int send_command(struct camera_device *,
1976f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev              int32_t cmd, int32_t arg1, int32_t arg2);
1986f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void release(struct camera_device *);
1996f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static int dump(struct camera_device *, int fd);
2006f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static int close_camera_device(hw_device_t *);
2016f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
2026f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static int register_face_image(struct camera_device *,
2036f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                   void *img_ptr,
2046f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                   cam_pp_offline_src_config_t *config);
2056f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchevpublic:
2066f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCamera2HardwareInterface(int cameraId);
2076f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    virtual ~QCamera2HardwareInterface();
2086f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int openCamera(struct hw_device_t **hw_device);
2096f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
2106f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static int getCapabilities(int cameraId, struct camera_info *info);
2116f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static int initCapabilities(int cameraId);
2126f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
2136f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    // Implementation of QCameraAllocator
2146f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    virtual QCameraMemory *allocateStreamBuf(cam_stream_type_t stream_type,
2156f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                             int size,
2166f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                             uint8_t &bufferCnt);
2176f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    virtual QCameraHeapMemory *allocateStreamInfoBuf(cam_stream_type_t stream_type);
2186f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
2196f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    // Implementation of QCameraThermalCallback
2206f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    virtual int thermalEvtHandle(qcamera_thermal_level_enum_t level,
2216f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev            void *userdata, void *data);
2226f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
2236f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    friend class QCameraStateMachine;
2246f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    friend class QCameraPostProcessor;
2256f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    friend class QCameraCbNotifier;
2266f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
2276f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchevprivate:
2286f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int setPreviewWindow(struct preview_stream_ops *window);
2296f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int setCallBacks(
2306f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev        camera_notify_callback notify_cb,
2316f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev        camera_data_callback data_cb,
2326f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev        camera_data_timestamp_callback data_cb_timestamp,
2336f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev        camera_request_memory get_memory,
2346f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev        void *user);
2356f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int enableMsgType(int32_t msg_type);
2366f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int disableMsgType(int32_t msg_type);
2376f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int msgTypeEnabled(int32_t msg_type);
2386f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int msgTypeEnabledWithLock(int32_t msg_type);
2396f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int startPreview();
2406f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int stopPreview();
2416f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int storeMetaDataInBuffers(int enable);
2426f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int startRecording();
2436f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int stopRecording();
2446f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int releaseRecordingFrame(const void *opaque);
2456f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int autoFocus();
2466f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int cancelAutoFocus();
2476f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int takePicture();
2486f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int cancelPicture();
2496f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int takeLiveSnapshot();
2506f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int cancelLiveSnapshot();
2516f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    char* getParameters();
2526f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int putParameters(char *);
2536f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int sendCommand(int32_t cmd, int32_t arg1, int32_t arg2);
2546f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int release();
2556f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int dump(int fd);
2566f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int registerFaceImage(void *img_ptr,
2576f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                          cam_pp_offline_src_config_t *config,
2586f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                          int32_t &faceID);
2596f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
2606f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int openCamera();
2616f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int closeCamera();
2626f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
2636f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int processAPI(qcamera_sm_evt_enum_t api, void *api_payload);
2646f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int processEvt(qcamera_sm_evt_enum_t evt, void *evt_payload);
265744f5403bebb0e27140d16a5df7a341713c24a13Nagesh Subba Reddy    int processSyncEvt(qcamera_sm_evt_enum_t evt, void *evt_payload);
2666f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    void lockAPI();
2676f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    void waitAPIResult(qcamera_sm_evt_enum_t api_evt);
2686f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    void unlockAPI();
2696f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    void signalAPIResult(qcamera_api_result_t *result);
270744f5403bebb0e27140d16a5df7a341713c24a13Nagesh Subba Reddy    void signalEvtResult(qcamera_api_result_t *result);
2716f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
2726f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int updateThermalLevel(qcamera_thermal_level_enum_t level);
2736f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
2746f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    // update entris to set parameters and check if restart is needed
2756f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int updateParameters(const char *parms, bool &needRestart);
2766f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    // send request to server to set parameters
2776f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int commitParameterChanges();
2786f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
2796f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    bool needDebugFps();
280744f5403bebb0e27140d16a5df7a341713c24a13Nagesh Subba Reddy    bool isCACEnabled();
2816f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    bool needReprocess();
2826f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    bool needRotationReprocess();
2836f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    void debugShowVideoFPS();
2846f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    void debugShowPreviewFPS();
2856f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    void dumpFrameToFile(const void *data, uint32_t size,
2866f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                         int index, int dump_type);
2876f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    void releaseSuperBuf(mm_camera_super_buf_t *super_buf);
2886f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    void playShutter();
2896f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    void getThumbnailSize(cam_dimension_t &dim);
2906f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int getJpegQuality();
2916f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int getJpegRotation();
2926f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCameraExif *getExifData();
2936f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
2946f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t processAutoFocusEvent(cam_auto_focus_data_t &focus_data);
2956f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t processZoomEvent(cam_crop_data_t &crop_info);
2966f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t processPrepSnapshotDoneEvent(cam_prep_snapshot_state_t prep_snapshot_state);
2976f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t processJpegNotify(qcamera_jpeg_evt_payload_t *jpeg_job);
2986f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
2996f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t sendEvtNotify(int32_t msg_type, int32_t ext1, int32_t ext2);
3006f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t sendDataNotify(int32_t msg_type,
3016f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                           camera_memory_t *data,
3026f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                           uint8_t index,
3036f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                           camera_frame_metadata_t *metadata);
3046f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
3056f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t addChannel(qcamera_ch_type_enum_t ch_type);
3066f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t startChannel(qcamera_ch_type_enum_t ch_type);
3076f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t stopChannel(qcamera_ch_type_enum_t ch_type);
3086f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t delChannel(qcamera_ch_type_enum_t ch_type);
3096f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t addPreviewChannel();
3106f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t addSnapshotChannel();
3116f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t addVideoChannel();
3126f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t addZSLChannel();
3136f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t addCaptureChannel();
3146f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t addRawChannel();
3156f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t addMetaDataChannel();
3166f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCameraReprocessChannel *addOnlineReprocChannel(QCameraChannel *pInputChannel);
3176f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCameraReprocessChannel *addOfflineReprocChannel(
3186f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                                cam_pp_offline_src_config_t &img_config,
3196f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                                cam_pp_feature_config_t &pp_feature,
3206f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                                stream_cb_routine stream_cb,
3216f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                                void *userdata);
3226f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t addStreamToChannel(QCameraChannel *pChannel,
3236f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                               cam_stream_type_t streamType,
3246f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                               stream_cb_routine streamCB,
3256f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                               void *userData);
3266f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t preparePreview();
3276f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    void unpreparePreview();
3286f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCameraChannel *getChannelByHandle(uint32_t channelHandle);
3296f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    mm_camera_buf_def_t *getSnapshotFrame(mm_camera_super_buf_t *recvd_frame);
3306f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t processFaceDetectionResult(cam_face_detection_data_t *fd_data);
3316f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t processHistogramStats(cam_hist_stats_t &stats_data);
3326f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t setHistogram(bool histogram_en);
3336f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t setFaceDetection(bool enabled);
3346f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t prepareHardwareForSnapshot(int32_t afNeeded);
3356f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    bool needProcessPreviewFrame() {return m_stateMachine.isPreviewRunning();};
3366f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    bool isNoDisplayMode() {return mParameters.isNoDisplayMode();};
3376f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    bool isZSLMode() {return mParameters.isZSLMode();};
3386f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    uint8_t numOfSnapshotsExpected() {return mParameters.getNumOfSnapshots();};
3396f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    uint8_t getBufNumRequired(cam_stream_type_t stream_type);
3406f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
3416f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void camEvtHandle(uint32_t camera_handle,
3426f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                          mm_camera_event_t *evt,
3436f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                          void *user_data);
3446f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void jpegEvtHandle(jpeg_job_status_t status,
3456f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                              uint32_t client_hdl,
3466f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                              uint32_t jobId,
3476f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                              mm_jpeg_output_t *p_buf,
3486f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                              void *userdata);
3496f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
3506f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void *evtNotifyRoutine(void *data);
3516f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
3526f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    // functions for different data notify cb
3536f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void zsl_channel_cb(mm_camera_super_buf_t *recvd_frame, void *userdata);
3546f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void capture_channel_cb_routine(mm_camera_super_buf_t *recvd_frame,
3556f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                           void *userdata);
3566f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void postproc_channel_cb_routine(mm_camera_super_buf_t *recvd_frame,
3576f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                            void *userdata);
3586f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void nodisplay_preview_stream_cb_routine(mm_camera_super_buf_t *frame,
3596f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                                    QCameraStream *stream,
3606f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                                    void *userdata);
3616f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void preview_stream_cb_routine(mm_camera_super_buf_t *frame,
3626f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                          QCameraStream *stream,
3636f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                          void *userdata);
3646f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void postview_stream_cb_routine(mm_camera_super_buf_t *frame,
3656f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                           QCameraStream *stream,
3666f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                           void *userdata);
3676f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void video_stream_cb_routine(mm_camera_super_buf_t *frame,
3686f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                        QCameraStream *stream,
3696f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                        void *userdata);
3706f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void snapshot_stream_cb_routine(mm_camera_super_buf_t *frame,
3716f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                           QCameraStream *stream,
3726f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                           void *userdata);
3736f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void raw_stream_cb_routine(mm_camera_super_buf_t *frame,
3746f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                      QCameraStream *stream,
3756f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                      void *userdata);
3766f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void metadata_stream_cb_routine(mm_camera_super_buf_t *frame,
3776f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                           QCameraStream *stream,
3786f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                           void *userdata);
3796f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void reprocess_stream_cb_routine(mm_camera_super_buf_t *frame,
3806f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                            QCameraStream *stream,
3816f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev                                            void *userdata);
3826f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
3836f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void releaseCameraMemory(void *data, void *cookie);
3846f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    static void returnStreamBuffer(void *data, void *cookie);
3856f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
3866f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchevprivate:
3876f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    camera_device_t   mCameraDevice;
3886f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    uint8_t           mCameraId;
3896f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    mm_camera_vtbl_t *mCameraHandle;
3906f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    bool mCameraOpened;
3916f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
3926f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    preview_stream_ops_t *mPreviewWindow;
3936f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCameraParameters mParameters;
3946f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int32_t               mMsgEnabled;
3956f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int                   mStoreMetaDataInFrame;
3966f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
3976f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    camera_notify_callback         mNotifyCb;
3986f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    camera_data_callback           mDataCb;
3996f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    camera_data_timestamp_callback mDataCbTimestamp;
4006f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    camera_request_memory          mGetMemory;
4016f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    void                          *mCallbackCookie;
4026f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
4036f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCameraStateMachine m_stateMachine;   // state machine
4046f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCameraPostProcessor m_postprocessor; // post processor
4056f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCameraThermalAdapter &m_thermalAdapter;
4066f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCameraCbNotifier m_cbNotifier;
4076f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    pthread_mutex_t m_lock;
4086f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    pthread_cond_t m_cond;
4096f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    qcamera_api_result_t m_apiResult;
4106f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
411744f5403bebb0e27140d16a5df7a341713c24a13Nagesh Subba Reddy    pthread_mutex_t m_evtLock;
412744f5403bebb0e27140d16a5df7a341713c24a13Nagesh Subba Reddy    pthread_cond_t m_evtCond;
413744f5403bebb0e27140d16a5df7a341713c24a13Nagesh Subba Reddy    qcamera_api_result_t m_evtResult;
414744f5403bebb0e27140d16a5df7a341713c24a13Nagesh Subba Reddy
4156f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    QCameraChannel *m_channels[QCAMERA_CH_TYPE_MAX]; // array holding channel ptr
4166f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
4176f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    bool m_bShutterSoundPlayed;         // if shutter sound had been played
4186f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
4196f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    // if auto focus is running, in other words, when auto_focus is called from service,
4206f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    // and beforeany focus callback/cancel_focus happens. This flag is not an indication
4216f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    // of whether lens is moving or not.
4226f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    bool m_bAutoFocusRunning;
4236f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    cam_autofocus_state_t m_currentFocusState;
4246f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
4256f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    // If start_zsl_snapshot is called to notify camera daemon about zsl snapshot
4266f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    bool m_bStartZSLSnapshotCalled;
4276f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
4286f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    power_module_t *m_pPowerModule;   // power module
4296f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
4306f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int mDumpFrmCnt;  // frame dump count
4316f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev    int mDumpSkipCnt; // frame skip count
4326f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev};
4336f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
4346f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev}; // namespace qcamera
4356f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev
4366f83d735d8e3b918da42e6b559fcd0efb78133e5Iliyan Malchev#endif /* __QCAMERA2HARDWAREINTERFACE_H__ */
437