QCamera3HWI.h revision 625515beb9c1347216a2d261930ceb0d85ba1c47
1/* Copyright (c) 2012-2013, The Linux Foundataion. All rights reserved.
2*
3* Redistribution and use in source and binary forms, with or without
4* modification, are permitted provided that the following conditions are
5* met:
6*     * Redistributions of source code must retain the above copyright
7*       notice, this list of conditions and the following disclaimer.
8*     * Redistributions in binary form must reproduce the above
9*       copyright notice, this list of conditions and the following
10*       disclaimer in the documentation and/or other materials provided
11*       with the distribution.
12*     * Neither the name of The Linux Foundation nor the names of its
13*       contributors may be used to endorse or promote products derived
14*       from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19* ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*
28*/
29
30#ifndef __QCAMERA2HARDWAREINTERFACE_H__
31#define __QCAMERA2HARDWAREINTERFACE_H__
32
33#include <utils/List.h>
34#include <hardware/camera3.h>
35#include <camera/CameraMetadata.h>
36
37extern "C" {
38#include <mm_camera_interface.h>
39#include <mm_jpeg_interface.h>
40}
41
42using namespace android;
43
44namespace qcamera {
45
46#ifndef TRUE
47#define TRUE 1
48#endif
49
50#ifndef FALSE
51#define FALSE 0
52#endif
53
54class QCamera3MetadataChannel;
55
56class QCamera3HardwareInterface {
57public:
58    /* static variable and functions accessed by camera service */
59    static camera3_device_ops_t mCameraOps;
60    static int initialize(const struct camera3_device *, const camera3_callback_ops_t *callback_ops);
61    static int configure_streams(const struct camera3_device *, camera3_stream_configuration_t *stream_list);
62    static int register_stream_buffers(const struct camera3_device *, const camera3_stream_buffer_set_t *buffer_set);
63    static const camera_metadata_t* construct_default_request_settings(const struct camera3_device *, int type);
64    static int process_capture_request(const struct camera3_device *, camera3_capture_request_t *request);
65    static void get_metadata_vendor_tag_ops(const struct camera3_device *, vendor_tag_query_ops_t* ops);
66    static void dump(const struct camera3_device *, int fd);
67
68public:
69    QCamera3HardwareInterface(int cameraId);
70    virtual ~QCamera3HardwareInterface();
71    int openCamera(struct hw_device_t **hw_device);
72    int getMetadata(int type);
73    camera_metadata_t* translateMetadata(int type);
74
75    static int getCamInfo(int cameraId, struct camera_info *info);
76    static int initCapabilities(int cameraId);
77    static int initStaticMetadata(int cameraId);
78
79    static void channelCbRoutine(mm_camera_buf_def_t *frame,
80                camera3_stream_buffer_t *buffer, void *userdata);
81
82    void sendCaptureResult(const struct camera3_callback_ops *, const camera3_capture_result_t *result);
83    void notify(const struct camera3_callback_ops *, const camera3_notify_msg_t *msg);
84
85    int initialize(const camera3_callback_ops_t *callback_ops);
86    int configureStreams(camera3_stream_configuration_t *stream_list);
87    int registerStreamBuffers(const camera3_stream_buffer_set_t *buffer_set);
88private:
89
90    int openCamera();
91    int closeCamera();
92
93public:
94
95private:
96    camera3_device_t   mCameraDevice;
97    uint8_t            mCameraId;
98    mm_camera_vtbl_t  *mCameraHandle;
99    bool               mCameraOpened;
100    camera_metadata_t *mDefaultMetadata[CAMERA3_TEMPLATE_COUNT];
101
102    const camera3_callback_ops_t *mCallbackOps;
103
104    camera3_stream_t *mInputStream;
105    QCamera3MetadataChannel *mMetadataChannel;
106};
107
108}; // namespace qcamera
109
110#endif /* __QCAMERA2HARDWAREINTERFACE_H__ */
111