• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2012-2016, The Linux Foundation. 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 __QCAMERA3_CHANNEL_H__
31 #define __QCAMERA3_CHANNEL_H__
32 
33 // System dependencies
34 #include <utils/List.h>
35 #include <utils/Mutex.h>
36 #include <utils/Vector.h>
37 #include "gralloc_priv.h"
38 
39 // Camera dependencies
40 #include "cam_intf.h"
41 #include "cam_types.h"
42 #include "camera3.h"
43 #include "QCamera3HALHeader.h"
44 #include "QCamera3Mem.h"
45 #include "QCamera3PostProc.h"
46 #include "QCamera3Stream.h"
47 #include "QCamera3StreamMem.h"
48 
49 extern "C" {
50 #include "mm_camera_interface.h"
51 #include "mm_jpeg_interface.h"
52 }
53 
54 using namespace android;
55 
56 #define MIN_STREAMING_BUFFER_NUM 7+11
57 
58 #define QCAMERA_DUMP_FRM_PREVIEW          1
59 #define QCAMERA_DUMP_FRM_VIDEO            (1<<1)
60 #define QCAMERA_DUMP_FRM_SNAPSHOT         (1<<2)
61 #define QCAMERA_DUMP_FRM_CALLBACK         (1<<3)
62 #define QCAMERA_DUMP_FRM_INPUT_REPROCESS  (1<<6)
63 
64 typedef int64_t nsecs_t;
65 
66 namespace qcamera {
67 
68 typedef void (*channel_cb_routine)(mm_camera_super_buf_t *metadata,
69                                 camera3_stream_buffer_t *buffer,
70                                 uint32_t frame_number, bool isInputBuffer,
71                                 void *userdata);
72 
73 typedef void (*channel_cb_buffer_err)(QCamera3Channel* ch, uint32_t frameNumber,
74                                 camera3_buffer_status_t err,
75                                 void *userdata);
76 
77 class QCamera3Channel
78 {
79 public:
80     QCamera3Channel(uint32_t cam_handle,
81                    uint32_t channel_handle,
82                    mm_camera_ops_t *cam_ops,
83                    channel_cb_routine cb_routine,
84                    channel_cb_buffer_err cb_buf_err,
85                    cam_padding_info_t *paddingInfo,
86                    cam_feature_mask_t postprocess_mask,
87                    void *userData, uint32_t numBuffers);
88     virtual ~QCamera3Channel();
89 
90     virtual int32_t start();
91     virtual int32_t stop();
92     virtual int32_t setBatchSize(uint32_t);
93     virtual int32_t queueBatchBuf();
94     virtual int32_t setPerFrameMapUnmap(bool enable);
95     int32_t bufDone(mm_camera_super_buf_t *recvd_frame);
96     int32_t setBundleInfo(const cam_bundle_config_t &bundleInfo);
97 
98     virtual uint32_t getStreamTypeMask();
99     uint32_t getStreamID(uint32_t streamMask);
100     void destroy();
101     virtual int32_t initialize(cam_is_type_t isType) = 0;
request(buffer_handle_t *,uint32_t,int &)102     virtual int32_t request(buffer_handle_t * /*buffer*/,
103                 uint32_t /*frameNumber*/,
104                 int &/*indexUsed*/){ return 0;};
request(buffer_handle_t *,uint32_t,camera3_stream_buffer_t *,metadata_buffer_t *,int &)105     virtual int32_t request(buffer_handle_t * /*buffer*/,
106                 uint32_t /*frameNumber*/,
107                 camera3_stream_buffer_t* /*pInputBuffer*/,
108                 metadata_buffer_t* /*metadata*/,
109                 int & /*indexUsed*/){ return 0;};
110     virtual void streamCbRoutine(mm_camera_super_buf_t *super_frame,
111                             QCamera3Stream *stream) = 0;
112 
113     virtual int32_t registerBuffer(buffer_handle_t *buffer, cam_is_type_t isType) = 0;
114     virtual QCamera3StreamMem *getStreamBufs(uint32_t len) = 0;
115     virtual void putStreamBufs() = 0;
116     virtual int32_t flush();
117 
118     QCamera3Stream *getStreamByHandle(uint32_t streamHandle);
getMyHandle()119     uint32_t getMyHandle() const {return m_handle;};
getNumOfStreams()120     uint32_t getNumOfStreams() const {return m_numStreams;};
getNumBuffers()121     uint32_t getNumBuffers() const {return mNumBuffers;};
122     QCamera3Stream *getStreamByIndex(uint32_t index);
123 
124     static void streamCbRoutine(mm_camera_super_buf_t *super_frame,
125                 QCamera3Stream *stream, void *userdata);
126     void dumpYUV(mm_camera_buf_def_t *frame, cam_dimension_t dim,
127             cam_frame_len_offset_t offset, uint8_t name);
128     static bool isUBWCEnabled();
129     static cam_format_t getStreamDefaultFormat(cam_stream_type_t type,
130             uint32_t width, uint32_t height);
131     virtual int32_t timeoutFrame(__unused uint32_t frameNumber) = 0;
132 
133     void *mUserData;
134     cam_padding_info_t mPaddingInfo;
135     QCamera3Stream *mStreams[MAX_STREAM_NUM_IN_BUNDLE];
136     uint32_t m_numStreams;
137 protected:
138 
139     int32_t addStream(cam_stream_type_t streamType,
140                       cam_format_t streamFormat,
141                       cam_dimension_t streamDim,
142                       cam_rotation_t streamRotation,
143                       uint8_t minStreamBufnum,
144                       cam_feature_mask_t postprocessMask,
145                       cam_is_type_t isType,
146                       uint32_t batchSize = 0);
147 
148     int32_t allocateStreamInfoBuf(camera3_stream_t *stream);
149 
150     uint32_t m_camHandle;
151     mm_camera_ops_t *m_camOps;
152     bool m_bIsActive;
153 
154     uint32_t m_handle;
155 
156 
157     mm_camera_buf_notify_t mDataCB;
158 
159 
160     QCamera3HeapMemory *mStreamInfoBuf;
161     channel_cb_routine mChannelCB;
162     channel_cb_buffer_err mChannelCbBufErr;
163     //cam_padding_info_t *mPaddingInfo;
164     cam_feature_mask_t mPostProcMask;
165     uint32_t mYUVDump;
166     cam_is_type_t mIsType;
167     uint32_t mNumBuffers;
168     /* Enable unmapping of buffer before issuing buffer callback. Default value
169      * for this flag is true and is selectively set to false for the usecases
170      * such as HFR to avoid any performance hit due to mapping/unmapping */
171     bool    mPerFrameMapUnmapEnable;
172     uint32_t mFrmNum;
173     uint32_t mDumpFrmCnt;
174     uint32_t mSkipMode;
175     uint32_t mDumpSkipCnt;
176 };
177 
178 /* QCamera3ProcessingChannel is used to handle all streams that are directly
179  * generated by hardware and given to frameworks without any postprocessing at HAL.
180  * It also handles input streams that require reprocessing by hardware and then
181  * returned to frameworks. */
182 class QCamera3ProcessingChannel : public QCamera3Channel
183 {
184 public:
185    QCamera3ProcessingChannel(uint32_t cam_handle,
186            uint32_t channel_handle,
187            mm_camera_ops_t *cam_ops,
188            channel_cb_routine cb_routine,
189            channel_cb_buffer_err cb_buffer_err,
190            cam_padding_info_t *paddingInfo,
191            void *userData,
192            camera3_stream_t *stream,
193            cam_stream_type_t stream_type,
194            cam_feature_mask_t postprocess_mask,
195            QCamera3Channel *metadataChannel,
196            uint32_t numBuffers = MAX_INFLIGHT_REQUESTS);
197 
198     ~QCamera3ProcessingChannel();
199 
200     virtual int32_t initialize(cam_is_type_t isType);
201     virtual int32_t request(buffer_handle_t *buffer,
202             uint32_t frameNumber,
203             camera3_stream_buffer_t* pInputBuffer,
204             metadata_buffer_t* metadata, int &indexUsed);
205     virtual void streamCbRoutine(mm_camera_super_buf_t *super_frame,
206             QCamera3Stream *stream);
207     virtual QCamera3StreamMem *getStreamBufs(uint32_t len);
208     virtual void putStreamBufs();
209     virtual int32_t registerBuffer(buffer_handle_t *buffer, cam_is_type_t isType);
210 
211     virtual int32_t stop();
212 
213     virtual reprocess_type_t getReprocessType() = 0;
214 
215     virtual void reprocessCbRoutine(buffer_handle_t *resultBuffer,
216             uint32_t resultFrameNumber);
217 
218     int32_t queueReprocMetadata(mm_camera_super_buf_t *metadata);
219     int32_t metadataBufDone(mm_camera_super_buf_t *recvd_frame);
220     int32_t translateStreamTypeAndFormat(camera3_stream_t *stream,
221             cam_stream_type_t &streamType,
222             cam_format_t &streamFormat);
223     int32_t setReprocConfig(reprocess_config_t &reproc_cfg,
224             camera3_stream_buffer_t *pInputBuffer,
225             metadata_buffer_t *metadata,
226             cam_format_t streamFormat, cam_dimension_t dim);
227     int32_t setFwkInputPPData(qcamera_fwk_input_pp_data_t *src_frame,
228             camera3_stream_buffer_t *pInputBuffer,
229             reprocess_config_t *reproc_cfg,
230             metadata_buffer_t *metadata,
231             buffer_handle_t *output_buffer,
232             uint32_t frameNumber);
233     int32_t checkStreamCbErrors(mm_camera_super_buf_t *super_frame,
234             QCamera3Stream *stream);
235     int32_t getStreamSize(cam_dimension_t &dim);
236     virtual int32_t timeoutFrame(uint32_t frameNumber);
237 
238     QCamera3PostProcessor m_postprocessor; // post processor
239     void showDebugFPS(int32_t streamType);
240     int32_t releaseOfflineMemory(uint32_t resultFrameNumber);
241 
242 protected:
243     uint8_t mDebugFPS;
244     int mFrameCount;
245     int mLastFrameCount;
246     nsecs_t mLastFpsTime;
isWNREnabled()247     bool isWNREnabled() {return m_bWNROn;};
248     void startPostProc(const reprocess_config_t &reproc_cfg);
249     void issueChannelCb(buffer_handle_t *resultBuffer,
250             uint32_t resultFrameNumber);
251 
252     QCamera3StreamMem mMemory; //output buffer allocated by fwk
253     camera3_stream_t *mCamera3Stream;
254     uint32_t mNumBufs;
255     cam_stream_type_t mStreamType;
256     cam_format_t mStreamFormat;
257     uint8_t mIntent;
258 
259     bool mPostProcStarted;
260     bool mInputBufferConfig;   // Set when the processing channel is configured
261                                // for processing input(framework) buffers
262 
263     QCamera3Channel *m_pMetaChannel;
264     mm_camera_super_buf_t *mMetaFrame;
265     QCamera3StreamMem mOfflineMemory;      //reprocessing input buffer
266     QCamera3StreamMem mOfflineMetaMemory; //reprocessing metadata buffer
267     List<uint32_t> mFreeOfflineMetaBuffersList;
268     Mutex mFreeOfflineMetaBuffersLock;
269     android::List<mm_camera_super_buf_t *> mOutOfSequenceBuffers;
270 
271 private:
272 
273     bool m_bWNROn;
274 };
275 
276 /* QCamera3RegularChannel is used to handle all streams that are directly
277  * generated by hardware and given to frameworks without any postprocessing at HAL.
278  * Examples are: all IMPLEMENTATION_DEFINED streams, CPU_READ streams. */
279 class QCamera3RegularChannel : public QCamera3ProcessingChannel
280 {
281 public:
282     QCamera3RegularChannel(uint32_t cam_handle,
283                     uint32_t channel_handle,
284                     mm_camera_ops_t *cam_ops,
285                     channel_cb_routine cb_routine,
286                     channel_cb_buffer_err cb_buffer_err,
287                     cam_padding_info_t *paddingInfo,
288                     void *userData,
289                     camera3_stream_t *stream,
290                     cam_stream_type_t stream_type,
291                     cam_feature_mask_t postprocess_mask,
292                     QCamera3Channel *metadataChannel,
293                     uint32_t numBuffers = MAX_INFLIGHT_REQUESTS);
294 
295     virtual ~QCamera3RegularChannel();
296 
297     virtual int32_t setBatchSize(uint32_t batchSize);
298     virtual uint32_t getStreamTypeMask();
299     virtual int32_t queueBatchBuf();
300     virtual int32_t initialize(cam_is_type_t isType);
301     using QCamera3ProcessingChannel::request;
302     virtual int32_t request(buffer_handle_t *buffer, uint32_t frameNumber,
303                     int &indexUsed);
304     virtual reprocess_type_t getReprocessType();
305 
306 private:
307     int32_t initialize(struct private_handle_t *priv_handle);
308 
309     uint32_t mBatchSize;
310     cam_rotation_t mRotation;
311 };
312 
313 /* QCamera3MetadataChannel is for metadata stream generated by camera daemon. */
314 class QCamera3MetadataChannel : public QCamera3Channel
315 {
316 public:
317     QCamera3MetadataChannel(uint32_t cam_handle,
318                     uint32_t channel_handle,
319                     mm_camera_ops_t *cam_ops,
320                     channel_cb_routine cb_routine,
321                     channel_cb_buffer_err cb_buffer_err,
322                     cam_padding_info_t *paddingInfo,
323                     cam_feature_mask_t postprocess_mask,
324                     void *userData,
325                     uint32_t numBuffers = MIN_STREAMING_BUFFER_NUM);
326     virtual ~QCamera3MetadataChannel();
327 
328     virtual int32_t initialize(cam_is_type_t isType);
329 
330     virtual int32_t request(buffer_handle_t *buffer, uint32_t frameNumber,
331                     int &indexUsed);
332     virtual void streamCbRoutine(mm_camera_super_buf_t *super_frame,
333                             QCamera3Stream *stream);
334 
335     virtual QCamera3StreamMem *getStreamBufs(uint32_t le);
336     virtual void putStreamBufs();
registerBuffer(buffer_handle_t *,cam_is_type_t)337     virtual int32_t registerBuffer(buffer_handle_t * /*buffer*/, cam_is_type_t /*isType*/)
338             { return NO_ERROR; };
timeoutFrame(__unused uint32_t frameNumber)339     virtual int32_t timeoutFrame(__unused uint32_t frameNumber) {return NO_ERROR; };
340 
341 private:
342     QCamera3StreamMem *mMemory;
343 };
344 
345 /* QCamera3RawChannel is for opaqueu/cross-platform raw stream containing
346  * vendor specific bayer data or 16-bit unpacked bayer data */
347 class QCamera3RawChannel : public QCamera3RegularChannel
348 {
349 public:
350     QCamera3RawChannel(uint32_t cam_handle,
351                     uint32_t channel_handle,
352                     mm_camera_ops_t *cam_ops,
353                     channel_cb_routine cb_routine,
354                     channel_cb_buffer_err cb_buffer_err,
355                     cam_padding_info_t *paddingInfo,
356                     void *userData,
357                     camera3_stream_t *stream,
358                     cam_feature_mask_t postprocess_mask,
359                     QCamera3Channel *metadataChannel,
360                     bool raw_16 = false,
361                     uint32_t numBuffers = MAX_INFLIGHT_REQUESTS);
362 
363     virtual ~QCamera3RawChannel();
364 
365     virtual int32_t initialize(cam_is_type_t isType);
366 
367     virtual void streamCbRoutine(mm_camera_super_buf_t *super_frame,
368                             QCamera3Stream *stream);
369 
370     virtual reprocess_type_t getReprocessType();
371 
372 private:
373     bool mRawDump;
374     bool mIsRaw16;
375 
376     void dumpRawSnapshot(mm_camera_buf_def_t *frame);
377     void convertLegacyToRaw16(mm_camera_buf_def_t *frame);
378     void convertMipiToRaw16(mm_camera_buf_def_t *frame);
379 };
380 
381 /*
382  * QCamera3RawDumpChannel is for internal use only for Raw dump
383  */
384 
385 class QCamera3RawDumpChannel : public QCamera3Channel
386 {
387 public:
388     QCamera3RawDumpChannel(uint32_t cam_handle,
389                     uint32_t channel_handle,
390                     mm_camera_ops_t *cam_ops,
391                     cam_dimension_t rawDumpSize,
392                     cam_padding_info_t *paddingInfo,
393                     void *userData,
394                     cam_feature_mask_t postprocess_mask, uint32_t numBuffers = 3U);
395     virtual ~QCamera3RawDumpChannel();
396     virtual int32_t initialize(cam_is_type_t isType);
397     virtual void streamCbRoutine(mm_camera_super_buf_t *super_frame,
398                             QCamera3Stream *stream);
399     virtual QCamera3StreamMem *getStreamBufs(uint32_t le);
400     virtual void putStreamBufs();
registerBuffer(buffer_handle_t *,cam_is_type_t)401     virtual int32_t registerBuffer(buffer_handle_t * /*buffer*/, cam_is_type_t /*isType*/)
402             { return NO_ERROR; };
timeoutFrame(__unused uint32_t frameNumber)403     virtual int32_t timeoutFrame(__unused uint32_t frameNumber) {return NO_ERROR;};
404     virtual int32_t request(buffer_handle_t *buffer, uint32_t frameNumber,
405             int &indexUsed);
406     void dumpRawSnapshot(mm_camera_buf_def_t *frame);
407 
408 public:
409     cam_dimension_t mDim;
410 
411 private:
412     bool mRawDump;
413     QCamera3StreamMem *mMemory;
414 };
415 
416 /* QCamera3YUVChannel is used to handle flexible YUV streams that are directly
417  * generated by hardware and given to frameworks without any postprocessing at HAL.
418  * It is also used to handle input buffers that generate YUV outputs */
419 class QCamera3YUVChannel : public QCamera3ProcessingChannel
420 {
421 public:
422     QCamera3YUVChannel(uint32_t cam_handle,
423             uint32_t channel_handle,
424             mm_camera_ops_t *cam_ops,
425             channel_cb_routine cb_routine,
426             channel_cb_buffer_err cb_buffer_err,
427             cam_padding_info_t *paddingInfo,
428             void *userData,
429             camera3_stream_t *stream,
430             cam_stream_type_t stream_type,
431             cam_feature_mask_t postprocess_mask,
432             QCamera3Channel *metadataChannel);
433     ~QCamera3YUVChannel();
434     virtual int32_t initialize(cam_is_type_t isType);
435     using QCamera3ProcessingChannel::request;
436     virtual int32_t request(buffer_handle_t *buffer,
437             uint32_t frameNumber,
438             camera3_stream_buffer_t* pInputBuffer,
439             metadata_buffer_t* metadata, bool &needMetadata,
440             int &indexUsed);
441     virtual reprocess_type_t getReprocessType();
442     virtual void streamCbRoutine(mm_camera_super_buf_t *super_frame,
443             QCamera3Stream *stream);
444     virtual void putStreamBufs();
445     virtual void reprocessCbRoutine(buffer_handle_t *resultBuffer,
446         uint32_t resultFrameNumber);
447 
448 private:
449     typedef struct {
450         uint32_t frameNumber;
451         bool offlinePpFlag;
452         buffer_handle_t *output;
453         mm_camera_super_buf_t *callback_buffer;
454     } PpInfo;
455 
456     // Whether offline postprocessing is required for this channel
457     bool mBypass;
458     uint32_t mFrameLen;
459 
460     // Current edge, noise, and crop region setting
461     cam_edge_application_t mEdgeMode;
462     uint32_t mNoiseRedMode;
463     cam_crop_region_t mCropRegion;
464 
465     // Mutex to protect mOfflinePpFlagMap and mFreeHeapBufferList
466     Mutex mOfflinePpLock;
467     // Map between free number and whether the request needs to be
468     // postprocessed.
469     List<PpInfo> mOfflinePpInfoList;
470     // Heap buffer index list
471     List<uint32_t> mFreeHeapBufferList;
472 
473 private:
474     bool needsFramePostprocessing(metadata_buffer_t* meta);
475     int32_t handleOfflinePpCallback(uint32_t resultFrameNumber,
476             Vector<mm_camera_super_buf_t *>& pendingCbs);
477     mm_camera_super_buf_t* getNextPendingCbBuffer();
478 };
479 
480 /* QCamera3PicChannel is for JPEG stream, which contains a YUV stream generated
481  * by the hardware, and encoded to a JPEG stream */
482 class QCamera3PicChannel : public QCamera3ProcessingChannel
483 {
484 public:
485     QCamera3PicChannel(uint32_t cam_handle,
486             uint32_t channel_handle,
487             mm_camera_ops_t *cam_ops,
488             channel_cb_routine cb_routine,
489             channel_cb_buffer_err cb_buffer_err,
490             cam_padding_info_t *paddingInfo,
491             void *userData,
492             camera3_stream_t *stream,
493             cam_feature_mask_t postprocess_mask,
494             bool is4KVideo,
495             bool isInputStreamConfigured,
496             QCamera3Channel *metadataChannel,
497             uint32_t numBuffers = MAX_INFLIGHT_REQUESTS);
498     ~QCamera3PicChannel();
499 
500     virtual int32_t initialize(cam_is_type_t isType);
501     virtual int32_t flush();
502     virtual int32_t request(buffer_handle_t *buffer,
503             uint32_t frameNumber,
504             camera3_stream_buffer_t* pInputBuffer,
505             metadata_buffer_t* metadata,
506             int &indexUsed);
507     virtual void streamCbRoutine(mm_camera_super_buf_t *super_frame,
508             QCamera3Stream *stream);
509 
510     virtual QCamera3StreamMem *getStreamBufs(uint32_t le);
511     virtual void putStreamBufs();
512     virtual reprocess_type_t getReprocessType();
513     virtual int32_t timeoutFrame(uint32_t frameNumber);
514 
515     QCamera3Exif *getExifData(metadata_buffer_t *metadata,
516             jpeg_settings_t *jpeg_settings);
517     void overrideYuvSize(uint32_t width, uint32_t height);
518     static void jpegEvtHandle(jpeg_job_status_t status,
519             uint32_t /*client_hdl*/,
520             uint32_t jobId,
521             mm_jpeg_output_t *p_output,
522             void *userdata);
523     static void dataNotifyCB(mm_camera_super_buf_t *recvd_frame,
524             void *userdata);
525     void setCppPerfParam();
526     void resetCppPerfParam();
527 
528 private:
529     int32_t queueJpegSetting(uint32_t out_buf_index, metadata_buffer_t *metadata);
530 
531 public:
532     cam_dimension_t m_max_pic_dim;
533 
534 private:
535     uint32_t mNumSnapshotBufs;
536     uint32_t mYuvWidth, mYuvHeight;
537     int32_t mCurrentBufIndex;
538     bool mInputBufferHint;
539     QCamera3StreamMem *mYuvMemory;
540     // Keep a list of free buffers
541     Mutex mFreeBuffersLock;
542     List<uint32_t> mFreeBufferList;
543     uint32_t mFrameLen;
544     uint32_t mPendingLiveSnapshotFrames;
545 };
546 
547 // reprocess channel class
548 class QCamera3ReprocessChannel : public QCamera3Channel
549 {
550 public:
551     QCamera3ReprocessChannel(uint32_t cam_handle,
552                             uint32_t channel_handle,
553                             mm_camera_ops_t *cam_ops,
554                             channel_cb_routine cb_routine,
555                             channel_cb_buffer_err cb_buffer_err,
556                             cam_padding_info_t *paddingInfo,
557                             cam_feature_mask_t postprocess_mask,
558                             void *userData, void *ch_hdl);
559     QCamera3ReprocessChannel();
560     virtual ~QCamera3ReprocessChannel();
561     // offline reprocess
562     virtual int32_t start();
563     virtual int32_t stop();
564     int32_t doReprocessOffline(qcamera_fwk_input_pp_data_t *frame,
565             bool isPriorityFrame = false);
566     int32_t doReprocess(int buf_fd,void *buffer, size_t buf_length, int32_t &ret_val,
567                         mm_camera_super_buf_t *meta_buf);
568     int32_t overrideMetadata(qcamera_hal3_pp_buffer_t *pp_buffer,
569             mm_camera_buf_def_t *meta_buffer,
570             jpeg_settings_t *jpeg_settings,
571             qcamera_fwk_input_pp_data_t &fwk_frame);
572     int32_t overrideFwkMetadata(qcamera_fwk_input_pp_data_t *frame);
573     virtual QCamera3StreamMem *getStreamBufs(uint32_t len);
574     virtual void putStreamBufs();
575     virtual int32_t initialize(cam_is_type_t isType);
576     int32_t unmapOfflineBuffers(bool all);
577     int32_t bufDone(mm_camera_super_buf_t *recvd_frame);
578     virtual void streamCbRoutine(mm_camera_super_buf_t *super_frame,
579                             QCamera3Stream *stream);
580     static void dataNotifyCB(mm_camera_super_buf_t *recvd_frame,
581                                        void* userdata);
582     int32_t addReprocStreamsFromSource(cam_pp_feature_config_t &pp_config,
583            const reprocess_config_t &src_config,
584            cam_is_type_t is_type,
585            QCamera3Channel *pMetaChannel);
586     QCamera3Stream *getStreamBySrcHandle(uint32_t srcHandle);
587     QCamera3Stream *getSrcStreamBySrcHandle(uint32_t srcHandle);
588     virtual int32_t registerBuffer(buffer_handle_t * buffer, cam_is_type_t isType);
timeoutFrame(__unused uint32_t frameNumber)589     virtual int32_t timeoutFrame(__unused uint32_t frameNumber) {return NO_ERROR;};
590 
591 public:
592     void *inputChHandle;
593 
594 private:
595     typedef struct {
596         QCamera3Stream *stream;
597         cam_mapping_buf_type type;
598         uint32_t index;
599     } OfflineBuffer;
600 
601     int32_t resetToCamPerfNormal(uint32_t frameNumber);
602     Mutex mOfflineBuffersLock; // Lock for offline buffers
603     android::List<OfflineBuffer> mOfflineBuffers;
604     android::List<OfflineBuffer> mOfflineMetaBuffers;
605     int32_t mOfflineBuffersIndex;
606     int32_t mOfflineMetaIndex;
607     uint32_t mFrameLen;
608     Mutex mFreeBuffersLock; // Lock for free heap buffers
609     List<int32_t> mFreeBufferList; // Free heap buffers list
610     reprocess_type_t mReprocessType;
611     uint32_t mSrcStreamHandles[MAX_STREAM_NUM_IN_BUNDLE];
612     QCamera3ProcessingChannel *m_pSrcChannel; // ptr to source channel for reprocess
613     QCamera3Channel *m_pMetaChannel;
614     QCamera3StreamMem *mMemory;
615     QCamera3StreamMem mGrallocMemory;
616     Vector<uint32_t> mPriorityFrames;
617     Mutex            mPriorityFramesLock;
618     bool             mReprocessPerfMode;
619 };
620 
621 
622 /* QCamera3SupportChannel is for HAL internal consumption only */
623 class QCamera3SupportChannel : public QCamera3Channel
624 {
625 public:
626     QCamera3SupportChannel(uint32_t cam_handle,
627                     uint32_t channel_handle,
628                     mm_camera_ops_t *cam_ops,
629                     cam_padding_info_t *paddingInfo,
630                     cam_feature_mask_t postprocess_mask,
631                     cam_stream_type_t streamType,
632                     cam_dimension_t *dim,
633                     cam_format_t streamFormat,
634                     uint8_t hw_analysis_supported,
635                     void *userData,
636                     uint32_t numBuffers = MIN_STREAMING_BUFFER_NUM
637                     );
638     virtual ~QCamera3SupportChannel();
639 
640     virtual int32_t initialize(cam_is_type_t isType);
641 
642     virtual int32_t request(buffer_handle_t *buffer, uint32_t frameNumber,
643                     int &indexUsed);
644     virtual void streamCbRoutine(mm_camera_super_buf_t *super_frame,
645                             QCamera3Stream *stream);
646 
647     virtual QCamera3StreamMem *getStreamBufs(uint32_t le);
648     virtual void putStreamBufs();
registerBuffer(buffer_handle_t *,cam_is_type_t)649     virtual int32_t registerBuffer(buffer_handle_t * /*buffer*/, cam_is_type_t /*isType*/)
650             { return NO_ERROR; };
timeoutFrame(__unused uint32_t frameNumber)651     virtual int32_t timeoutFrame(__unused uint32_t frameNumber) {return NO_ERROR;};
652 
653     static cam_dimension_t kDim;
654 private:
655     QCamera3StreamMem *mMemory;
656     cam_dimension_t mDim;
657     cam_stream_type_t mStreamType;
658     cam_format_t mStreamFormat;
659 };
660 
661 }; // namespace qcamera
662 
663 #endif /* __QCAMERA_CHANNEL_H__ */
664