• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 __QCAMERA_CHANNEL_H__
31 #define __QCAMERA_CHANNEL_H__
32 
33 #include <hardware/camera.h>
34 #include "QCameraStream.h"
35 
36 extern "C" {
37 #include <mm_camera_interface.h>
38 }
39 
40 namespace qcamera {
41 
42 class QCameraChannel
43 {
44 public:
45     QCameraChannel(uint32_t cam_handle,
46                    mm_camera_ops_t *cam_ops);
47     QCameraChannel();
48     virtual ~QCameraChannel();
49     virtual int32_t init(mm_camera_channel_attr_t *attr,
50                          mm_camera_buf_notify_t dataCB, // data CB for channel data
51                          void *userData);
52     // Owner of memory is transferred from the caller to the caller with this call.
53     virtual int32_t addStream(QCameraAllocator& allocator,
54                               QCameraHeapMemory *streamInfoBuf,
55                               uint8_t minStreamBufnum,
56                               cam_padding_info_t *paddingInfo,
57                               stream_cb_routine stream_cb,
58                               void *userdata);
59     virtual int32_t start();
60     virtual int32_t stop();
61     virtual int32_t bufDone(mm_camera_super_buf_t *recvd_frame);
62     virtual int32_t processZoomDone(preview_stream_ops_t *previewWindow,
63                                     cam_crop_data_t &crop_info);
64     QCameraStream *getStreamByHandle(uint32_t streamHandle);
getMyHandle()65     uint32_t getMyHandle() const {return m_handle;};
getNumOfStreams()66     uint8_t getNumOfStreams() const {return m_numStreams;};
67     QCameraStream *getStreamByIndex(uint8_t index);
68     QCameraStream *getStreamByServerID(uint32_t serverID);
69 
70 protected:
71     uint32_t m_camHandle;
72     mm_camera_ops_t *m_camOps;
73     bool m_bIsActive;
74 
75     uint32_t m_handle;
76     uint8_t m_numStreams;
77     QCameraStream *mStreams[MAX_STREAM_NUM_IN_BUNDLE];
78     mm_camera_buf_notify_t mDataCB;
79     void *mUserData;
80 };
81 
82 // burst pic channel: i.e. zsl burst mode
83 class QCameraPicChannel : public QCameraChannel
84 {
85 public:
86     QCameraPicChannel(uint32_t cam_handle,
87                       mm_camera_ops_t *cam_ops);
88     QCameraPicChannel();
89     virtual ~QCameraPicChannel();
90     int32_t takePicture(uint8_t num_of_snapshot);
91     int32_t cancelPicture();
92 };
93 
94 // video channel class
95 class QCameraVideoChannel : public QCameraChannel
96 {
97 public:
98     QCameraVideoChannel(uint32_t cam_handle,
99                         mm_camera_ops_t *cam_ops);
100     QCameraVideoChannel();
101     virtual ~QCameraVideoChannel();
102     int32_t releaseFrame(const void *opaque, bool isMetaData);
103 };
104 
105 // reprocess channel class
106 class QCameraReprocessChannel : public QCameraChannel
107 {
108 public:
109     QCameraReprocessChannel(uint32_t cam_handle,
110                             mm_camera_ops_t *cam_ops);
111     QCameraReprocessChannel();
112     virtual ~QCameraReprocessChannel();
113     int32_t addReprocStreamsFromSource(QCameraAllocator& allocator,
114                                        cam_pp_feature_config_t &config,
115                                        QCameraChannel *pSrcChannel,
116                                        uint8_t minStreamBufNum,
117                                        cam_padding_info_t *paddingInfo);
118     // online reprocess
119     int32_t doReprocess(mm_camera_super_buf_t *frame);
120     // offline reprocess
121     int32_t doReprocess(int buf_fd, uint32_t buf_length, int32_t &ret_val);
122 
123 private:
124     QCameraStream *getStreamBySrouceHandle(uint32_t srcHandle);
125 
126     uint32_t mSrcStreamHandles[MAX_STREAM_NUM_IN_BUNDLE];
127     QCameraChannel *m_pSrcChannel; // ptr to source channel for reprocess
128 };
129 
130 }; // namespace qcamera
131 
132 #endif /* __QCAMERA_CHANNEL_H__ */
133